Skip to content

Commit 4b38e2c

Browse files
authored
Upgrade to Platform v3.2.4 APIs (#90)
1 parent 660f13f commit 4b38e2c

File tree

6 files changed

+95
-17
lines changed

6 files changed

+95
-17
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ Alternatively to build from source, clone this repo then inside the project's ba
1616
pip install .
1717
```
1818

19+
### Un-installation
20+
21+
To uninstall `centml`, simply do:
22+
```bash
23+
pip uninstall centml
24+
```
25+
1926
### CLI
2027
Once installed, use the centml CLI tool with the following command:
2128
```bash
@@ -85,3 +92,30 @@ To run all the tests, use:
8592
```bash
8693
pytest
8794
```
95+
96+
### Common Issues
97+
98+
- **`SSL` certificate on `MacOS`**
99+
100+
Sometimes, you will see issues when using command like `centml cluster [CMD]`, where the output might look like:
101+
102+
```logs
103+
104+
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/urllib3/util/retry.py", line 519, in increment
105+
106+
raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type]
107+
108+
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.centml.com', port=443):
109+
110+
Max retries exceeded with url: /deployments
111+
112+
(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1007)')))
113+
```
114+
115+
**Solution**:
116+
To fix this issue, navigate to your `python` installation directory and run the `Install Certificates.command` file located there.
117+
118+
For example, if you are using `python3.10`, the file path would be:
119+
`
120+
/Applications/Python 3.10/Install Certificates.command
121+
`

centml/cli/cluster.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@
77
from centml.sdk.api import get_centml_client
88

99

10+
depl_type_to_name_map = {
11+
DeploymentType.INFERENCE: 'inference',
12+
DeploymentType.COMPUTE: 'compute',
13+
DeploymentType.COMPILATION: 'compilation',
14+
DeploymentType.INFERENCE_V2: 'inference',
15+
DeploymentType.COMPUTE_V2: 'compute',
16+
DeploymentType.CSERVE: 'cserve',
17+
DeploymentType.CSERVE_V2: 'cserve',
18+
DeploymentType.RAG: 'rag',
19+
}
1020
depl_name_to_type_map = {
11-
"inference": DeploymentType.INFERENCE_V2,
12-
"compute": DeploymentType.COMPUTE_V2,
13-
"cserve": DeploymentType.CSERVE,
21+
'inference': DeploymentType.INFERENCE_V2,
22+
'cserve': DeploymentType.CSERVE_V2,
23+
'compute': DeploymentType.COMPUTE_V2,
24+
'rag': DeploymentType.RAG,
1425
}
15-
depl_type_to_name_map = {v: k for k, v in depl_name_to_type_map.items()}
1626

1727

1828
def handle_exception(func):
@@ -21,7 +31,7 @@ def wrapper(*args, **kwargs):
2131
try:
2232
return func(*args, **kwargs)
2333
except ApiException as e:
24-
click.echo(f"Error: {e.reason}")
34+
click.echo(f"Error: {e.body or e.reason}")
2535
return None
2636

2737
return wrapper
@@ -43,7 +53,7 @@ def _get_hw_to_id_map(cclient, cluster_id):
4353
def _format_ssh_key(ssh_key):
4454
if not ssh_key:
4555
return "No SSH Key Found"
46-
return ssh_key[:10] + '...'
56+
return ssh_key[:32] + "..."
4757

4858

4959
def _get_ready_status(cclient, deployment):
@@ -80,10 +90,18 @@ def ls(type):
8090
with get_centml_client() as cclient:
8191
depl_type = depl_name_to_type_map[type] if type in depl_name_to_type_map else None
8292
deployments = cclient.get(depl_type)
83-
rows = [
84-
[d.id, d.name, depl_type_to_name_map[d.type], d.status.value, d.created_at.strftime("%Y-%m-%d %H:%M:%S")]
85-
for d in deployments
86-
]
93+
rows = []
94+
for d in deployments:
95+
if d.type in depl_type_to_name_map:
96+
rows.append(
97+
[
98+
d.id,
99+
d.name,
100+
depl_type_to_name_map[d.type],
101+
d.status.value,
102+
d.created_at.strftime("%Y-%m-%d %H:%M:%S"),
103+
]
104+
)
87105

88106
click.echo(
89107
tabulate(
@@ -107,7 +125,7 @@ def get(type, id):
107125
deployment = cclient.get_inference(id)
108126
elif depl_type == DeploymentType.COMPUTE_V2:
109127
deployment = cclient.get_compute(id)
110-
elif depl_type == DeploymentType.CSERVE:
128+
elif depl_type == DeploymentType.CSERVE_V2:
111129
deployment = cclient.get_cserve(id)
112130
else:
113131
sys.exit("Please enter correct deployment type")
@@ -124,7 +142,7 @@ def get(type, id):
124142
("Endpoint", deployment.endpoint_url),
125143
("Created at", deployment.created_at.strftime("%Y-%m-%d %H:%M:%S")),
126144
("Hardware", f"{hw.name} ({hw.num_gpu}x {hw.gpu_type})"),
127-
("Cost", f"{hw.cost_per_hr/100} credits/hr"),
145+
("Cost", f"{hw.cost_per_hr / 100} credits/hr"),
128146
],
129147
tablefmt="rounded_outline",
130148
disable_numparse=True,
@@ -155,7 +173,7 @@ def get(type, id):
155173
disable_numparse=True,
156174
)
157175
)
158-
elif depl_type == DeploymentType.CSERVE:
176+
elif depl_type == DeploymentType.CSERVE_V2:
159177
click.echo(
160178
tabulate(
161179
[

centml/cli/main.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55

66

77
@click.group()
8+
# this is the version and prog name set in setup.py
9+
@click.version_option(
10+
prog_name="CentML CLI",
11+
message="""
12+
______ __ __ ___ __
13+
/ ____/___ ____ / /_ / |/ // /
14+
/ / / _ \\ / __ \\ / __// /|_/ // /
15+
/ /___ / __// / / // /_ / / / // /___
16+
\\____/ \\___//_/ /_/ \\__//_/ /_//_____/
17+
18+
🚀 Welcome to %(prog)s v%(version)s 🚀
19+
20+
✨ AI Deployment Made Simple ✨
21+
📚 Documentation: https://docs.centml.ai/
22+
🛠 Need help? Reach out to [email protected]
23+
""",
24+
)
825
def cli():
926
pass
1027

centml/sdk/api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import platform_api_python_client
44
from platform_api_python_client import (
5+
DeploymentType,
56
DeploymentStatus,
67
CreateInferenceDeploymentRequest,
78
CreateComputeDeploymentRequest,
@@ -58,8 +59,16 @@ def resume(self, id):
5859
def get_clusters(self):
5960
return self._api.get_clusters_clusters_get()
6061

61-
def get_hardware_instances(self, cluster_id):
62-
return self._api.get_hardware_instances_hardware_instances_get(cluster_id).results
62+
def get_hardware_instances(self, cluster_id=None):
63+
return self._api.get_hardware_instances_hardware_instances_get(
64+
cluster_id=cluster_id if cluster_id else None
65+
).results
66+
67+
def get_prebuilt_images(self, depl_type: DeploymentType):
68+
return self._api.get_prebuilt_images_prebuilt_images_get(type=depl_type)
69+
70+
def get_cserve_recipe(self):
71+
return self._api.get_cserve_recipe_deployments_cserve_recipes_get().results
6372

6473

6574
@contextmanager

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ cryptography==44.0.1
99
prometheus-client>=0.20.0
1010
scipy>=1.6.0
1111
scikit-learn>=1.5.1
12-
platform-api-python-client==0.3.1
12+
platform-api-python-client==3.2.4

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name='centml',
14-
version='0.3.0',
14+
version='0.3.1',
1515
packages=find_packages(),
1616
python_requires=">=3.10",
1717
long_description=open('README.md').read(),

0 commit comments

Comments
 (0)