LogoLogo
WebsiteSlack
0.35
0.35
  • Get started
  • Clusters
    • Management
      • Auth
      • Create
      • Update
      • Delete
      • Environments
    • Instances
      • Multi-instance
      • Spot instances
    • Observability
      • Logging
      • Metrics
      • Alerting
    • Networking
      • Load balancers
      • VPC peering
      • HTTPS
      • Custom domain
    • Advanced
      • Setting up kubectl
      • Private Docker registry
      • Self hosted images
  • Workloads
    • Realtime APIs
      • Example
      • Handler
      • Configuration
      • Parallelism
      • Autoscaling
      • Models
      • Multi-model
        • Example
        • Configuration
        • Caching
      • Server-side batching
      • Metrics
      • Statuses
      • Traffic Splitter
        • Example
        • Configuration
      • Troubleshooting
    • Async APIs
      • Example
      • Handler
      • Configuration
      • TensorFlow Models
      • Metrics
      • Statuses
      • Webhooks
    • Batch APIs
      • Example
      • Handler
      • Configuration
      • Jobs
      • TensorFlow Models
      • Metrics
      • Statuses
    • Task APIs
      • Example
      • Definition
      • Configuration
      • Jobs
      • Metrics
      • Statuses
    • Dependencies
      • Example
      • Python packages
      • System packages
      • Custom images
    • Debugging
  • Clients
    • Install
    • Uninstall
    • CLI commands
    • Python client
Powered by GitBook
On this page
  • Python client
  • cortex
  • client
  • new_client
  • env_list
  • env_delete
  • cortex.client.Client
  • deploy
  • deploy_realtime_api
  • deploy_async_api
  • deploy_batch_api
  • deploy_task_api
  • deploy_traffic_splitter
  • get_api
  • list_apis
  • get_job
  • refresh
  • patch
  • delete
  • stop_job
  • stream_api_logs
  • stream_job_logs
  1. Clients

Python client

PreviousCLI commands

Last updated 3 years ago

Python client

cortex

client

client(env: Optional[str] = None) -> 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

new_client(name: str, operator_endpoint: str) -> 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 command cortex cluster info.

Returns:

Cortex client that can be used to deploy and manage APIs on a 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[str, Any], project_dir: str, force: bool = True, wait: bool = False)

Deploy API(s) from a project directory.

Arguments:

  • 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.

deploy_realtime_api

 | deploy_realtime_api(api_spec: Dict[str, Any], handler, requirements: Optional[List] = None, conda_packages: Optional[List] = None, force: bool = True, wait: bool = False) -> Dict

Deploy a Realtime API.

Arguments:

  • handler - A Cortex Handler class implementation.

  • 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.

  • 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.

deploy_async_api

 | deploy_async_api(api_spec: Dict[str, Any], handler, requirements: Optional[List] = None, conda_packages: Optional[List] = None, force: bool = True) -> Dict

Deploy an Async API.

Arguments:

  • handler - A Cortex Handler class implementation.

  • 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.

  • force - Override any in-progress api updates.

Returns:

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

deploy_batch_api

 | deploy_batch_api(api_spec: Dict[str, Any], handler, requirements: Optional[List] = None, conda_packages: Optional[List] = None) -> Dict

Deploy a Batch API.

Arguments:

  • handler - A Cortex Handler class implementation.

  • 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.

Returns:

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

deploy_task_api

 | deploy_task_api(api_spec: Dict[str, Any], task, requirements: Optional[List] = None, conda_packages: Optional[List] = None) -> Dict

Deploy a Task API.

Arguments:

  • task - A callable class implementation.

  • 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.

Returns:

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

deploy_traffic_splitter

 | deploy_traffic_splitter(api_spec: Dict[str, Any]) -> Dict

Deploy a Task 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/Task 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.

patch

 | patch(api_spec: Dict, force: bool = False) -> Dict

Update the api specification for an API that has already been deployed.

Arguments:

  • api_spec - The new api specification to apply

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

delete

 | delete(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/Task 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.

api_spec - A dictionary defining a single Cortex API. See for schema.

api_spec - A dictionary defining a single Cortex API. See for schema.

api_spec - A dictionary defining a single Cortex API. See for schema.

api_spec - A dictionary defining a single Cortex API. See for schema.

api_spec - A dictionary defining a single Cortex API. See for schema.

api_spec - A dictionary defining a single Cortex API. See for schema.

https://docs.cortex.dev/v/0.35/
https://docs.cortex.dev/v/0.35/workloads/realtime-apis/configuration
https://docs.cortex.dev/v/0.35/workloads/async-apis/configuration
https://docs.cortex.dev/v/0.35/workloads/batch-apis/configuration
https://docs.cortex.dev/v/0.35/workloads/task-apis/configuration
https://docs.cortex.dev/v/0.35/workloads/realtime-apis/traffic-splitter/configuration
cortex
client
new_client
env_list
env_delete
cortex.client.Client
deploy
deploy_realtime_api
deploy_async_api
deploy_batch_api
deploy_task_api
deploy_traffic_splitter
get_api
list_apis
get_job
refresh
patch
delete
stop_job
stream_api_logs
stream_job_logs