|
| 1 | +# Python client |
| 2 | + |
| 3 | +_WARNING: you are on the master branch, please refer to the docs on the branch that matches your `cortex version`_ |
| 4 | + |
| 5 | +* [cortex](#cortex) |
| 6 | + * [client](#client) |
| 7 | + * [local\_client](#local_client) |
| 8 | + * [cluster\_client](#cluster_client) |
| 9 | + * [env\_list](#env_list) |
| 10 | + * [env\_delete](#env_delete) |
| 11 | +* [cortex.client.Client](#cortex-client-client) |
| 12 | + * [deploy](#deploy) |
| 13 | + * [get\_api](#get_api) |
| 14 | + * [list\_apis](#list_apis) |
| 15 | + * [get\_job](#get_job) |
| 16 | + * [refresh](#refresh) |
| 17 | + * [delete\_api](#delete_api) |
| 18 | + * [stop\_job](#stop_job) |
| 19 | + * [stream\_api\_logs](#stream_api_logs) |
| 20 | + * [stream\_job\_logs](#stream_job_logs) |
| 21 | + |
| 22 | +# cortex |
| 23 | + |
| 24 | +## client |
| 25 | + |
| 26 | +```python |
| 27 | +client(env: str) |
| 28 | +``` |
| 29 | + |
| 30 | +Initialize a client based on the specified environment. |
| 31 | + |
| 32 | +To deploy and manage APIs on a new cluster: |
| 33 | + |
| 34 | +1. Spin up a cluster using the CLI command `cortex cluster up`. |
| 35 | + An environment named "aws" will be created once the cluster is ready. |
| 36 | +2. Initialize your client: |
| 37 | + |
| 38 | + ```python |
| 39 | + import cortex |
| 40 | + c = cortex.client("aws") |
| 41 | + c.deploy("./cortex.yaml") |
| 42 | + ``` |
| 43 | + |
| 44 | +To deploy and manage APIs on an existing cluster: |
| 45 | + |
| 46 | +1. Use the command `cortex cluster info` to get the Operator Endpoint. |
| 47 | +2. Configure a client to your cluster: |
| 48 | + |
| 49 | + ```python |
| 50 | + import cortex |
| 51 | + c = cortex.cluster_client("aws", operator_endpoint, aws_access_key_id, aws_secret_access_key) |
| 52 | + c.deploy("./cortex.yaml") |
| 53 | + ``` |
| 54 | + |
| 55 | +To deploy and manage APIs locally: |
| 56 | + |
| 57 | +```python |
| 58 | +import cortex |
| 59 | +c = cortex.client("local") |
| 60 | +c.deploy("./cortex.yaml") |
| 61 | +``` |
| 62 | + |
| 63 | +**Arguments**: |
| 64 | + |
| 65 | +- `env` - Name of the environment to use. |
| 66 | + |
| 67 | + |
| 68 | +**Returns**: |
| 69 | + |
| 70 | + Cortex client that can be used to deploy and manage APIs in the specified environment. |
| 71 | + |
| 72 | +## local\_client |
| 73 | + |
| 74 | +```python |
| 75 | +local_client(aws_access_key_id: str, aws_secret_access_key: str, aws_region: str) -> Client |
| 76 | +``` |
| 77 | + |
| 78 | +Initialize a client to deploy and manage APIs locally. |
| 79 | + |
| 80 | +The specified AWS credentials will be used by the CLI to download models |
| 81 | +from S3 and authenticate to ECR, and will be set in your Predictor. |
| 82 | + |
| 83 | +**Arguments**: |
| 84 | + |
| 85 | +- `aws_access_key_id` - AWS access key ID. |
| 86 | +- `aws_secret_access_key` - AWS secret access key. |
| 87 | +- `aws_region` - AWS region. |
| 88 | + |
| 89 | + |
| 90 | +**Returns**: |
| 91 | + |
| 92 | + Cortex client that can be used to deploy and manage APIs locally. |
| 93 | + |
| 94 | +## cluster\_client |
| 95 | + |
| 96 | +```python |
| 97 | +cluster_client(name: str, operator_endpoint: str, aws_access_key_id: str, aws_secret_access_key: str) -> Client |
| 98 | +``` |
| 99 | + |
| 100 | +Create a new environment to connect to an existing Cortex Cluster, and initialize a client to deploy and manage APIs on that cluster. |
| 101 | + |
| 102 | +**Arguments**: |
| 103 | + |
| 104 | +- `name` - Name of the environment to create. |
| 105 | +- `operator_endpoint` - The endpoint for the operator of your Cortex Cluster. You can get this endpoint by running the CLI command `cortex cluster info`. |
| 106 | +- `aws_access_key_id` - AWS access key ID. |
| 107 | +- `aws_secret_access_key` - AWS secret access key. |
| 108 | + |
| 109 | + |
| 110 | +**Returns**: |
| 111 | + |
| 112 | + Cortex client that can be used to deploy and manage APIs on a Cortex Cluster. |
| 113 | + |
| 114 | +## env\_list |
| 115 | + |
| 116 | +```python |
| 117 | +env_list() -> list |
| 118 | +``` |
| 119 | + |
| 120 | +List all environments configured on this machine. |
| 121 | + |
| 122 | +## env\_delete |
| 123 | + |
| 124 | +```python |
| 125 | +env_delete(name: str) |
| 126 | +``` |
| 127 | + |
| 128 | +Delete an environment configured on this machine. |
| 129 | + |
| 130 | +**Arguments**: |
| 131 | + |
| 132 | +- `name` - Name of the environment to delete. |
| 133 | + |
| 134 | +# cortex.client.Client |
| 135 | + |
| 136 | +## deploy |
| 137 | + |
| 138 | +```python |
| 139 | + | deploy(config_file: str, force: bool = False, wait: bool = False) -> list |
| 140 | +``` |
| 141 | + |
| 142 | +Deploy or update APIs specified in the config_file. |
| 143 | + |
| 144 | +**Arguments**: |
| 145 | + |
| 146 | +- `config_file` - Local path to a yaml file defining Cortex APIs. |
| 147 | +- `force` - Override any in-progress api updates. |
| 148 | +- `wait` - Streams logs until the APIs are ready. |
| 149 | + |
| 150 | + |
| 151 | +**Returns**: |
| 152 | + |
| 153 | + Deployment status, API specification, and endpoint for each API. |
| 154 | + |
| 155 | +## get\_api |
| 156 | + |
| 157 | +```python |
| 158 | + | get_api(api_name: str) -> dict |
| 159 | +``` |
| 160 | + |
| 161 | +Get information about an API. |
| 162 | + |
| 163 | +**Arguments**: |
| 164 | + |
| 165 | +- `api_name` - Name of the API. |
| 166 | + |
| 167 | + |
| 168 | +**Returns**: |
| 169 | + |
| 170 | + Information about the API, including the API specification, endpoint, status, and metrics (if applicable). |
| 171 | + |
| 172 | +## list\_apis |
| 173 | + |
| 174 | +```python |
| 175 | + | list_apis() -> list |
| 176 | +``` |
| 177 | + |
| 178 | +List all APIs in the environment. |
| 179 | + |
| 180 | +**Returns**: |
| 181 | + |
| 182 | + List of APIs, including information such as the API specification, endpoint, status, and metrics (if applicable). |
| 183 | + |
| 184 | +## get\_job |
| 185 | + |
| 186 | +```python |
| 187 | + | get_job(api_name: str, job_id: str) -> dict |
| 188 | +``` |
| 189 | + |
| 190 | +Get information about a submitted job. |
| 191 | + |
| 192 | +**Arguments**: |
| 193 | + |
| 194 | +- `api_name` - Name of the Batch API. |
| 195 | +- `job_id` - Job ID. |
| 196 | + |
| 197 | + |
| 198 | +**Returns**: |
| 199 | + |
| 200 | + Information about the job, including the job status, worker status, and job progress. |
| 201 | + |
| 202 | +## refresh |
| 203 | + |
| 204 | +```python |
| 205 | + | refresh(api_name: str, force: bool = False) |
| 206 | +``` |
| 207 | + |
| 208 | +Restart all of the replicas for a Realtime API without downtime. |
| 209 | + |
| 210 | +**Arguments**: |
| 211 | + |
| 212 | +- `api_name` - Name of the API to refresh. |
| 213 | +- `force` - Override an already in-progress API update. |
| 214 | + |
| 215 | +## delete\_api |
| 216 | + |
| 217 | +```python |
| 218 | + | delete_api(api_name: str, keep_cache: bool = False) |
| 219 | +``` |
| 220 | + |
| 221 | +Delete an API. |
| 222 | + |
| 223 | +**Arguments**: |
| 224 | + |
| 225 | +- `api_name` - Name of the API to delete. |
| 226 | +- `keep_cache` - Whether to retain the cached data for this API. |
| 227 | + |
| 228 | +## stop\_job |
| 229 | + |
| 230 | +```python |
| 231 | + | stop_job(api_name: str, job_id: str, keep_cache: bool = False) |
| 232 | +``` |
| 233 | + |
| 234 | +Stop a running job. |
| 235 | + |
| 236 | +**Arguments**: |
| 237 | + |
| 238 | +- `api_name` - Name of the Batch API. |
| 239 | +- `job_id` - ID of the Job to stop. |
| 240 | + |
| 241 | +## stream\_api\_logs |
| 242 | + |
| 243 | +```python |
| 244 | + | stream_api_logs(api_name: str) |
| 245 | +``` |
| 246 | + |
| 247 | +Stream the logs of an API. |
| 248 | + |
| 249 | +**Arguments**: |
| 250 | + |
| 251 | +- `api_name` - Name of the API. |
| 252 | + |
| 253 | +## stream\_job\_logs |
| 254 | + |
| 255 | +```python |
| 256 | + | stream_job_logs(api_name: str, job_id: str) |
| 257 | +``` |
| 258 | + |
| 259 | +Stream the logs of a Job. |
| 260 | + |
| 261 | +**Arguments**: |
| 262 | + |
| 263 | +- `api_name` - Name of the Batch API. |
| 264 | +- `job_id` - Job ID. |
0 commit comments