Skip to content

Commit 25e3b66

Browse files
authored
Updated cluster commands to use platform client 0.3.1 (#80)
* Updated cluster commands to use platform client 0.3.1
1 parent 35fc1fe commit 25e3b66

File tree

7 files changed

+55
-37
lines changed

7 files changed

+55
-37
lines changed

centml/cli/cluster.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Dict
44
import click
55
from tabulate import tabulate
6-
from centml.sdk import DeploymentType, DeploymentStatus, HealthStatus, ApiException, HardwareInstanceResponse
6+
from centml.sdk import DeploymentType, DeploymentStatus, ServiceStatus, ApiException, HardwareInstanceResponse
77
from centml.sdk.api import get_centml_client
88

99

@@ -55,10 +55,18 @@ def _get_ready_status(cclient, deployment):
5555
status_styles = {
5656
(DeploymentStatus.PAUSED, None): ("paused", "yellow", "black"),
5757
(DeploymentStatus.DELETED, None): ("deleted", "white", "black"),
58-
(DeploymentStatus.ACTIVE, HealthStatus.HEALTHY): ("ready", "green", "black"),
59-
(DeploymentStatus.ACTIVE, HealthStatus.PROGRESSING): ("starting", "black", "white"),
60-
(DeploymentStatus.ACTIVE, HealthStatus.DEGRADED): ("starting", "black", "white"),
61-
(DeploymentStatus.ACTIVE, HealthStatus.MISSING): ("not found", "cyan"),
58+
(DeploymentStatus.ACTIVE, ServiceStatus.HEALTHY): ("ready", "green", "black"),
59+
(DeploymentStatus.ACTIVE, ServiceStatus.INITIALIZING): ("starting", "black", "white"),
60+
(DeploymentStatus.ACTIVE, ServiceStatus.MISSING): ("starting", "black", "white"),
61+
(DeploymentStatus.ACTIVE, ServiceStatus.ERROR): ("error", "red", "black"),
62+
(DeploymentStatus.ACTIVE, ServiceStatus.CREATECONTAINERCONFIGERROR): (
63+
"createContainerConfigError",
64+
"red",
65+
"black",
66+
),
67+
(DeploymentStatus.ACTIVE, ServiceStatus.CRASHLOOPBACKOFF): ("crashLoopBackOff", "red", "black"),
68+
(DeploymentStatus.ACTIVE, ServiceStatus.IMAGEPULLBACKOFF): ("imagePullBackOff", "red", "black"),
69+
(DeploymentStatus.ACTIVE, ServiceStatus.PROGRESSDEADLINEEXCEEDED): ("progressDeadlineExceeded", "red", "black"),
6270
}
6371

6472
style = status_styles.get((api_status, service_status), ("unknown", "black", "white"))

centml/sdk/api.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import platform_api_python_client
44
from platform_api_python_client import (
55
DeploymentStatus,
6-
CreateInferenceDeploymentV2Request,
7-
CreateComputeDeploymentV2Request,
6+
CreateInferenceDeploymentRequest,
7+
CreateComputeDeploymentRequest,
88
CreateCServeDeploymentRequest,
99
)
1010

@@ -14,37 +14,37 @@
1414

1515
class CentMLClient:
1616
def __init__(self, api):
17-
self._api = api
17+
self._api: platform_api_python_client.EXTERNALApi = api
1818

1919
def get(self, depl_type):
20-
results = self._api.get_deployments_deployments_v2_get(type=depl_type).results
20+
results = self._api.get_deployments_deployments_get(type=depl_type).results
2121
deployments = sorted(results, reverse=True, key=lambda d: d.created_at)
2222
return deployments
2323

2424
def get_status(self, id):
25-
return self._api.get_deployment_status_deployments_v2_status_deployment_id_get(id)
25+
return self._api.get_deployment_status_deployments_status_deployment_id_get(id)
2626

2727
def get_inference(self, id):
28-
return self._api.get_inference_deployment_deployments_v2_inference_deployment_id_get(id)
28+
return self._api.get_inference_deployment_deployments_inference_deployment_id_get(id)
2929

3030
def get_compute(self, id):
31-
return self._api.get_compute_deployment_deployments_v2_compute_deployment_id_get(id)
31+
return self._api.get_compute_deployment_deployments_compute_deployment_id_get(id)
3232

3333
def get_cserve(self, id):
34-
return self._api.get_cserve_deployment_deployments_v2_cserve_deployment_id_get(id)
34+
return self._api.get_cserve_deployment_deployments_cserve_deployment_id_get(id)
3535

36-
def create_inference(self, request: CreateInferenceDeploymentV2Request):
37-
return self._api.create_inference_deployment_deployments_v2_inference_post(request)
36+
def create_inference(self, request: CreateInferenceDeploymentRequest):
37+
return self._api.create_inference_deployment_deployments_inference_post(request)
3838

39-
def create_compute(self, request: CreateComputeDeploymentV2Request):
39+
def create_compute(self, request: CreateComputeDeploymentRequest):
4040
return self._api.create_compute_deployment_deployments_compute_post(request)
4141

4242
def create_cserve(self, request: CreateCServeDeploymentRequest):
43-
return self._api.create_cserve_deployment_deployments_v2_cserve_post(request)
43+
return self._api.create_cserve_deployment_deployments_cserve_post(request)
4444

4545
def _update_status(self, id, new_status):
4646
status_req = platform_api_python_client.DeploymentStatusRequest(status=new_status)
47-
self._api.update_deployment_status_deployments_v2_status_deployment_id_put(id, status_req)
47+
self._api.update_deployment_status_deployments_status_deployment_id_put(id, status_req)
4848

4949
def delete(self, id):
5050
self._update_status(id, DeploymentStatus.DELETED)
@@ -59,7 +59,7 @@ def get_clusters(self):
5959
return self._api.get_clusters_clusters_get()
6060

6161
def get_hardware_instances(self, cluster_id):
62-
return self._api.get_hardware_instances_hardware_instances_v2_get(cluster_id).results
62+
return self._api.get_hardware_instances_hardware_instances_get(cluster_id).results
6363

6464

6565
@contextmanager

centml/sdk/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def get_centml_token():
5151
if not cred:
5252
sys.exit("CentML credentials not found. Please login...")
5353

54-
exp_time = int(jwt.decode(cred["access_token"], options={"verify_signature": False})["exp"])
54+
exp_time = int(jwt.decode(cred["idToken"], options={"verify_signature": False})["exp"])
5555

5656
if time.time() >= exp_time - 100:
57-
cred = refresh_centml_token(cred["refresh_token"])
57+
cred = refresh_centml_token(cred["refreshToken"])
5858

59-
return cred["access_token"]
59+
return cred["idToken"]
6060

6161

6262
def remove_centml_cred():

centml/sdk/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class Config(BaseSettings):
66
CENTML_WEB_URL: str = "https://app.centml.com/"
77
CENTML_CONFIG_PATH: str = os.path.expanduser("~/.centml")
8-
CENTML_CRED_FILE: str = "credential"
8+
CENTML_CRED_FILE: str = "credentials.json"
99
CENTML_CRED_FILE_PATH: str = CENTML_CONFIG_PATH + "/" + CENTML_CRED_FILE
1010

1111
CENTML_PLATFORM_API_URL: str = "https://api.centml.com"

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-r requirements.txt
2+
13
torch==2.3.1
24
black>=23.10.0
35
pylint>=3.0.1

requirements.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fastapi>=0.103.0
2+
uvicorn>=0.23.0
3+
python-multipart>=0.0.6
4+
pydantic-settings==2.0.*
5+
Requests==2.32.2
6+
tabulate>=0.9.0
7+
pyjwt>=2.8.0
8+
cryptography==43.0.1
9+
prometheus-client>=0.20.0
10+
scipy>=1.6.0
11+
scikit-learn>=1.5.1
12+
platform-api-python-client==0.3.1

setup.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
from setuptools import setup, find_packages
22

3+
REQUIRES = []
4+
with open('requirements.txt') as f:
5+
for line in f:
6+
line, _, _ = line.partition('#')
7+
line = line.strip()
8+
if not line or line.startswith('setuptools'):
9+
continue
10+
REQUIRES.append(line)
11+
312
setup(
413
name='centml',
514
version='0.2.0',
@@ -13,18 +22,5 @@
1322
"ccluster = centml.cli:ccluster",
1423
],
1524
},
16-
install_requires=[
17-
"fastapi>=0.103.0",
18-
"uvicorn>=0.23.0",
19-
"python-multipart>=0.0.6",
20-
"pydantic-settings==2.0.*",
21-
"Requests==2.32.2",
22-
"tabulate>=0.9.0",
23-
"pyjwt>=2.8.0",
24-
"cryptography==43.0.1",
25-
"prometheus-client>=0.20.0",
26-
"scipy>=1.6.0",
27-
"scikit-learn>=1.5.1",
28-
"platform-api-python-client==0.2.0",
29-
],
25+
install_requires=REQUIRES
3026
)

0 commit comments

Comments
 (0)