7
7
from centml .sdk .api import get_centml_client
8
8
9
9
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
+ }
10
20
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 ,
14
25
}
15
- depl_type_to_name_map = {v : k for k , v in depl_name_to_type_map .items ()}
16
26
17
27
18
28
def handle_exception (func ):
@@ -21,7 +31,7 @@ def wrapper(*args, **kwargs):
21
31
try :
22
32
return func (* args , ** kwargs )
23
33
except ApiException as e :
24
- click .echo (f"Error: { e .reason } " )
34
+ click .echo (f"Error: { e .body or e . reason } " )
25
35
return None
26
36
27
37
return wrapper
@@ -43,7 +53,7 @@ def _get_hw_to_id_map(cclient, cluster_id):
43
53
def _format_ssh_key (ssh_key ):
44
54
if not ssh_key :
45
55
return "No SSH Key Found"
46
- return ssh_key [:10 ] + ' ...'
56
+ return ssh_key [:32 ] + " ..."
47
57
48
58
49
59
def _get_ready_status (cclient , deployment ):
@@ -80,10 +90,18 @@ def ls(type):
80
90
with get_centml_client () as cclient :
81
91
depl_type = depl_name_to_type_map [type ] if type in depl_name_to_type_map else None
82
92
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
+ )
87
105
88
106
click .echo (
89
107
tabulate (
@@ -107,7 +125,7 @@ def get(type, id):
107
125
deployment = cclient .get_inference (id )
108
126
elif depl_type == DeploymentType .COMPUTE_V2 :
109
127
deployment = cclient .get_compute (id )
110
- elif depl_type == DeploymentType .CSERVE :
128
+ elif depl_type == DeploymentType .CSERVE_V2 :
111
129
deployment = cclient .get_cserve (id )
112
130
else :
113
131
sys .exit ("Please enter correct deployment type" )
@@ -124,7 +142,7 @@ def get(type, id):
124
142
("Endpoint" , deployment .endpoint_url ),
125
143
("Created at" , deployment .created_at .strftime ("%Y-%m-%d %H:%M:%S" )),
126
144
("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" ),
128
146
],
129
147
tablefmt = "rounded_outline" ,
130
148
disable_numparse = True ,
@@ -155,7 +173,7 @@ def get(type, id):
155
173
disable_numparse = True ,
156
174
)
157
175
)
158
- elif depl_type == DeploymentType .CSERVE :
176
+ elif depl_type == DeploymentType .CSERVE_V2 :
159
177
click .echo (
160
178
tabulate (
161
179
[
0 commit comments