Skip to content

Commit 9c2c3a7

Browse files
author
Miguel Varela Ramos
authored
Rename python client functions (#2145)
1 parent 43b8efe commit 9c2c3a7

File tree

15 files changed

+387
-62
lines changed

15 files changed

+387
-62
lines changed

dev/generate_python_client_md.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ sed -i "/\* \[Client](#cortex\.client\.Client)/d" $docs_path
4848
sed -i "s/\* \[cortex\.client](#cortex\.client)/\* [cortex\.client\.Client](#cortex-client-client)/g" $docs_path
4949
sed -i "s/# cortex\.client/# cortex\.client\.Client/g" $docs_path
5050
# delete unnecessary section body
51-
sed -i "/# cortex.client.Client/,/## create\\\_api/{//!d}" $docs_path
51+
sed -i "/# cortex.client.Client/,/## deploy/{//!d}" $docs_path
5252
sed -i "s/# cortex.client.Client/# cortex.client.Client\n/g" $docs_path
5353

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

6666
# Cortex version comment
67-
sed -i "s/^## create\\\_api/## create\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
67+
sed -i "s/^## deploy$/## deploy\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
68+
sed -i "s/^## deploy\\\_realtime\\\_api$/## deploy\\\_realtime\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
69+
sed -i "s/^## deploy\\\_async\\\_api$/## deploy\\\_async\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
70+
sed -i "s/^## deploy\\\_batch\\\_api$/## deploy\\\_batch\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
71+
sed -i "s/^## deploy\\\_task\\\_api$/## deploy\\\_task\\\_api\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
72+
sed -i "s/^## deploy\\\_traffic\\\_splitter$/## deploy\\\_traffic\\\_splitter\n\n<!-- CORTEX_VERSION_MINOR -->/g" $docs_path
6873

6974
pip3 uninstall -y cortex
7075
rm -rf $ROOT/python/client/cortex.egg-info

docs/clients/python.md

Lines changed: 126 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
* [env\_list](#env_list)
77
* [env\_delete](#env_delete)
88
* [cortex.client.Client](#cortex-client-client)
9-
* [create\_api](#create_api)
9+
* [deploy](#deploy)
10+
* [deploy\_realtime\_api](#deploy_realtime_api)
11+
* [deploy\_async\_api](#deploy_async_api)
12+
* [deploy\_batch\_api](#deploy_batch_api)
13+
* [deploy\_task\_api](#deploy_task_api)
14+
* [deploy\_traffic\_splitter](#deploy_traffic_splitter)
1015
* [get\_api](#get_api)
1116
* [list\_apis](#list_apis)
1217
* [get\_job](#get_job)
1318
* [refresh](#refresh)
1419
* [patch](#patch)
15-
* [delete\_api](#delete_api)
20+
* [delete](#delete)
1621
* [stop\_job](#stop_job)
1722
* [stream\_api\_logs](#stream_api_logs)
1823
* [stream\_job\_logs](#stream_job_logs)
@@ -57,7 +62,7 @@ Create a new environment to connect to an existing cluster, and initialize a cli
5762
## env\_list
5863

5964
```python
60-
env_list() -> list
65+
env_list() -> List
6166
```
6267

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

7782
# cortex.client.Client
7883

79-
## create\_api
84+
## deploy
8085

8186
<!-- CORTEX_VERSION_MINOR -->
8287

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

87-
Deploy an API.
92+
Deploy API(s) from a project directory.
8893

8994
**Arguments**:
9095

9196
- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/ for schema.
92-
- `handler` - A Cortex handler class implementation. Not required for TaskAPI/TrafficSplitter kinds.
93-
- `task` - A callable class/function implementation. Not required for RealtimeAPI/BatchAPI/TrafficSplitter kinds.
97+
- `project_dir` - Path to a python project.
98+
- `force` - Override any in-progress api updates.
99+
- `wait` - Streams logs until the APIs are ready.
100+
101+
102+
**Returns**:
103+
104+
Deployment status, API specification, and endpoint for each API.
105+
106+
## deploy\_realtime\_api
107+
108+
<!-- CORTEX_VERSION_MINOR -->
109+
110+
```python
111+
| 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
112+
```
113+
114+
Deploy a Realtime API.
115+
116+
**Arguments**:
117+
118+
- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/realtime-apis/configuration for schema.
119+
- `handler` - A Cortex Handler class implementation.
94120
- `requirements` - A list of PyPI dependencies that will be installed before the handler class implementation is invoked.
95121
- `conda_packages` - A list of Conda dependencies that will be installed before the handler class implementation is invoked.
96-
- `project_dir` - Path to a python project.
97122
- `force` - Override any in-progress api updates.
98123
- `wait` - Streams logs until the APIs are ready.
99124

100125

126+
**Returns**:
127+
128+
Deployment status, API specification, and endpoint for each API.
129+
130+
## deploy\_async\_api
131+
132+
<!-- CORTEX_VERSION_MINOR -->
133+
134+
```python
135+
| deploy_async_api(api_spec: Dict[str, Any], handler, requirements: Optional[List] = None, conda_packages: Optional[List] = None, force: bool = True) -> Dict
136+
```
137+
138+
Deploy an Async API.
139+
140+
**Arguments**:
141+
142+
- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/async-apis/configuration for schema.
143+
- `handler` - A Cortex Handler class implementation.
144+
- `requirements` - A list of PyPI dependencies that will be installed before the handler class implementation is invoked.
145+
- `conda_packages` - A list of Conda dependencies that will be installed before the handler class implementation is invoked.
146+
- `force` - Override any in-progress api updates.
147+
148+
149+
**Returns**:
150+
151+
Deployment status, API specification, and endpoint for each API.
152+
153+
## deploy\_batch\_api
154+
155+
<!-- CORTEX_VERSION_MINOR -->
156+
157+
```python
158+
| deploy_batch_api(api_spec: Dict[str, Any], handler, requirements: Optional[List] = None, conda_packages: Optional[List] = None) -> Dict
159+
```
160+
161+
Deploy a Batch API.
162+
163+
**Arguments**:
164+
165+
- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/batch-apis/configuration for schema.
166+
- `handler` - A Cortex Handler class implementation.
167+
- `requirements` - A list of PyPI dependencies that will be installed before the handler class implementation is invoked.
168+
- `conda_packages` - A list of Conda dependencies that will be installed before the handler class implementation is invoked.
169+
170+
171+
**Returns**:
172+
173+
Deployment status, API specification, and endpoint for each API.
174+
175+
## deploy\_task\_api
176+
177+
<!-- CORTEX_VERSION_MINOR -->
178+
179+
```python
180+
| deploy_task_api(api_spec: Dict[str, Any], task, requirements: Optional[List] = None, conda_packages: Optional[List] = None) -> Dict
181+
```
182+
183+
Deploy a Task API.
184+
185+
**Arguments**:
186+
187+
- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/task-apis/configuration for schema.
188+
- `task` - A callable class implementation.
189+
- `requirements` - A list of PyPI dependencies that will be installed before the handler class implementation is invoked.
190+
- `conda_packages` - A list of Conda dependencies that will be installed before the handler class implementation is invoked.
191+
192+
193+
**Returns**:
194+
195+
Deployment status, API specification, and endpoint for each API.
196+
197+
## deploy\_traffic\_splitter
198+
199+
<!-- CORTEX_VERSION_MINOR -->
200+
201+
```python
202+
| deploy_traffic_splitter(api_spec: Dict[str, Any]) -> Dict
203+
```
204+
205+
Deploy a Task API.
206+
207+
**Arguments**:
208+
209+
- `api_spec` - A dictionary defining a single Cortex API. See https://docs.cortex.dev/v/master/workloads/realtime-apis/traffic-splitter/configuration for schema.
210+
211+
101212
**Returns**:
102213

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

105216
## get\_api
106217

107218
```python
108-
| get_api(api_name: str) -> dict
219+
| get_api(api_name: str) -> Dict
109220
```
110221

111222
Get information about an API.
@@ -122,7 +233,7 @@ Get information about an API.
122233
## list\_apis
123234

124235
```python
125-
| list_apis() -> list
236+
| list_apis() -> List
126237
```
127238

128239
List all APIs in the environment.
@@ -134,7 +245,7 @@ List all APIs in the environment.
134245
## get\_job
135246

136247
```python
137-
| get_job(api_name: str, job_id: str) -> dict
248+
| get_job(api_name: str, job_id: str) -> Dict
138249
```
139250

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

167278
```python
168-
| patch(api_spec: dict, force: bool = False) -> dict
279+
| patch(api_spec: Dict, force: bool = False) -> Dict
169280
```
170281

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

178-
## delete\_api
289+
## delete
179290

180291
```python
181-
| delete_api(api_name: str, keep_cache: bool = False)
292+
| delete(api_name: str, keep_cache: bool = False)
182293
```
183294

184295
Delete an API.

docs/workloads/batch/handler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,5 @@ class Handler:
121121
# get client pointing to the default environment
122122
client = cortex.client()
123123
# deploy API in the existing cluster using the artifacts in the previous step
124-
client.create_api(...)
124+
client.deploy(...)
125125
```

docs/workloads/dependencies/example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ api_spec = {
4141
}
4242

4343
cx = cortex.client("aws")
44-
cx.create_api(api_spec, project_dir=".")
44+
cx.deploy(api_spec, project_dir=".")
4545
```
4646

4747
## Deploy using the CLI

docs/workloads/realtime/multi-model/example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ requirements = ["tensorflow", "transformers", "wget", "fasttext"]
3333
api_spec = {"name": "multi-model", "kind": "RealtimeAPI"}
3434

3535
cx = cortex.client("aws")
36-
cx.create_api(api_spec, handler=Handler, requirements=requirements)
36+
cx.deploy_realtime_api(api_spec, handler=Handler, requirements=requirements)
3737
```
3838

3939
## Deploy

docs/workloads/realtime/traffic-splitter/example.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ api_spec_gpu = {
3434
}
3535

3636
cx = cortex.client("aws")
37-
cx.create_api(api_spec_cpu, handler=Handler, requirements=requirements)
38-
cx.create_api(api_spec_gpu, handler=Handler, requirements=requirements)
37+
cx.deploy_realtime_api(api_spec_cpu, handler=Handler, requirements=requirements)
38+
cx.deploy_realtime_api(api_spec_gpu, handler=Handler, requirements=requirements)
3939
```
4040

4141
## Deploy a traffic splitter
@@ -50,7 +50,7 @@ traffic_splitter_spec = {
5050
],
5151
}
5252

53-
cx.create_api(traffic_splitter_spec)
53+
cx.deploy_traffic_splitter(traffic_splitter_spec)
5454
```
5555

5656
## Update the weights of the traffic splitter

docs/workloads/task/definitions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ class Task:
8787
# get client pointing to the default environment
8888
client = cortex.client()
8989
# deploy API in the existing cluster as part of your pipeline workflow
90-
client.create_api(...)
90+
client.deploy(...)
9191
```

python/client/cortex/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import json
16-
from typing import Optional
16+
from typing import Optional, List
1717

1818
from cortex.binary import run_cli
1919
from cortex.client import Client
@@ -79,7 +79,7 @@ def new_client(
7979

8080

8181
@sentry_wrapper
82-
def env_list() -> list:
82+
def env_list() -> List:
8383
"""
8484
List all environments configured on this machine.
8585
"""

0 commit comments

Comments
 (0)