Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dev/generate_python_client_md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sed -i "/\* \[Client](#cortex\.client\.Client)/d" $docs_path
sed -i "s/\* \[cortex\.client](#cortex\.client)/\* [cortex\.client\.Client](#cortex-client-client)/g" $docs_path
sed -i "s/# cortex\.client/# cortex\.client\.Client/g" $docs_path
# delete unnecessary section body
sed -i "/# cortex.client.Client/,/## create\\\_api/{//!d}" $docs_path
sed -i "/# cortex.client.Client/,/## deploy/{//!d}" $docs_path
sed -i "s/# cortex.client.Client/# cortex.client.Client\n/g" $docs_path

# fix table of contents links
Expand All @@ -64,7 +64,12 @@ sed -i 's/[[:space:]]*$//' $docs_path
truncate -s -1 $docs_path

# Cortex version comment
sed -i "s/^## create\\\_api/## create\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy$/## deploy\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_realtime\\\_api$/## deploy\\\_realtime\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_async\\\_api$/## deploy\\\_async\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_batch\\\_api$/## deploy\\\_batch\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_task\\\_api$/## deploy\\\_task\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
sed -i "s/^## deploy\\\_traffic\\\_splitter$/## deploy\\\_traffic\\\_splitter\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path

pip3 uninstall -y cortex
rm -rf $ROOT/python/client/cortex.egg-info
141 changes: 126 additions & 15 deletions docs/clients/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
* [env\_list](#env_list)
* [env\_delete](#env_delete)
* [cortex.client.Client](#cortex-client-client)
* [create\_api](#create_api)
* [deploy](#deploy)
* [deploy\_realtime\_api](#deploy_realtime_api)
* [deploy\_async\_api](#deploy_async_api)
* [deploy\_batch\_api](#deploy_batch_api)
* [deploy\_task\_api](#deploy_task_api)
* [deploy\_traffic\_splitter](#deploy_traffic_splitter)
* [get\_api](#get_api)
* [list\_apis](#list_apis)
* [get\_job](#get_job)
* [refresh](#refresh)
* [patch](#patch)
* [delete\_api](#delete_api)
* [delete](#delete)
* [stop\_job](#stop_job)
* [stream\_api\_logs](#stream_api_logs)
* [stream\_job\_logs](#stream_job_logs)
Expand Down Expand Up @@ -57,7 +62,7 @@ Create a new environment to connect to an existing cluster, and initialize a cli
## env\_list

```python
env_list() -> list
env_list() -> List
```

List all environments configured on this machine.
Expand All @@ -76,36 +81,142 @@ Delete an environment configured on this machine.

# cortex.client.Client

## create\_api
## deploy

<!-- CORTEX_VERSION_MINOR -->

```python
| create_api(api_spec: dict, handler=None, task=None, requirements=[], conda_packages=[], project_dir: Optional[str] = None, force: bool = True, wait: bool = False) -> list
| deploy(api_spec: Dict[str, Any], project_dir: str, force: bool = True, wait: bool = False)
```

Deploy an API.
Deploy API(s) from a project directory.

**Arguments**:

- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/ 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.
- `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

<!-- CORTEX_VERSION_MINOR -->

```python
| 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**:

- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/realtime-apis/configuration for schema.
- `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.
- `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\_async\_api

<!-- CORTEX_VERSION_MINOR -->

```python
| 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**:

- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/async-apis/configuration for schema.
- `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

<!-- CORTEX_VERSION_MINOR -->

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

Deploy a Batch API.

**Arguments**:

- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/batch-apis/configuration for schema.
- `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

<!-- CORTEX_VERSION_MINOR -->

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

Deploy a Task API.

**Arguments**:

- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/task-apis/configuration for schema.
- `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

<!-- CORTEX_VERSION_MINOR -->

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

Deploy a Task API.

**Arguments**:

- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/realtime-apis/traffic-splitter/configuration for schema.


**Returns**:

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

## get\_api

```python
| get_api(api_name: str) -> dict
| get_api(api_name: str) -> Dict
```

Get information about an API.
Expand All @@ -122,7 +233,7 @@ Get information about an API.
## list\_apis

```python
| list_apis() -> list
| list_apis() -> List
```

List all APIs in the environment.
Expand All @@ -134,7 +245,7 @@ List all APIs in the environment.
## get\_job

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

Get information about a submitted job.
Expand Down Expand Up @@ -165,7 +276,7 @@ Restart all of the replicas for a Realtime API without downtime.
## patch

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

Update the api specification for an API that has already been deployed.
Expand All @@ -175,10 +286,10 @@ Update the api specification for an API that has already been deployed.
- `api_spec` - The new api specification to apply
- `force` - Override an already in-progress API update.

## delete\_api
## delete

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

Delete an API.
Expand Down
2 changes: 1 addition & 1 deletion docs/workloads/batch/handler.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ class Handler:
# get client pointing to the default environment
client = cortex.client()
# deploy API in the existing cluster using the artifacts in the previous step
client.create_api(...)
client.deploy(...)
```
2 changes: 1 addition & 1 deletion docs/workloads/dependencies/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ api_spec = {
}

cx = cortex.client("aws")
cx.create_api(api_spec, project_dir=".")
cx.deploy(api_spec, project_dir=".")
```

## Deploy using the CLI
Expand Down
2 changes: 1 addition & 1 deletion docs/workloads/realtime/multi-model/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ requirements = ["tensorflow", "transformers", "wget", "fasttext"]
api_spec = {"name": "multi-model", "kind": "RealtimeAPI"}

cx = cortex.client("aws")
cx.create_api(api_spec, handler=Handler, requirements=requirements)
cx.deploy_realtime_api(api_spec, handler=Handler, requirements=requirements)
```

## Deploy
Expand Down
6 changes: 3 additions & 3 deletions docs/workloads/realtime/traffic-splitter/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ api_spec_gpu = {
}

cx = cortex.client("aws")
cx.create_api(api_spec_cpu, handler=Handler, requirements=requirements)
cx.create_api(api_spec_gpu, handler=Handler, requirements=requirements)
cx.deploy_realtime_api(api_spec_cpu, handler=Handler, requirements=requirements)
cx.deploy_realtime_api(api_spec_gpu, handler=Handler, requirements=requirements)
```

## Deploy a traffic splitter
Expand All @@ -50,7 +50,7 @@ traffic_splitter_spec = {
],
}

cx.create_api(traffic_splitter_spec)
cx.deploy_traffic_splitter(traffic_splitter_spec)
```

## Update the weights of the traffic splitter
Expand Down
2 changes: 1 addition & 1 deletion docs/workloads/task/definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ class Task:
# get client pointing to the default environment
client = cortex.client()
# deploy API in the existing cluster as part of your pipeline workflow
client.create_api(...)
client.deploy(...)
```
4 changes: 2 additions & 2 deletions python/client/cortex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import json
from typing import Optional
from typing import Optional, List

from cortex.binary import run_cli
from cortex.client import Client
Expand Down Expand Up @@ -79,7 +79,7 @@ def new_client(


@sentry_wrapper
def env_list() -> list:
def env_list() -> List:
"""
List all environments configured on this machine.
"""
Expand Down
Loading