Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT][API] Add create_avatarization_multi_table_job API #69

Open
youen opened this issue Mar 31, 2024 · 0 comments
Open

[FEAT][API] Add create_avatarization_multi_table_job API #69

youen opened this issue Mar 31, 2024 · 0 comments

Comments

@youen
Copy link
Member

youen commented Mar 31, 2024

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:

{
  "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:

{
  "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

// 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

// 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

Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant