API Client represents a low level interface for Model API. All API operation can be performed using this.
A low-level client for Deployment API
from abeja.deployments import APIClient
api_client = APIClient()
create a deployment
API reference: POST /organizations/<organization_id>/deployments
organization_id = "1111111111111"
deployment_name = "deployment_name"
description = "description"
default_environment = {
'SAMPLE_ENV': 'SAMPLE_VALUE'
}
response = api_client.create_deployment(organization_id, deployment_name, default_environment)
organization_id (str): organization identifier
name (str): deploymnet name
description (str): description
default_environment (dict): default environment variables on the running environment
dict
{
"deployment_id": "1111111111111",
"name": "deployment_name",
"description": "description",
"creator": {
"display_name": null,
"email": "platform-support@abeja.asia",
"id": "1111111111111",
"is_registered": true,
"role": "admin",
"created_at": "2017-05-29T07:48:55Z",
"updated_at": "2017-11-29T10:21:24Z"
},
"default_environment": {},
"runs": [],
"services": [],
"triggers": [],
"created_at": "2018-06-05T08:52:02.428441Z",
"modified_at": "2018-06-05T08:52:02.428587Z"
}
BadRequest: the resource already exists or parameters is insufficient or invalid.
Unauthorized: Authentication failed
InternalServerError
create a deployment from template
API reference: POST /organizations/<organization_id>/deployments/<deployment_id>/code_templates
deployment_id = '1111111111111',
template_id = 1,
version = '0.0.1'
handler = 'main:handler'
image = 'abeja-inc/all-cpu:18.10'
user_parameters = {
'SAMPLE_ENV': 'SAMPLE_VALUE'
}
response = api_client.create_deployment_from_template(
organization_id, deployment_id, template_id, version, handler, image, user_parameters
)
organization_id (str): organization id
deployment_id (str): deployment id
template_id (int): template id
version (str): version
handler (str) : handler path
user_parameters (dict): user defined parameters.
dict
{
"deployment_id": "1111111111111",
"version": "0.0.1",
"version_id": "ver-abc1111111111111",
"handler": "main:handler",
"image": "abeja-inc/all-cpu:18.10",
"user_parameters": {},
"created_at": "2018-06-14T07:15:43.462664Z",
"modified_at": "2018-06-14T07:15:43.462824Z"
}
deployment_id (str) : deployment id
version (str) : version
version_id (str) : version id
handler (str) : handler path
image (str) : runtime enviornment
user_parameters (dict): user defined parameters.
upload_url (str) : url to upload archived file. archived file should be uploaded after creating model version using this upload_url
BadRequest: specified deployment id does not exist or deployment version already exist, parameters is insufficient or invalid,
Unauthorized: Authentication failed
InternalServerError
create a deployment code version
API reference: POST /organizations/<organization_id>/deployments/<deployment_id>/versions
deployment_id = '1111111111111',
version = '0.0.1'
handler = 'main:handler'
image = 'abeja-inc/all-cpu:18.10'
user_parameters = {
'SAMPLE_ENV': 'SAMPLE_VALUE'
}
response = api_client.create_deployment_version(
organization_id, deployment_id, version, handler, image, user_parameters
)
# Then, you need to upload the source code for prediction to the ABEJA Platform
# create an archive containing all the source codes.
# for example, source tree looks like:
# /path/
# |-- to/
# |-- project/
# |-- root/
# |-- main.py
# |-- utils/
# |-- util.py
from shutil import make_archive
make_archive(
'./archive',
'gztar',
root_dir='/path/to/project/root',
base_dir='.'
)
# upload archive
import requests
upload_url = response['upload_url']
with open('archive.tar.gz', 'rb') as file:
requests.put(upload_url, data=file)
organization_id (str): organization id
deployment_id (str): deployment id
version (str): version
handler (str) : handler path
user_parameters (dict): user defined parameters.
dict
{
"deployment_id": "1111111111111",
"version": "0.0.1",
"version_id": "ver-abc1111111111111",
"handler": "main:handler",
"image": "abeja-inc/all-cpu:18.10",
"user_parameters": {},
"created_at": "2018-06-14T07:15:43.462664Z",
"modified_at": "2018-06-14T07:15:43.462824Z",
"upload_url": "https://abeja-model-api-src.s3.amazonaws.com/1462815098134/ver-/source.tgz?xxxxxx"
}
deployment_id (str) : deployment id
version (str) : version
version_id (str) : version id
handler (str) : handler path
image (str) : runtime enviornment
user_parameters (dict): user defined parameters.
upload_url (str) : url to upload archived file. archived file should be uploaded after creating model version using this upload_url
BadRequest: specified deployment id does not exist or deployment version already exist, parameters is insufficient or invalid,
Unauthorized: Authentication failed
InternalServerError
delete a deployment
API reference: DELETE /organizations/<organization_id>/deployments/<deployment_id>
response = api_client.delete_deployment(organization_id='1111111111111', deployment_id='1111111111111')
organization_id (str): ORGANIZATION_ID
deployment_id (str): deployment identifier
dict
{
"message": "1111111111111 deleted"
}
NotFound: model not found
Unauthorized: Authentication failed
InternalServerError
delete a version in a deployment
API reference: DELETE /organizations/<organization_id>/deployments/<deployment_id>/versions/<version_id>
api_client.delete_deployment_version(
organization_id='1111111111111',
deployment_id='1111111111111',
version_id='ver-abc3333333333333')
organization_id (str): ORGANIZATION_ID
deployment_id (str): deployment id
version_id (str): deployment version id
dict
{
"message": "ver-abc1111111111111 deleted"
}
message (str) :
NotFound: deployment version not found
Unauthorized: Authentication failed
InternalServerError
download a deployment code version
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/versions/<version_id>/download
response = api_client.download_deployment_version(
organization_id='1111111111111',
deployment_id='1111111111111',
version_id='ver-abc3333333333333')
organization_id (str): ORGANIZATION_ID
deployment_id (str): deployment id
version_id (str): deployment version id
dict
{
"download_uri": "https://..."
}
download_uri (str) : presigned download link of the deployment code version
NotFound: deployment not found
Unauthorized: Authentication failed
InternalServerError
get a deployment
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>
response = api_client.get_deployment(organization_id='1111111111111', deployment_id='1111111111111')
organization_id (str): organization_id
deployment_id (str): deployment_id of the requested model
dict
{
"deployment_id": "1111111111111",
"name": "deployment_name",
"creator": {
"display_name": null,
"email": "platform-support@abeja.asia",
"id": "1111111111111",
"is_registered": true,
"role": "admin",
"created_at": "2017-05-29T07:48:55Z",
"updated_at": "2017-11-29T10:21:24Z"
},
"default_environment": {},
"runs": [],
"services": [],
"triggers": [],
"created_at": "2018-06-05T08:52:02.428441Z",
"modified_at": "2018-06-05T08:52:02.428587Z",
}
NotFound: model not found
Unauthorized: Authentication failed
InternalServerError
get a version of a deployment
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/versions/<version_id>
response = api_client.get_deployment_version(organization_id='1111111111111',
deployment_id='2222222222222',
version_id='ver-abc3333333333333')
organization_id (str): ORGANIZATION_ID
deployment_id (str): deployment id
version_id (str): deployment version id
dict
{
"deployment_id": "1111111111111",
"version_id": "ver-abc1111111111111",
"version": "0.0.1",
"handler": "main:handler",
"image": "abeja-inc/all-cpu:18.10",
"user_parameters": {},
"created_at": "2018-04-26T01:12:05.771403Z",
"modified_at": "2018-04-26T01:12:05.771533Z"
}
deployment_id (str) : deployment id
version (str) : version
version_id (str) : version id
handler (str) : handler path
image (str) : runtime enviornment
user_parameters (dict): user defined parameters.
NotFound: deployment version not found
Unauthorized: Authentication failed
InternalServerError
get a deployment code versions
API reference: GET /organizations/<organization_id>/deployments/<deployment_id>/versions
response = api_client.get_deployment_versions(organization_id='1111111111111', deployment_id='1111111111111')
organization_id (str): organization_id
deployment_id (str): deployment_id of the requested model
dict
{
"entries": [
{
"deployment_id": "1111111111111",
"creator": {
"display_name": null,
"email": "paltform-support@abeja.asia",
"id": "1111111111111",
"is_registered": true,
"role": "admin",
"created_at": "2017-05-29T07:48:55Z",
"updated_at": "2017-11-29T10:21:24Z"
},
"version": "0.0.1",
"version_id": "ver-abc1111111111111",
"handler": "main:handler",
"image": "abeja-inc/all-cpu:18.10",
"user_parameters": {},
"created_at": "2018-06-05T08:52:02.428441Z",
"modified_at": "2018-06-05T08:52:02.428587Z"
}
]
}
NotFound: model not found
Unauthorized: Authentication failed
InternalServerError
Get deployments entries
API reference: GET /organizations/<organization_id>/deployments/
response = api_client.get_deployments(organization_id='1102940376065')
organization_id (str): organization_id
dict
{
"entries": [
{
"deployment_id": "1111111111111",
"name": "deployment_name",
"creator": {
"display_name": null,
"email": "paltform-support@abeja.asia",
"id": "1111111111111",
"is_registered": true,
"role": "admin",
"created_at": "2017-05-29T07:48:55Z",
"updated_at": "2017-11-29T10:21:24Z"
},
"default_environment": {},
"runs": [],
"services": [],
"triggers": [],
"created_at": "2018-06-05T08:52:02.428441Z",
"modified_at": "2018-06-05T08:52:02.428587Z"
}
]
}
Unauthorized: Authentication failed
InternalServerError
update a deployment
API reference: PATCH /organizations/<organization_id>/deployments/<deployment_id>
organization_id = "1111111111111"
deployment_name = "deployment_name"
default_environment = {
'SAMPLE_ENV': 'SAMPLE_VALUE'
}
response = api_client.create_deployment(organization_id, deployment_name, default_environment)
organization_id (str): organization identifier
deployment_id (str): deployment identifier
name (str): deploymnet name
default_environment (dict): default environment variables on the running environment
dict
{
"deployment_id": "1111111111111",
"name": "deployment_name",
"default_environment": {},
"runs": [],
"services": [],
"triggers": [],
"created_at": "2018-06-05T08:52:02.428441Z",
"modified_at": "2018-06-05T08:52:02.428587Z"
}
BadRequest: the resource already exists or parameters is insufficient or invalid.
Unauthorized: Authentication failed
InternalServerError