Search…
Python client

Python client

cortex

client

1
client(env: str)
Copied!
Initialize a client based on the specified environment.
To deploy and manage APIs on a new cluster:
  1. 1.
    Spin up a cluster using the CLI command cortex cluster up.
    An environment named "aws" will be created once the cluster is ready.
  2. 2.
    Initialize your client:
    1
    import cortex
    2
    c = cortex.client("aws")
    3
    c.deploy("./cortex.yaml")
    Copied!
To deploy and manage APIs on an existing cluster:
  1. 1.
    Use the command cortex cluster info to get the Operator Endpoint.
  2. 2.
    Configure a client to your cluster:
    1
    import cortex
    2
    c = cortex.cluster_client("aws", operator_endpoint, aws_access_key_id, aws_secret_access_key)
    3
    c.deploy("./cortex.yaml")
    Copied!
To deploy and manage APIs locally:
1
import cortex
2
c = cortex.client("local")
3
c.deploy("./cortex.yaml")
Copied!
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

1
local_client(aws_access_key_id: str, aws_secret_access_key: str, aws_region: str) -> Client
Copied!
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

1
cluster_client(name: str, operator_endpoint: str, aws_access_key_id: str, aws_secret_access_key: str) -> Client
Copied!
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

1
env_list() -> list
Copied!
List all environments configured on this machine.

env_delete

1
env_delete(name: str)
Copied!
Delete an environment configured on this machine.
Arguments:
  • name - Name of the environment to delete.

cortex.client.Client

deploy

1
| deploy(config_file: str, force: bool = False, wait: bool = False) -> list
Copied!
Deploy or update APIs specified in the config_file.
Arguments:
  • config_file - Local path to a yaml file defining Cortex APIs.
  • force - Override any in-progress api updates.
  • wait - Streams logs until the APIs are ready.
Returns:
Deployment status, API specification, and endpoint for each API.

get_api

1
| get_api(api_name: str) -> dict
Copied!
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

1
| list_apis() -> list
Copied!
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

1
| get_job(api_name: str, job_id: str) -> dict
Copied!
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

1
| refresh(api_name: str, force: bool = False)
Copied!
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

1
| delete_api(api_name: str, keep_cache: bool = False)
Copied!
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

1
| stop_job(api_name: str, job_id: str, keep_cache: bool = False)
Copied!
Stop a running job.
Arguments:
  • api_name - Name of the Batch API.
  • job_id - ID of the Job to stop.

stream_api_logs

1
| stream_api_logs(api_name: str)
Copied!
Stream the logs of an API.
Arguments:
  • api_name - Name of the API.

stream_job_logs

1
| stream_job_logs(api_name: str, job_id: str)
Copied!
Stream the logs of a Job.
Arguments:
  • api_name - Name of the Batch API.
  • job_id - Job ID.
Last modified 10mo ago