API Client represents a low level interface for Run API. All API operation can be performed using this.
abeja.runs.
APIClient
(credential: typing.Union[dict, NoneType] = None, timeout: typing.Union[int, NoneType] = None, max_retry_count: typing.Union[int, NoneType] = None)¶A low-level client for Run API
from abeja.run import APIClient
api_client = APIClient()
create_run
(organization_id: str, deployment_id: str, version_id: str, input_data: typing.Union[typing.Dict[str, str], NoneType] = None, output_template: typing.Union[typing.Dict[str, str], NoneType] = None, distribution: typing.Union[int, NoneType] = None, retry_count: typing.Union[int, NoneType] = None, environment: typing.Union[typing.Dict[str, str], NoneType] = None, model_id: typing.Union[str, NoneType] = None) → dict¶submit a run
API reference: POST /organizations/<organization_id>/deployments/<deployment_id>/runs
organization_id = "1234567890123"
deployment_id = "1111111111111"
version_id = "ver-1111111111111111"
model_id = "3333333333333"
input_data = {
"$datalake:1": "2222222222222/20180101T112233-44444444-5555-6666-7777-888888888888"
}
distribution = 0
retry_count = 0
environment = {
"EXAMPLE_ENV": "example"
}
response = api_client.create_run(
organization_id, deployment_id, version_id, input_data,
model_id=model_id, distribution=distribution, retry_count=retry_count, environment=environment)
{"<operator>:<protocol_version>": "<operator_payload>"}
.
The value specified in INPUT is passed to the first argument of the handler of
the user-defined code.{"<operator>:<protocol_version>": "<operator_payload>"}
.Response Syntax:
{
"deployment_id": "1111111111111",
"models": {
"alias": "3333333333333"
},
"model_version": "0.0.3",
"model_version_id": "ver-1111111111111111",
"input_data": {
"$datalake:1": "2222222222222/20180101T112233-44444444-5555-6666-7777-888888888888"
},
"output_template": null,
"retry_count": 7,
"run_id": "run-3333333333333333",
"status": "SUBMITTED",
"user_env_vars": {
"DEBUG": "debug"
},
"distribution": 0,
"created_at": "2018-01-01T00:00:00.000000Z",
"modified_at": "2018-01-01T00:00:00.000000Z"
}
get_run
(organization_id: str, deployment_id: str, run_id: str) → dict¶get a run
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/runs/<run_id>
organization_id = "1234567890123"
deployment_id = "1111111111111"
run_id = "run-3333333333333333"
response = api_client.get_run(organization_id, deployment_id, run_id)
Response Syntax:
{
"deployment_id": "1111111111111",
"models": {
"alias": "3333333333333"
},
"model_version": "0.0.3",
"model_version_id": "ver-1111111111111111",
"input_data": {
"$datalake:1": "2222222222222/20180101T112233-44444444-5555-6666-7777-888888888888"
},
"output_template": null,
"retry_count": 7,
"run_id": "run-3333333333333333",
"status": "SUBMITTED",
"user_env_vars": {
"DEBUG": "debug"
},
"created_at": "2018-01-01T00:00:00.000000Z",
"modified_at": "2018-01-01T00:00:00.000000Z"
}
Response Structure:
SUBMITTED
, PENDING
,
RUNNABLE
, STARTING
, RUNNING
, SUCCEEDED
, FAILED
.get_run_logs
(organization_id: str, deployment_id: str, run_id: str, next_token: typing.Union[str, NoneType] = None, start_time: typing.Union[datetime.datetime, NoneType] = None, end_time: typing.Union[datetime.datetime, NoneType] = None) → dict¶get logs of the run
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/runs/<run_id>/logs
organization_id = "1234567890123"
deployment_id = "1111111111111"
run_id = "run-3333333333333333"
response = api_client.get_run_logs(organization_id, deployment_id, run_id)
Response Syntax:
{
"events": [
{
"message": "...",
"timestamp": "2018-01-01T00:00:00.000000Z"
}
],
"next_token": "..."
}
Response Structure:
get_run_recent_logs
(organization_id: str, deployment_id: str, run_id: str, next_forward_token: typing.Union[str, NoneType] = None, next_backward_token: typing.Union[str, NoneType] = None, start_time: typing.Union[datetime.datetime, NoneType] = None, end_time: typing.Union[datetime.datetime, NoneType] = None) → dict¶get recent logs of the run
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/runs/<run_id>/recentlogs
organization_id = "1234567890123"
deployment_id = "1111111111111"
run_id = "run-3333333333333333"
response = api_client.get_run_recent_logs(organization_id, deployment_id, run_id)
Response Syntax:
{
"events": [
{
"message": "...",
"timestamp": "2018-01-01T00:00:00.000000Z"
}
],
"next_backward_token": "...",
"next_forward_token": "..."
}
Response Structure:
get_runs
(organization_id: str, deployment_id: str, next_page_token: typing.Union[str, NoneType] = None, scan_forward: typing.Union[bool, NoneType] = None) → dict¶get runs
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/runs/
organization_id = "1234567890123"
deployment_id = "1111111111111"
response = api_client.get_runs(organization_id, deployment_id)
False
, the sort order is descending. To reverse the order, set this to True
Response Syntax:
{
"entries": [
{
"deployment_id": "1111111111111",
"models": {
"alias": "3333333333333"
},
"model_version": "0.0.3",
"model_version_id": "ver-1111111111111111",
"input_data": {
"$datalake:1": "2222222222222/20180101T112233-44444444-5555-6666-7777-888888888888"
},
"output_template": null,
"retry_count": 7,
"run_id": "run-3333333333333333",
"status": "SUBMITTED",
"user_env_vars": {
"DEBUG": "debug"
},
"created_at": "2018-01-01T00:00:00.000000Z",
"modified_at": "2018-01-01T00:00:00.000000Z"
}
],
"next_page_token": "..."
}