CGI-FR / CGI-FR/SIGO

[FEAT][API] Add `create_avatarization_multi_table_job` API

Open
#69 0 comments 0 reactions 0 assignees View on GitHub
api octopize
Dominant language
Go
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Description
Adds an API to create an avatarization for relational data.

## Request

### Method
`POST`

### URL
```
/jobs/avatarization_multi_table
```

### Request Parameters

| Parameter | Description | Required | Example |
|---|---|---|---|
| `kind` | Must be `avatarization_multi_table` | `false` | `avatarization_multi_table` |
| `parameters` | Parameters for the avatarization job | `true` | See below |

### Request Body

The request body should be a JSON object with the following fields:

```json
{
"parameters": {
"input_uri": "gs://my-bucket/input-data.csv",
"schema_uri": "gs://my-bucket/input-schema.json",
"output_uri": "gs://my-bucket/output-data",
"feature_columns": [
"age",
"gender"
],
"target_column": "label",
"train_fraction": 0.8,
"eval_fraction": 0.1,
"test_fraction": 0.1,
"model_params": {
"num_trees": 100,
"max_depth": 5
}
}
}
```

## Result

### Result parameters

| Parameter | Description | Example |
|---|---|---|
| `id` | The ID of the job | `1234567890` |
| `kind` | The kind of job | `avatarization_multi_table` |
| `created_at` | The time the job was created | `2023-03-08T12:34:56Z` |
| `status` | The status of the job | `CREATED` |
| `error_message` | The error message, if any | `null` |
| `traceback` | The traceback, if any | `null` |
| `result` | The result of the job, if any | `null` |
| `parameters` | The parameters of the job | See above |
| `current_progress` | The current progress of the job | `null` |

### Result Body

The result body will be a JSON object with the following fields:

```json
{
"id": "1234567890",
"kind": "avatarization_multi_table",
"created_at": "2023-03-08T12:34:56Z",
"status": "CREATED",
"error_message": null,
"traceback": null,
"result": null,
"parameters": {
"input_uri": "gs://my-bucket/input-data.csv",
"schema_uri": "gs://my-bucket/input-schema.json",
"output_uri": "gs://my-bucket/output-data",
"feature_columns": [
"age",
"gender"
],
"target_column": "label",
"train_fraction": 0.8,
"eval_fraction": 0.1,
"test_fraction": 0.1,
"model_params": {
"num_trees": 100,
"max_depth": 5
}
},
"current_progress": null
}
```

## Example Curl Request

```
curl -X POST -H "Content-Type: application/json" -d '{
"parameters": {
"input_uri": "gs://my-bucket/input-data.csv",
"schema_uri": "gs://my-bucket/input-schema.json",
"output_uri": "gs://my-bucket/output-data",
"feature_columns": [
"age",
"gender"
],
"target_column": "label",
"train_fraction": 0.8,
"eval_fraction": 0.1,
"test_fraction": 0.1,
"model_params": {
"num_trees": 100,
"max_depth": 5
}
}
}' http://localhost:8080/jobs/avatarization_multi_table
```

## Go server

### Struct
```go
// AvatarizationMultiTableJob is a job that creates an avatarization for relational data.
type AvatarizationMultiTableJob struct {
ID uuid.UUID `json:"id"`
Kind JobKind `json:"kind"`
CreatedAt time.Time `json:"created_at"`
Status JobStatus `json:"status"`
ErrorMessage *string `json:"error_message"`
Traceback *string `json:"traceback"`
Result *AvatarizationMultiTableResult `json:"result"`
Parameters AvatarizationMultiTableParameters `json:"parameters"`
CurrentProgress *JobProgress `json:"current_progress"`
}
```

### Handler
```go
// CreateAvatarizationMultiTableJob creates a new avatarization job.
func (s *Server) CreateAvatarizationMultiTableJob(w http.ResponseWriter, r *http.Request) {
var req AvatarizationMultiTableJobCreate
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}

job, err := s.avatarizationService.CreateJob(r.Context(), req.Parameters)
if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}

w.WriteHeader(http.StatusCreated)
if err := json.NewEncoder(w).Encode(job); err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
}
```
## Links

- [Jobs.create_avatarization_multi_table_job](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L566)
- [AvatarizationMultiTableJobCreate](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L566)
- [AvatarizationMultiTableJob](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L566)

## Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project [avatar-python](https://github.com/octopize/avatar-python/) to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.

Best regards,
The SIGO Team

Contributor guide

Open the contributing guide

Research direction

Locate the Go server's CreateAvatarizationMultiTableJob handler and the avatarizationService.CreateJob entry point, then compare the linked Python API definitions. The work is done when POST /jobs/avatarization_multi_table accepts the documented parameters and returns the documented 201 job response.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.