API Client

API Client represents a low level interface for training API. All API operation can be performed using this.

class abeja.train.APIClient(credential: dict | None = None, timeout: int | None = None, max_retry_count: int | None = None)

A Low-Level client for Training API

from abeja.training import APIClient

api_client = APIClient()
archive_training_job(organization_id: str, job_definition_name: str, training_job_id: str) dict

Archive a training job.

API reference: POST /organizations/<organization_id>/training/definitions/{job_definition_name}/jobs/{training_job_id}/archive

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test"
training_job_id = "1234567890123"
response = api_client.archive_training_job(organization_id,
                                           job_definition_name,
                                           training_job_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • training_job_id (str): TRAINING_JOB_ID

Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

archive_training_job_definition(organization_id: str, job_definition_name: str) dict

archive a training job definition

API reference: POST /organizations/<organization_id>/training/definitions/{name}/archive

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test"
response = api_client.archive_training_job_definition(organization_id,
                                                     job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

archive_training_job_definition_version(organization_id: str, job_definition_name: str, version_id: int) dict

archive a training job definition version

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/versions/<version_id>/archive

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
version_id = 1
response = api_client.archive_training_job_definition_version(organization_id, job_definition_name, version_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • version_id (int): training job version

Return type:

dict

Returns:

Response Syntax:

{
    "message": "archived"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

archive_training_model(organization_id: str, job_definition_name: str, model_id: str) dict

archive a training model

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/models/<model_id>/archive

Request Syntax:
response = api_client.archive_training_model(
    organization_id='1111111111111', job_definition_name='1111111111111', model_id='1111111111111')
Params:
  • organization_id (str): organization_id

  • job_definition_name (str): training job definition name

  • model_id (str): model_id of the requested model

Return type:

dict

Returns:
Response Syntax:
{
     "message": "{job_definition_name}:{model_id} archived"
}
Response Structure:
  • message (str) : message

Raises:
  • NotFound: model not found

  • Unauthorized: Authentication failed

  • InternalServerError

create_training_job(organization_id: str, job_definition_name: str, version_id: int, user_parameters: dict | None = None, datasets: dict | None = None, instance_type: str | None = None, environment: dict | None = None, description: str | None = None, export_log: bool | None = None) dict

create a training job

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/versions/<version_id>/jobs

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
version_id = 1
user_parameters = {
    'BATCH_SIZE': 50
}
datasets = {
    "mnist": "1111111111111"
}
response = api_client.create_training_job(
    organization_id, job_definition_name, version_id, user_parameters, datasets)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • version_id (int): training job version

  • user_parameters (dict): (deprecated!!) user defined parameters set as environment variables. use environment instead.

  • datasets (dict): [optional] datasets, combination of alias and dataset_id

  • instance_type (str): [optional] instance type of running environment

  • environment (dict): [optional] user defined parameters set as environment variables

  • description (str): [optional] description of this job

  • export_log (bool): [optional] If true, include the log in the model. This feature is only available with 19.04 or later images. (default: false)

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_id": "1443714239154",
    "user_parameters": {},
    "start_time": null,
    "created_at": "2018-05-17T12:43:59.322367Z",
    "job_definition_version": 1,
    "completion_time": null,
    "status": "Pending",
    "instance_type": "cpu-1",
    "modified_at": "2018-05-17T12:43:59.322673Z",
    "training_job_id": "1443722127663",
    "creator": {
        "email": "test@abeja.asia",
        "is_registered": true,
        "created_at": "2017-05-26T01:38:46Z",
        "id": "1128347408389",
        "display_name": null,
        "updated_at": "2018-01-04T03:02:12Z",
        "role": "admin"
    },
    "description": null,
    "statistics": null
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_training_job_definition(organization_id: str, job_definition_name: str) dict

create a training job definition

API reference: POST /organizations/<organization_id>/training/definitions

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test"
response = api_client.create_training_job_definition(organization_id,
                                                     job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_id": "1443334816413",
    "versions": [],
    "organization_id": "1200123565071",
    "modified_at": "2018-05-17T02:13:35.726812Z",
    "created_at": "2018-05-17T02:13:35.726691Z",
    "version_count": 0,
    "name": "test"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_training_job_definition_version(organization_id: str, job_definition_name: str, filepaths: List[str], handler: str, image: str | None = None, environment: Dict[str, Any] | None = None, description: str | None = None) dict

create a training job definition version.

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/versions

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
filepaths = ["./requirements.txt", "./train.py"]
handler = "train:handler"
image = "abeja-inc/all-gpu:19.04"
environment = {"key": "value"}
description = "description"
response = api_client.create_training_job_definition_version(
    organization_id, job_definition_name, filepaths, handler,
    image=image, environment=environment, description=description)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • filepaths (list): file list to run training job

  • handler (str): path to handler (ex. train:handler )

  • image (Optional[str]): runtime environment

  • environment (Optional[dict]): user defined parameters set as environment variables

  • description (Optional[str]): description

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_version": 1,
    "user_parameters": {},
    "environment": {},
    "description": "description",
    "datasets": {
        "mnist": "1111111111111"
    },
    "modified_at": "2018-05-17T12:34:46.344076Z",
    "job_definition_id": "1443714239154",
    "handler": "train:handler",
    "created_at": "2018-05-17T12:34:46.296488Z",
    "image": "abeja-inc/all-gpu:19.04"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_training_job_definition_version_native_api(organization_id: str, job_definition_name: str, source_code: IO, parameters: dict) dict

create a training job definition version.

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/versions

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
source_code = open("./train.zip", "rb")
handler = "train:handler"
image = "abeja-inc/all-gpu:19.04"
environment = {"key": "value"}
description = "description"
response = api_client.create_training_job_definition_version_native_api(
    organization_id, job_definition_name, source_code,
    parameters={"handler": handler, "image": image, "environment": environment, "description": description})
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • source_code (IO): zip or tar.gz archived file-like object to run training job

  • parameters (dict): parameters excluding source code to run training job

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_version": 1,
    "user_parameters": {},
    "environment": {},
    "description": "description",
    "datasets": {
        "mnist": "1111111111111"
    },
    "modified_at": "2018-05-17T12:34:46.344076Z",
    "job_definition_id": "1443714239154",
    "handler": "train:handler",
    "created_at": "2018-05-17T12:34:46.296488Z",
    "image": "abeja-inc/all-gpu:19.04"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

create_training_model(organization_id: str, job_definition_name: str, model_data: IO, parameters: dict | None = None) dict

create a training model.

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/models

Request Syntax:
organization_id = "1102940376065"
job_definition_name = 'test_job_definition'
model_data = '....'
parameters = {
    "description": "description",
    "user_parameters": {}
}
response = api_client.create_training_model(
    organization_id, job_definition_name, model_data, parameters)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • model_data (IO): model data

  • parameters (dict): parameters for creating training model
    • training_job_id (str): The ID of a corresponding training job.

    • description (str): Description

    • user_parameters (dict): user defined parameters.

    • metrics (dict): user defined metrics.

Return type:

dict

Returns:

Response Syntax:

{
    "training_model_id": "1111111111111",
    "job_definition_id": "1111111111111",
    "training_job_id": "1111111111111",
    "user_parameters": {},
    "description": "this is description of the model",
    "archived": false,
    "exec_env": "cloud",
    "created_at": "2018-01-01T00:00:00.00000Z",
    "modified_at": "2018-01-01T00:00:00.00000Z"
}
Raises:
  • InvalidDataFormat

  • Unauthorized: Authentication failed

  • InternalServerError

delete_training_job_definition(organization_id: str, job_definition_name: str) dict

delete a training job definition.

API reference: DELETE /organizations/<organization_id>/training/definitions/<job_definition_name>

Request Syntax:
organization_id = "1102940376065"
job_definition_name = 'test'
response = api_client.delete_training_job_definition(organization_id, job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

Return type:

dict

Returns:

Response Syntax:

{
    "message": "test deleted"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

delete_training_job_definition_version(organization_id: str, job_definition_name: str, version_id: int) dict

delete a training job definition version

API reference: DELETE /organizations/<organization_id>/training/definitions/<job_definition_name>/versions/<version_id>

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
version_id = 1
response = api_client.delete_training_job_definition_version(organization_id, job_definition_name, version_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • version_id (int): training job version

Return type:

dict

Returns:

Response Syntax:

{
    "message": "deleted"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

download_training_model(organization_id: str, job_definition_name: str, model_id: str) dict

download a training model

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/models/<model_id>/download

Request Syntax:
response = api_client.download_training_model(
    organization_id='1111111111111', job_definition_name='1111111111111', model_id='1111111111111')
Params:
  • organization_id (str): organization_id

  • job_definition_name (str): training job definition name

  • model_id (str): model_id of the requested model

Return type:

dict

Returns:
Response Syntax:
{
     "download_uri": "https://..."
}
Response Structure:
  • download_uri (str) : presigned download link of the training model

Raises:
  • NotFound: model not found

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_job(organization_id: str, job_definition_name: str, training_job_id: str) dict

get a training job

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/jobs/<training_job_id>

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
training_job_id = "1443722127663"
response = api_client.get_training_job(organization_id, job_definition_name, training_job_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • training_job_id (str): TRAINING_JOB_ID

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_id": "1443714239154",
    "user_parameters": {},
    "start_time": null,
    "created_at": "2018-05-17T12:43:59.322367Z",
    "job_definition_version": 1,
    "completion_time": null,
    "status": "Pending",
    "modified_at": "2018-05-17T12:43:59.322673Z",
    "training_job_id": "1443722127663",
    "archived": false,
    "creator": {
        "email": "test@abeja.asia",
        "is_registered": true,
        "created_at": "2017-05-26T01:38:46Z",
        "id": "1128347408389",
        "display_name": null,
        "updated_at": "2018-01-04T03:02:12Z",
        "role": "admin"
    },
    "description": null,
    "statistics": null
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_job_definition(organization_id: str, job_definition_name: str, include_jobs: bool | None = None) dict

get a training job definition.

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>

Request Syntax:
organization_id = "1102940376065"
job_definition_name = 'test'
response = api_client.get_training_job_definition(organization_id, job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • include_jobs (bool): If True, also returns training jobs in response. By historical reason,

    the default value is True, but you should specify False because it degrades API performance if you have a massive amount of jobs in the target training job definition.

Return type:

dict

Returns:

Response Syntax:

{
    "modified_at": "2018-05-17T02:13:35.726812Z",
    "organization_id": "1200123565071",
    "created_at": "2018-05-17T02:13:35.726691Z",
    "job_definition_id": "1443334816413",
    "name": "test",
    "archived": false,
    "versions": [],
    "version_count": 0
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_job_definition_version(organization_id: str, job_definition_name: str, version_id: int) dict

get a training job definition version

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/versions/<version_id>

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
version_id = 1
response = api_client.get_training_job_definition_version(organization_id, job_definition_name, version_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • version_id (int): training job version

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_version": 1,
    "user_parameters": {},
    "datasets": {
        "mnist": "1111111111111"
    },
    "modified_at": "2018-05-17T12:34:46.344076Z",
    "job_definition_id": "1443714239154",
    "handler": "train:handler",
    "created_at": "2018-05-17T12:34:46.296488Z",
    "image": "abeja-inc/all-gpu:19.04",
    "archived": false
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_job_definition_versions(organization_id: str, job_definition_name: str, filter_archived: bool | None = None) dict

get training job definition versions.

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/versions

Request Syntax:
organization_id = "1102940376065"
job_definition_name = 'test_job_definition'
response = api_client.get_training_job_definition_versions(organization_id, job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • filter_archived (bool): [optional] If true, include archived jobs, otherwise exclude archived jobs. (default: false)

Return type:

dict

Returns:

Response Syntax:

{
    "entries": [
        {
            "job_definition_version": 1,
            "user_parameters": {},
            "datasets": {
                "mnist": "1111111111111"
            },
            "modified_at": "2018-05-17T12:34:46.344076Z",
            "job_definition_id": "1443714239154",
            "handler": "train:handler",
            "created_at": "2018-05-17T12:34:46.296488Z",
            "image": "abeja-inc/all-gpu:19.04",
            "archived": false
        }
    ]
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_job_definitions(organization_id: str, filter_archived: bool | None = None, offset: int | None = None, limit: int | None = None) dict

get training job definitions

API reference: GET /organizations/<organization_id>/training/definitions

Request Syntax:
organization_id = "1102940376065"
response = api_client.get_training_job_definitions(organization_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • filter_archived (bool): [optional] If true, include archived jobs, otherwise exclude archived jobs. (default: false)

  • offset (int): [optional] paging offset.

  • limit (int): [optional] paging limit.

Return type:

dict

Returns:

Response Syntax:

{
    "entries": [
        {
            "version_count": 1,
            "created_at": "2018-03-08T00:46:50.791787Z",
            "organization_id": "1200123565071",
            "versions": [
                {
                    "job_definition_version": 1,
                    "user_parameters": {},
                    "handler": "train:handler",
                    "image": "abeja-inc/all-gpu:19.04",
                    "modified_at": "2018-03-08T00:48:12.207883Z",
                    "datasets": {
                        "train": "1376063797251"
                    },
                    "created_at": "2018-03-08T00:48:12.132471Z",
                    "job_definition_id": "1381349997580"
                }
            ],
            "name": "test",
            "archived": false,
            "modified_at": "2018-03-08T00:46:50.791946Z",
            "job_definition_id": "1381349997580"
        }
    ]
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_jobs(organization_id: str, job_definition_name: str, limit: int | None = None, offset: int | None = None, filter_archived: bool | None = None) dict

get training jobs

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/jobs

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
response = api_client.get_training_jobs(organization_id, job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • limit (int): [optional] max number of jobs to be returned (default: 10)

  • offset (int): [optional] offset of jobs ( which starts from 0 )

  • filter_archived (bool): [optional] If true, include archived jobs, otherwise exclude archived jobs. (default: false)

Return type:

dict

Returns:

Response Syntax:

{
    "entries": [
        {
            "user_parameters": {},
            "start_time": null,
            "training_job_id": "1443722127663",
            "created_at": "2018-05-17T12:43:59.322367Z",
            "completion_time": null,
            "id": "1443722127663",
            "job_definition_version": 1,
            "description": null,
            "statistics": null,
            "job_definition_id": "1443714239154",
            "modified_at": "2018-05-17T12:43:59.322673Z",
            "status": "Pending",
            "archived": false,
            "creator": {
                "email": "test@abeja.asia",
                "created_at": "2017-05-26T01:38:46Z",
                "id": "1128347408389",
                "role": "admin",
                "display_name": null,
                "updated_at": "2018-01-04T03:02:12Z",
                "is_registered": true
            }
        }
    ],
    "limit": 10,
    "offset": 0,
    "total": 1
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_model(organization_id: str, job_definition_name: str, model_id: str) dict

get a training model

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/models/<model_id>

Request Syntax:
response = api_client.get_training_model(
    organization_id='1111111111111', job_definition_name='1111111111111', model_id='1111111111111')
Params:
  • organization_id (str): organization_id

  • job_definition_name (str): training job definition name

  • model_id (str): model_id of the requested model

Return type:

dict

Returns:
Response Syntax:
{
     "training_model_id": "1111111111111",
     "job_definition_id": "1111111111111",
     "training_job_id": "1111111111111",
     "user_parameters": {},
     "description": "this is description of the model",
     "archived": false,
     "exec_env": "cloud",
     "archived": false,
     "created_at": "2018-01-01T00:00:00.00000Z",
     "modified_at": "2018-01-01T00:00:00.00000Z"
}
Response Structure:
  • training_model_id (str) : training model id

  • job_definition_id (str) : job definition id

  • training_job_id (str) : training job id

  • user_parameters (dict): user defined parameters.

  • description (str) : model description.

  • archived (bool) : archived or not.

  • exec_env (enum) : Executed environment. One of [cloud, local, none].

Raises:
  • NotFound: model not found

  • Unauthorized: Authentication failed

  • InternalServerError

get_training_models(organization_id: str, job_definition_name: str, filter_archived: bool | None = None) dict

Get models entries

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/models

Request syntax:
response = api_client.list_models(organization_id='1102940376065')
Params:
  • organization_id (str): organization_id

  • job_definition_name (str): training job definition name

  • filter_archived (bool): [optional] If true, include archived jobs, otherwise exclude archived jobs. (default: false)

Return type:

dict

Returns:
Response syntax:
{
    "entries": [
        {
            "training_model_id": "1111111111111",
            "job_definition_id": "1111111111111",
            "training_job_id": "1111111111111",
            "user_parameters": {},
            "description": "this is description of the model",
            "archived": false,
            "exec_env": "cloud",
            "archived": false,
            "created_at": "2018-01-01T00:00:00.00000Z",
            "modified_at": "2018-01-01T00:00:00.00000Z"
        }
    ]
}
Response Structure:
  • entries (list)
    • (dict)
      • training_model_id (str) : training model id

      • job_definition_id (str) : job definition id

      • training_job_id (str) : training job id

      • user_parameters (dict): user defined parameters.

      • description (str) : model description.

      • archived (bool) : archived or not.

      • exec_env (enum) : Executed environment. One of [cloud, local, none].

Raises:
  • Unauthorized: Authentication failed

  • InternalServerError

get_training_result(organization_id: str, job_definition_name: str, training_job_id: str) dict

get a training job result

API reference: GET /organizations/<organization_id>/training/definitions/<job_definition_name>/jobs/<training_job_id>/result

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
training_job_id = "1443722127663"
response = api_client.get_training_result(organization_id, job_definition_name,
                                          training_job_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • training_job_id (str): TRAINING_JOB_ID

Return type:

dict

Returns:

Response Syntax:

{
    "artifacts": {
        "complete": {
            "uri": "dummy_url",
        }
    }
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

patch_training_job_definition_version(organization_id: str, job_definition_name: str, version_id: int, description: str) dict

Update a training job definition version

API reference: PATCH /organizations/<organization_id>/training/definitions/<job_definition_name>/versions/<version_id>

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
version_id = 1
response = api_client.patch_training_job_definition_version(organization_id, job_definition_name, version_id, description='new version')
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • version_id (int): training job version

  • description (str): description

Return type:

dict

Returns:

Response Syntax:

{
    "job_definition_version": 1,
    "user_parameters": {},
    "datasets": {
        "mnist": "1111111111111"
    },
    "modified_at": "2018-05-17T12:34:46.344076Z",
    "job_definition_id": "1443714239154",
    "handler": "train:handler",
    "created_at": "2018-05-17T12:34:46.296488Z",
    "image": "abeja-inc/all-gpu:19.04",
    "archived": false
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

patch_training_model(organization_id: str, job_definition_name: str, model_id: str, description: str) dict

patch a training model

API reference: PATCH /organizations/<organization_id>/training/definitions/<job_definition_name>/models/<model_id>

Request Syntax:
response = api_client.patch_training_model(
    organization_id='1111111111111', job_definition_name='1111111111111',
    model_id='1111111111111', description='new description')
Params:
  • organization_id (str): organization_id

  • job_definition_name (str): training job definition name

  • model_id (str): model_id of the requested model

  • description (str): description

Return type:

dict

Returns:
Response Syntax:
{
     "training_model_id": "1111111111111",
     "job_definition_id": "1111111111111",
     "training_job_id": "1111111111111",
     "user_parameters": {},
     "description": "this is description of the model",
     "archived": false,
     "exec_env": "cloud",
     "created_at": "2018-01-01T00:00:00.00000Z",
     "modified_at": "2018-01-01T00:00:00.00000Z"
}
Response Structure:
  • training_model_id (str) : training model id

  • job_definition_id (str) : job definition id

  • training_job_id (str) : training job id

  • user_parameters (dict): user defined parameters.

  • description (str) : model description.

  • archived (bool) : archived or not.

  • exec_env (enum) : Executed environment. One of [cloud, local, none].

Raises:
  • NotFound: model not found

  • Unauthorized: Authentication failed

  • InternalServerError

stop_training_job(organization_id: str, job_definition_name: str, training_job_id: str) dict

stop a training job

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/jobs/<training_job_id>/stop

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
training_job_id = "1443722127663"
response = api_client.stop_training_job(organization_id, job_definition_name, training_job_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • training_job_id (str): TRAINING_JOB_ID

Return type:

dict

Returns:

Response Syntax:

{
    "message": "test_job_definition:1443722127663 stopped"
}
Raises:
  • Unauthorized: Authentication failed

  • Forbidden:

  • InternalServerError

unarchive_training_job(organization_id: str, job_definition_name: str, training_job_id: str) dict

Archive a training job.

API reference: POST /organizations/<organization_id>/training/definitions/{job_definition_name}/jobs/{training_job_id}/unarchive

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test"
training_job_id = "1234567890123"
response = api_client.unarchive_training_job(organization_id,
                                             job_definition_name,
                                             training_job_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • training_job_id (str): TRAINING_JOB_ID

Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

unarchive_training_job_definition(organization_id: str, job_definition_name: str) dict

unarchive a training job definition

API reference: POST /organizations/<organization_id>/training/definitions/{name}/unarchive

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test"
response = api_client.unarchive_training_job_definition(organization_id,
                                                     job_definition_name)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

unarchive_training_job_definition_version(organization_id: str, job_definition_name: str, version_id: int) dict

unarchive a training job definition version

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/versions/<version_id>/unarchive

Request Syntax:
organization_id = "1102940376065"
job_definition_name = "test_job_definition"
version_id = 1
response = api_client.unarchive_training_job_definition_version(organization_id, job_definition_name, version_id)
Params:
  • organization_id (str): ORGANIZATION_ID

  • job_definition_name (str): training job definition name

  • version_id (int): training job version

Return type:

dict

Returns:

Response Syntax:

{
    "message": "unarchived"
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError

unarchive_training_model(organization_id: str, job_definition_name: str, model_id: str) dict

unarchive a training model

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/models/<model_id>/unarchive

Request Syntax:
response = api_client.unarchive_training_model(
    organization_id='1111111111111', job_definition_name='1111111111111', model_id='1111111111111')
Params:
  • organization_id (str): organization_id

  • job_definition_name (str): training job definition name

  • model_id (str): model_id of the requested model

Return type:

dict

Returns:
Response Syntax:
{
     "message": "{job_definition_name}:{model_id} unarchived"
}
Response Structure:
  • message (str) : message

Raises:
  • NotFound: model not found

  • Unauthorized: Authentication failed

  • InternalServerError

update_statistics(organization_id: str, job_definition_name: str, training_job_id: str, statistics: dict) dict

update a training job statistics

API reference: POST /organizations/<organization_id>/training/definitions/<job_definition_name>/jobs/<training_job_id>/statistics

Request Syntax:
from abeja.training.statistics import Statistics

statistics = Statistics(progress_percentage=0.5, epoch=1, num_epochs=5, key1='value1')
statistics.add_stage(name=Statistics.STAGE_TRAIN, accuracy=0.9, loss=0.05)
statistics.add_stage(name=Statistics.STAGE_VALIDATION, accuracy=0.8, loss=0.1, key2=2)

response = api_client.update_statistics(statistics.get_statistics())
Params:
  • statistics (str): statistics needs to be saved and updated

Return type:

dict

Returns:

Response Syntax:

{
  "statistics": {
    "num_epochs": 5,
    "epoch": 1,
    "progress_percentage": 0.5,
    "stages": {
      "train": {
        "accuracy": 0.9,
        "loss": 0.05
      },
      "validation": {
        "accuracy": 0.8,
        "loss": 0.1,
        "key2": 2
      }
    },
    "key1": "value1"
  }
}
Raises:
  • BadRequest

  • Unauthorized: Authentication failed

  • InternalServerError