AI Core API¶
Lifecycle of AI scenarios.
Connect to AI Core API¶
- class procaine.aicore.Client(ai_api_url, auth, rg='default')¶
Initializes the connection to AI Core and obtains a Bearer token.
- Parameters:
ai_api_url – A URL to the AI API instance.
auth – Dictionary with creadentials to obtain a Bearer token. Should have
url
,clientid
andclientsecret
keys.rg – (optional) A name of a
resource group
to use with every call.
Usage:
>>> from procaine import aicore >>> auth = dict(url=AUTH_URL, clientid=CLIENT_ID, clientsecret=CLIENT_SECRET) >>> api = aicore.Client(AI_API_URL, auth) >>> api.healthz() {'message': 'OK', 'status': 'READY'}
Scenarios & Templates¶
- Client.list_scenarios()¶
Lists available scenarios.
- Client.list_templates(scenario=None)¶
Lists templates (executables).
- Parameters:
scenario – (optional) Scenario object or ID. Returns only templates belong to the scenario.
- Client.template(name, scenario=None)¶
Returns information about a template.
- Parameters:
name – Name of the template (executable ID).
scenario – (optional) Scenario object or ID.
Executions¶
- Client.list_executions()¶
Returns all executions.
- Client.create_execution(template, parameters=None, artifacts=None)¶
Starts a workflow execution.
- Parameters:
template – Template name or object returned from
Client.template()
orClient.list_templates()
.parameters – (optional) Dict of
param-name
->value
.artifacts – (optional) Dict of
binding-name
->S3 object URL or artifact or artifact ID
.
- Client.execution(execution)¶
Shows an execution status.
- Parameters:
execution – Execution object or ID.
- Client.execution_logs(execution)¶
Shows pods’ logs of an execution.
- Parameters:
execution – Execution object or ID.
- Client.stop_execution(execution)¶
Stops a running flow.
- Parameters:
execution – Execution object or ID.
Artifacts¶
- Client.list_artifacts()¶
Lists all registered artifacts.
- Client.create_artifact(url, kind, scenario, name, description='')¶
Registers an artifact.
- Parameters:
url – Object’s URL.
kind – One of the:
model
,dataset
,resultset
orother
.scenario – Scenario object or ID.
name – Name of an artifact.
description – (optional) Artifact’s description.
- Client.artifact(id)¶
Returns artifact by ID.
Deployments¶
- Client.list_deployments()¶
Returns all deployments.
- Client.create_deployment(template)¶
Starts an inference server.
- Parameters:
template – Template name or object returned from
Client.template()
orClient.list_templates()
.
- Client.deployment(deployment)¶
Shows a deployment status.
- Parameters:
deployment – Deployment object or ID.
- Client.deployment_logs(deployment)¶
Shows pods’ logs of a deployment.
- Parameters:
deployment – Deployment object or ID.
- Client.stop_deployment(deployment)¶
Stops a model server.
- Parameters:
deployment – Deployment object or ID.
- Client.delete_deployment(deployment)¶
Deletes a model server.
- Parameters:
deployment – Deployment object or ID.
Inference¶
- Client.predict(deployment, path='', data=None)¶
Sends HTTP request to a model server.
- Parameters:
deployment – Deployment object or ID.
path – (optional) Path attached to a deployment URL.
data – (optional) Data to be passed with a request. Sends a GET request when empty.
Configuration and secrets¶
Resource Groups¶
- Client.list_resource_groups()¶
Lists resource groups.
- Client.create_resource_group(name)¶
Creates a resource group.
Git repositories¶
- Client.list_git_repositories()¶
Lists registered git repositories.
- Client.create_git_repository(name, url, username=None, password=None)¶
Registers credentials to access a git repository.
- Parameters:
name – The name of a secret.
url – A URL to the git repository.
username – (optional) Username to access the registry.
password – (optional) Password to access the registry.
- Client.delete_git_repository(name)¶
Deletes a git repository secret.
Sync applications¶
- Client.list_applications()¶
Lists created sync applications.
- Client.application(app)¶
Returns application details.
- Parameters:
app – Application object, name or ID
- Client.create_application(repo_name, path='.', ref='HEAD')¶
Creates an application to sync git repository with AI Core.
- Parameters:
repo_name – Name of a registered git repository.
path – (optional) Directory in a repo to sync.
ref – (optional) Git reference, i.e. branch, tag, etc.
- Client.delete_application(name)¶
Deletes an application.
Docker registry secrets¶
- Client.list_docker_registry_secrets()¶
Lists registered docker registry secrets.
- Client.create_docker_registry_secret(name, registry, username, password)¶
Registers credentials to access a docker registry.
- Parameters:
name – The name of a secret.
registry – A docker registry address.
username – Username to access the registry.
password – Password to access the registry.
- Client.delete_docker_registry_secret(name)¶
Deletes a docker registry secret.
Object-store secrets¶
- Client.list_s3_secrets()¶
Lists registered S3 secrets.
- Client.create_s3_secret(name, access_key_id, secret_access_key, bucket=None, prefix=None, endpoint=None, region=None)¶
Registers credentials to access S3 bucket.
- Parameters:
name – The name of a secret.
access_key_id – Access key ID to access the bucket.
secret_access_key – Secret access key to access the bucket.
bucket – (optional) A bucket name.
prefix – (optional) A key name prefix.
endpoint – (optional) S3 service endpoint.
region – (optional) A region of the bucket.
- Client.delete_s3_secret(name)¶
Deletes an object-store secret.
Generic secrets¶
- Client.list_generic_secrets()¶
Lists registered generic secrets.
- Client.create_generic_secret(name, data)¶
Creates a generic secret.
- Parameters:
name – The name of a secret.
data – Dict of
key
->value
.
- Client.delete_generic_secret(name)¶
Deletes a generic secret.
Misc¶
- Client.meta()¶
Returns AI API service metadata.
- Client.kpi()¶
Provides usage statistics.
- Client.healthz()¶
Checks AI API service status.