Python client
Python client
cortex
client
Initialize a client based on the specified environment. If no environment is specified, it will attempt to use the default 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.
new_client
Create a new environment to connect to an existing 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 commandcortex cluster info
.
Returns:
Cortex client that can be used to deploy and manage APIs on a cluster.
env_list
List all environments configured on this machine.
env_delete
Delete an environment configured on this machine.
Arguments:
name
- Name of the environment to delete.
cortex.client.Client
create_api
Deploy an API.
Arguments:
api_spec
- A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/0.34/ for schema.handler
- A Cortex handler class implementation. Not required for TaskAPI/TrafficSplitter kinds.task
- A callable class/function implementation. Not required for RealtimeAPI/BatchAPI/TrafficSplitter kinds.requirements
- A list of PyPI dependencies that will be installed before the handler class implementation is invoked.conda_packages
- A list of Conda dependencies that will be installed before the handler class implementation is invoked.project_dir
- Path to a python project.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
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 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 information about a submitted job.
Arguments:
api_name
- Name of the Batch/Task API.job_id
- Job ID.
Returns:
Information about the job, including the job status, worker status, and job progress.
refresh
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.
patch
Update the api specification for an API that has already been deployed.
Arguments:
api_spec
- The new api specification to applyforce
- Override an already in-progress API update.
delete_api
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 a running job.
Arguments:
api_name
- Name of the Batch/Task API.job_id
- ID of the Job to stop.
stream_api_logs
Stream the logs of an API.
Arguments:
api_name
- Name of the API.
stream_job_logs
Stream the logs of a Job.
Arguments:
api_name
- Name of the Batch API.job_id
- Job ID.
Last updated