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
18 changes: 13 additions & 5 deletions centml/cli/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Dict
import click
from tabulate import tabulate
from centml.sdk import DeploymentType, DeploymentStatus, HealthStatus, ApiException, HardwareInstanceResponse
from centml.sdk import DeploymentType, DeploymentStatus, ServiceStatus, ApiException, HardwareInstanceResponse
from centml.sdk.api import get_centml_client


Expand Down Expand Up @@ -55,10 +55,18 @@ def _get_ready_status(cclient, deployment):
status_styles = {
(DeploymentStatus.PAUSED, None): ("paused", "yellow", "black"),
(DeploymentStatus.DELETED, None): ("deleted", "white", "black"),
(DeploymentStatus.ACTIVE, HealthStatus.HEALTHY): ("ready", "green", "black"),
(DeploymentStatus.ACTIVE, HealthStatus.PROGRESSING): ("starting", "black", "white"),
(DeploymentStatus.ACTIVE, HealthStatus.DEGRADED): ("starting", "black", "white"),
(DeploymentStatus.ACTIVE, HealthStatus.MISSING): ("not found", "cyan"),
(DeploymentStatus.ACTIVE, ServiceStatus.HEALTHY): ("ready", "green", "black"),
(DeploymentStatus.ACTIVE, ServiceStatus.INITIALIZING): ("starting", "black", "white"),
(DeploymentStatus.ACTIVE, ServiceStatus.MISSING): ("starting", "black", "white"),
(DeploymentStatus.ACTIVE, ServiceStatus.ERROR): ("error", "red", "black"),
(DeploymentStatus.ACTIVE, ServiceStatus.CREATECONTAINERCONFIGERROR): (
"createContainerConfigError",
"red",
"black",
),
(DeploymentStatus.ACTIVE, ServiceStatus.CRASHLOOPBACKOFF): ("crashLoopBackOff", "red", "black"),
(DeploymentStatus.ACTIVE, ServiceStatus.IMAGEPULLBACKOFF): ("imagePullBackOff", "red", "black"),
(DeploymentStatus.ACTIVE, ServiceStatus.PROGRESSDEADLINEEXCEEDED): ("progressDeadlineExceeded", "red", "black"),
}

style = status_styles.get((api_status, service_status), ("unknown", "black", "white"))
Expand Down
28 changes: 14 additions & 14 deletions centml/sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import platform_api_python_client
from platform_api_python_client import (
DeploymentStatus,
CreateInferenceDeploymentV2Request,
CreateComputeDeploymentV2Request,
CreateInferenceDeploymentRequest,
CreateComputeDeploymentRequest,
CreateCServeDeploymentRequest,
)

Expand All @@ -14,37 +14,37 @@

class CentMLClient:
def __init__(self, api):
self._api = api
self._api: platform_api_python_client.EXTERNALApi = api

def get(self, depl_type):
results = self._api.get_deployments_deployments_v2_get(type=depl_type).results
results = self._api.get_deployments_deployments_get(type=depl_type).results
deployments = sorted(results, reverse=True, key=lambda d: d.created_at)
return deployments

def get_status(self, id):
return self._api.get_deployment_status_deployments_v2_status_deployment_id_get(id)
return self._api.get_deployment_status_deployments_status_deployment_id_get(id)

def get_inference(self, id):
return self._api.get_inference_deployment_deployments_v2_inference_deployment_id_get(id)
return self._api.get_inference_deployment_deployments_inference_deployment_id_get(id)

def get_compute(self, id):
return self._api.get_compute_deployment_deployments_v2_compute_deployment_id_get(id)
return self._api.get_compute_deployment_deployments_compute_deployment_id_get(id)

def get_cserve(self, id):
return self._api.get_cserve_deployment_deployments_v2_cserve_deployment_id_get(id)
return self._api.get_cserve_deployment_deployments_cserve_deployment_id_get(id)

def create_inference(self, request: CreateInferenceDeploymentV2Request):
return self._api.create_inference_deployment_deployments_v2_inference_post(request)
def create_inference(self, request: CreateInferenceDeploymentRequest):
return self._api.create_inference_deployment_deployments_inference_post(request)

def create_compute(self, request: CreateComputeDeploymentV2Request):
def create_compute(self, request: CreateComputeDeploymentRequest):
return self._api.create_compute_deployment_deployments_compute_post(request)

def create_cserve(self, request: CreateCServeDeploymentRequest):
return self._api.create_cserve_deployment_deployments_v2_cserve_post(request)
return self._api.create_cserve_deployment_deployments_cserve_post(request)

def _update_status(self, id, new_status):
status_req = platform_api_python_client.DeploymentStatusRequest(status=new_status)
self._api.update_deployment_status_deployments_v2_status_deployment_id_put(id, status_req)
self._api.update_deployment_status_deployments_status_deployment_id_put(id, status_req)

def delete(self, id):
self._update_status(id, DeploymentStatus.DELETED)
Expand All @@ -59,7 +59,7 @@ def get_clusters(self):
return self._api.get_clusters_clusters_get()

def get_hardware_instances(self, cluster_id):
return self._api.get_hardware_instances_hardware_instances_v2_get(cluster_id).results
return self._api.get_hardware_instances_hardware_instances_get(cluster_id).results


@contextmanager
Expand Down
6 changes: 3 additions & 3 deletions centml/sdk/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def get_centml_token():
if not cred:
sys.exit("CentML credentials not found. Please login...")

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

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

return cred["access_token"]
return cred["idToken"]
Copy link
Contributor

@anandj91 anandj91 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I fixed all these before i made a release.



def remove_centml_cred():
Expand Down
2 changes: 1 addition & 1 deletion centml/sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Config(BaseSettings):
CENTML_WEB_URL: str = "https://app.centml.com/"
CENTML_CONFIG_PATH: str = os.path.expanduser("~/.centml")
CENTML_CRED_FILE: str = "credential"
CENTML_CRED_FILE: str = "credentials.json"
CENTML_CRED_FILE_PATH: str = CENTML_CONFIG_PATH + "/" + CENTML_CRED_FILE

CENTML_PLATFORM_API_URL: str = "https://api.centml.com"
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
-r requirements.txt

torch==2.3.1
black>=23.10.0
pylint>=3.0.1
Expand Down
12 changes: 12 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fastapi>=0.103.0
uvicorn>=0.23.0
python-multipart>=0.0.6
pydantic-settings==2.0.*
Requests==2.32.2
tabulate>=0.9.0
pyjwt>=2.8.0
cryptography==43.0.1
prometheus-client>=0.20.0
scipy>=1.6.0
scikit-learn>=1.5.1
platform-api-python-client==0.3.1
24 changes: 10 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from setuptools import setup, find_packages

REQUIRES = []
with open('requirements.txt') as f:
for line in f:
line, _, _ = line.partition('#')
line = line.strip()
if not line or line.startswith('setuptools'):
continue
REQUIRES.append(line)

setup(
name='centml',
version='0.2.0',
Expand All @@ -13,18 +22,5 @@
"ccluster = centml.cli:ccluster",
],
},
install_requires=[
"fastapi>=0.103.0",
"uvicorn>=0.23.0",
"python-multipart>=0.0.6",
"pydantic-settings==2.0.*",
"Requests==2.32.2",
"tabulate>=0.9.0",
"pyjwt>=2.8.0",
"cryptography==43.0.1",
"prometheus-client>=0.20.0",
"scipy>=1.6.0",
"scikit-learn>=1.5.1",
"platform-api-python-client==0.2.0",
],
install_requires=REQUIRES
)
Loading