77from 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+ }
1020depl_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
1828def 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):
4353def _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
4959def _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 [
0 commit comments