Python client

Python client

cortex

client

client(env: str)

Initialize a client based on the specified environment.

Arguments:

  • env - Name of the environment to use.

Returns:

Cortex client that can be used to deploy and manage APIs in the specified environment.

local_client

local_client(aws_access_key_id: str, aws_secret_access_key: str, aws_region: str) -> Client

Initialize a client to deploy and manage APIs locally.

The specified AWS credentials will be used by the CLI to download models from S3 and authenticate to ECR, and will be set in your Predictor.

Arguments:

  • aws_access_key_id - AWS access key ID.

  • aws_secret_access_key - AWS secret access key.

  • aws_region - AWS region.

Returns:

Cortex client that can be used to deploy and manage APIs locally.

cluster_client

cluster_client(name: str, operator_endpoint: str, aws_access_key_id: str, aws_secret_access_key: str) -> Client

Create a new environment to connect to an existing Cortex Cluster, and initialize a client to deploy and manage APIs on that cluster.

Arguments:

  • name - Name of the environment to create.

  • operator_endpoint - The endpoint for the operator of your Cortex Cluster. You can get this endpoint by running the CLI command cortex cluster info.

  • aws_access_key_id - AWS access key ID.

  • aws_secret_access_key - AWS secret access key.

Returns:

Cortex client that can be used to deploy and manage APIs on a Cortex Cluster.

env_list

env_list() -> list

List all environments configured on this machine.

env_delete

env_delete(name: str)

Delete an environment configured on this machine.

Arguments:

  • name - Name of the environment to delete.

cortex.client.Client

deploy

| deploy(api_spec: dict, predictor=None, pip_dependencies=[], conda_dependencies=[], project_dir: Optional[str] = None, force: bool = False, wait: bool = False) -> list

Deploy an API.

Arguments:

Returns:

Deployment status, API specification, and endpoint for each API.

get_api

| get_api(api_name: str) -> dict

Get information about an API.

Arguments:

  • api_name - Name of the API.

Returns:

Information about the API, including the API specification, endpoint, status, and metrics (if applicable).

list_apis

| list_apis() -> list

List all APIs in the environment.

Returns:

List of APIs, including information such as the API specification, endpoint, status, and metrics (if applicable).

get_job

| get_job(api_name: str, job_id: str) -> dict

Get information about a submitted job.

Arguments:

  • api_name - Name of the Batch API.

  • job_id - Job ID.

Returns:

Information about the job, including the job status, worker status, and job progress.

refresh

| refresh(api_name: str, force: bool = False)

Restart all of the replicas for a Realtime API without downtime.

Arguments:

  • api_name - Name of the API to refresh.

  • force - Override an already in-progress API update.

delete_api

| delete_api(api_name: str, keep_cache: bool = False)

Delete an API.

Arguments:

  • api_name - Name of the API to delete.

  • keep_cache - Whether to retain the cached data for this API.

stop_job

| stop_job(api_name: str, job_id: str, keep_cache: bool = False)

Stop a running job.

Arguments:

  • api_name - Name of the Batch API.

  • job_id - ID of the Job to stop.

stream_api_logs

| stream_api_logs(api_name: str)

Stream the logs of an API.

Arguments:

  • api_name - Name of the API.

stream_job_logs

| stream_job_logs(api_name: str, job_id: str)

Stream the logs of a Job.

Arguments:

  • api_name - Name of the Batch API.

  • job_id - Job ID.