@@ -246,15 +246,27 @@ def js_describe(
246246 if not isinstance (data , dict ):
247247 click .echo ("Invalid data received: expected a dictionary." )
248248 return
249-
249+
250+ click .echo ("\n Deployment (should be completed in 1-5 min):" )
251+
250252 status = data .get ("status" ) or {}
251253 metadata = data .get ("metadata" ) or {}
252254 model = data .get ("model" ) or {}
253255 server = data .get ("server" ) or {}
254256 tls = data .get ("tlsConfig" ) or {}
255257
258+ raw_state = status .get ("deploymentStatus" , {}) \
259+ .get ("deploymentObjectOverallState" , "" ) or ""
260+ if raw_state == "DeploymentComplete" :
261+ fg = "green"
262+ elif raw_state == "DeploymentInProgress" :
263+ fg = "yellow"
264+ else :
265+ fg = "red"
266+ colored_state = click .style (raw_state , fg = fg , bold = True )
267+
256268 summary = [
257- ("Deployment State :" , status . get ( "deploymentStatus" , {}). get ( "deploymentObjectOverallState" , "" ) ),
269+ ("Status :" , colored_state ),
258270 ("Metadata Name:" , metadata .get ("name" , "" )),
259271 ("Namespace:" , metadata .get ("namespace" , "" )),
260272 ("Label:" , metadata .get ("label" , "" )),
@@ -266,27 +278,16 @@ def js_describe(
266278 ]
267279 click .echo (tabulate (summary , tablefmt = "plain" ))
268280
269- click .echo ("\n SageMaker Endpoint:" )
270- status = data .get ("status" ) or {}
271- endpoints = status .get ("endpoints" ) or {}
272- sagemaker_info = endpoints .get ("sagemaker" )
273- if not sagemaker_info :
274- click .secho (" <no SageMaker endpoint information available>" , fg = "yellow" )
275- else :
276- ep_rows = [
277- ("State:" , data .get ("status" , {}).get ("endpoints" , {}).get ("sagemaker" , {}).get ("state" )),
278- ("Name:" , data .get ("sageMakerEndpoint" , {}).get ("name" )),
279- ("ARN:" , data .get ("status" , {}).get ("endpoints" , {}).get ("sagemaker" , {}).get ("endpointArn" )),
280- ]
281- click .echo (tabulate (ep_rows , tablefmt = "plain" ))
282-
283- click .echo ("\n Conditions:" )
281+ click .echo ("\n Deployment Status Conditions:" )
284282
285283 status = data .get ("status" ) if isinstance (data , dict ) else {}
286- status = status or {}
287- conds = status .get ("conditions" , [])
284+ status = status or {}
288285
289- if isinstance (conds , list ) and conds :
286+ deployment_status = status .get ("deploymentStatus" ) or {}
287+ dep_status_inner = deployment_status .get ("status" ) or {}
288+ dep_conds = dep_status_inner .get ("conditions" ) or []
289+
290+ if isinstance (dep_conds , list ) and dep_conds :
290291 headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
291292 rows = [
292293 [
@@ -296,22 +297,45 @@ def js_describe(
296297 c .get ("lastUpdateTime" , "" ),
297298 c .get ("message" ) or ""
298299 ]
299- for c in conds if isinstance (c , dict )
300+ for c in dep_conds if isinstance (c , dict )
300301 ]
301302 click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
302303 else :
303304 click .echo (" <none>" )
304305
305- click .echo ("\n DeploymentStatus Conditions:" )
306+ click .echo ()
307+ click .echo (click .style ("─" * 60 , fg = "white" ))
308+
309+ click .echo ("\n SageMaker Endpoint (takes ~10 min to create):" )
310+ status = data .get ("status" ) or {}
311+ endpoints = status .get ("endpoints" ) or {}
312+ sagemaker_info = endpoints .get ("sagemaker" )
306313
307- status = data .get ("status" ) if isinstance (data , dict ) else {}
308- status = status or {}
314+ if not sagemaker_info :
315+ click .secho (" <no SageMaker endpoint information available>" , fg = "yellow" )
316+ else :
317+ raw_state = sagemaker_info .get ("state" , "" ) or ""
318+ if raw_state == "CreationCompleted" :
319+ fg = "green"
320+ elif raw_state == "CreationInProgress" :
321+ fg = "yellow"
322+ else :
323+ fg = "red"
324+ colored_state = click .style (raw_state , fg = fg , bold = True )
325+ ep_rows = [
326+ ("Status:" , colored_state ),
327+ ("Name:" , data .get ("sageMakerEndpoint" , {}).get ("name" )),
328+ ("ARN:" , sagemaker_info .get ("endpointArn" )),
329+ ]
330+ click .echo (tabulate (ep_rows , tablefmt = "plain" ))
309331
310- deployment_status = status .get ("deploymentStatus" ) or {}
311- dep_status_inner = deployment_status .get ("status" ) or {}
312- dep_conds = dep_status_inner .get ("conditions" ) or []
332+ click .echo ("\n Sagemaker Endpoint Status Conditions:" )
313333
314- if isinstance (dep_conds , list ) and dep_conds :
334+ status = data .get ("status" ) if isinstance (data , dict ) else {}
335+ status = status or {}
336+ conds = status .get ("conditions" , [])
337+
338+ if isinstance (conds , list ) and conds :
315339 headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
316340 rows = [
317341 [
@@ -321,7 +345,7 @@ def js_describe(
321345 c .get ("lastUpdateTime" , "" ),
322346 c .get ("message" ) or ""
323347 ]
324- for c in dep_conds if isinstance (c , dict )
348+ for c in conds if isinstance (c , dict )
325349 ]
326350 click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
327351 else :
@@ -371,7 +395,8 @@ def custom_describe(
371395 click .echo ("Invalid data received: expected a dictionary." )
372396 return
373397
374- # Safe access blocks
398+ click .echo ("\n Deployment (should be completed in 1-5 min):" )
399+
375400 status = data .get ("status" ) or {}
376401 metadata = data .get ("metadata" ) or {}
377402 metrics = data .get ("metrics" ) or {}
@@ -385,8 +410,18 @@ def custom_describe(
385410 model_port = worker .get ("modelInvocationPort" ) or {}
386411 cloudwatch = data .get ("autoScalingSpec" , {}).get ("cloudWatchTrigger" ) or {}
387412
413+ raw_state = status .get ("deploymentStatus" , {}) \
414+ .get ("deploymentObjectOverallState" , "" ) or ""
415+ if raw_state == "DeploymentComplete" :
416+ fg = "green"
417+ elif raw_state == "DeploymentInProgress" :
418+ fg = "yellow"
419+ else :
420+ fg = "red"
421+ colored_state = click .style (raw_state , fg = fg , bold = True )
422+
388423 summary = [
389- ("Deployment State:" , status . get ( "deploymentStatus" , {}). get ( "deploymentObjectOverallState" , "" ) ),
424+ ("Deployment State:" , colored_state ),
390425 ("Metadata Name:" , metadata .get ("name" , "" )),
391426 ("Namespace:" , metadata .get ("namespace" , "" )),
392427 ("Label:" , metadata .get ("label" , "" )),
@@ -425,22 +460,16 @@ def custom_describe(
425460
426461 click .echo (tabulate (summary , tablefmt = "plain" ))
427462
428- click .echo ("\n SageMaker Endpoint:" )
429- sm_endpoints = status .get ("endpoints" ) or {}
430- sagemaker_info = sm_endpoints .get ("sagemaker" )
431- if not sagemaker_info :
432- click .secho (" <no SageMaker endpoint information available>" , fg = "yellow" )
433- else :
434- ep_rows = [
435- ("State:" , sm_endpoints .get ("sagemaker" , {}).get ("state" , "" )),
436- ("Name:" , data .get ("sageMakerEndpoint" , {}).get ("name" , "" )),
437- ("ARN:" , sm_endpoints .get ("sagemaker" , {}).get ("endpointArn" , "" )),
438- ]
439- click .echo (tabulate (ep_rows , tablefmt = "plain" ))
463+ click .echo ("\n Deployment Status Conditions:" )
440464
441- click .echo ("\n Conditions:" )
442- conds = status .get ("conditions" , [])
443- if isinstance (conds , list ) and conds :
465+ status = data .get ("status" ) if isinstance (data , dict ) else {}
466+ status = status or {}
467+
468+ deployment_status = status .get ("deploymentStatus" ) or {}
469+ dep_status_inner = deployment_status .get ("status" ) or {}
470+ dep_conds = dep_status_inner .get ("conditions" ) or []
471+
472+ if isinstance (dep_conds , list ) and dep_conds :
444473 headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
445474 rows = [
446475 [
@@ -450,17 +479,45 @@ def custom_describe(
450479 c .get ("lastUpdateTime" , "" ),
451480 c .get ("message" ) or ""
452481 ]
453- for c in conds if isinstance (c , dict )
482+ for c in dep_conds if isinstance (c , dict )
454483 ]
455484 click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
456485 else :
457486 click .echo (" <none>" )
458487
459- click .echo ("\n DeploymentStatus Conditions:" )
460- deployment_status = status .get ("deploymentStatus" ) or {}
461- dep_status_inner = deployment_status .get ("status" ) or {}
462- dep_conds = dep_status_inner .get ("conditions" ) or []
463- if isinstance (dep_conds , list ) and dep_conds :
488+ click .echo ()
489+ click .echo (click .style ("─" * 60 , fg = "white" ))
490+
491+ click .echo ("\n SageMaker Endpoint (takes ~10 min to create):" )
492+ status = data .get ("status" ) or {}
493+ endpoints = status .get ("endpoints" ) or {}
494+ sagemaker_info = endpoints .get ("sagemaker" )
495+
496+ if not sagemaker_info :
497+ click .secho (" <no SageMaker endpoint information available>" , fg = "yellow" )
498+ else :
499+ raw_state = sagemaker_info .get ("state" , "" ) or ""
500+ if raw_state == "CreationCompleted" :
501+ fg = "green"
502+ elif raw_state == "CreationInProgress" :
503+ fg = "yellow"
504+ else :
505+ fg = "red"
506+ colored_state = click .style (raw_state , fg = fg , bold = True )
507+ ep_rows = [
508+ ("Status:" , colored_state ),
509+ ("Name:" , data .get ("sageMakerEndpoint" , {}).get ("name" )),
510+ ("ARN:" , sagemaker_info .get ("endpointArn" )),
511+ ]
512+ click .echo (tabulate (ep_rows , tablefmt = "plain" ))
513+
514+ click .echo ("\n Sagemaker Endpoint Status Conditions:" )
515+
516+ status = data .get ("status" ) if isinstance (data , dict ) else {}
517+ status = status or {}
518+ conds = status .get ("conditions" , [])
519+
520+ if isinstance (conds , list ) and conds :
464521 headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
465522 rows = [
466523 [
@@ -470,7 +527,7 @@ def custom_describe(
470527 c .get ("lastUpdateTime" , "" ),
471528 c .get ("message" ) or ""
472529 ]
473- for c in dep_conds if isinstance (c , dict )
530+ for c in conds if isinstance (c , dict )
474531 ]
475532 click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
476533 else :
0 commit comments