@@ -246,15 +246,27 @@ def js_describe(
246
246
if not isinstance (data , dict ):
247
247
click .echo ("Invalid data received: expected a dictionary." )
248
248
return
249
-
249
+
250
+ click .echo ("\n Deployment (should be completed in 1-5 min):" )
251
+
250
252
status = data .get ("status" ) or {}
251
253
metadata = data .get ("metadata" ) or {}
252
254
model = data .get ("model" ) or {}
253
255
server = data .get ("server" ) or {}
254
256
tls = data .get ("tlsConfig" ) or {}
255
257
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
+
256
268
summary = [
257
- ("Deployment State :" , status . get ( "deploymentStatus" , {}). get ( "deploymentObjectOverallState" , "" ) ),
269
+ ("Status :" , colored_state ),
258
270
("Metadata Name:" , metadata .get ("name" , "" )),
259
271
("Namespace:" , metadata .get ("namespace" , "" )),
260
272
("Label:" , metadata .get ("label" , "" )),
@@ -266,27 +278,16 @@ def js_describe(
266
278
]
267
279
click .echo (tabulate (summary , tablefmt = "plain" ))
268
280
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:" )
284
282
285
283
status = data .get ("status" ) if isinstance (data , dict ) else {}
286
- status = status or {}
287
- conds = status .get ("conditions" , [])
284
+ status = status or {}
288
285
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 :
290
291
headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
291
292
rows = [
292
293
[
@@ -296,22 +297,45 @@ def js_describe(
296
297
c .get ("lastUpdateTime" , "" ),
297
298
c .get ("message" ) or ""
298
299
]
299
- for c in conds if isinstance (c , dict )
300
+ for c in dep_conds if isinstance (c , dict )
300
301
]
301
302
click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
302
303
else :
303
304
click .echo (" <none>" )
304
305
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" )
306
313
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" ))
309
331
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:" )
313
333
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 :
315
339
headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
316
340
rows = [
317
341
[
@@ -321,7 +345,7 @@ def js_describe(
321
345
c .get ("lastUpdateTime" , "" ),
322
346
c .get ("message" ) or ""
323
347
]
324
- for c in dep_conds if isinstance (c , dict )
348
+ for c in conds if isinstance (c , dict )
325
349
]
326
350
click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
327
351
else :
@@ -371,7 +395,8 @@ def custom_describe(
371
395
click .echo ("Invalid data received: expected a dictionary." )
372
396
return
373
397
374
- # Safe access blocks
398
+ click .echo ("\n Deployment (should be completed in 1-5 min):" )
399
+
375
400
status = data .get ("status" ) or {}
376
401
metadata = data .get ("metadata" ) or {}
377
402
metrics = data .get ("metrics" ) or {}
@@ -385,8 +410,18 @@ def custom_describe(
385
410
model_port = worker .get ("modelInvocationPort" ) or {}
386
411
cloudwatch = data .get ("autoScalingSpec" , {}).get ("cloudWatchTrigger" ) or {}
387
412
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
+
388
423
summary = [
389
- ("Deployment State:" , status . get ( "deploymentStatus" , {}). get ( "deploymentObjectOverallState" , "" ) ),
424
+ ("Deployment State:" , colored_state ),
390
425
("Metadata Name:" , metadata .get ("name" , "" )),
391
426
("Namespace:" , metadata .get ("namespace" , "" )),
392
427
("Label:" , metadata .get ("label" , "" )),
@@ -425,22 +460,16 @@ def custom_describe(
425
460
426
461
click .echo (tabulate (summary , tablefmt = "plain" ))
427
462
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:" )
440
464
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 :
444
473
headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
445
474
rows = [
446
475
[
@@ -450,17 +479,45 @@ def custom_describe(
450
479
c .get ("lastUpdateTime" , "" ),
451
480
c .get ("message" ) or ""
452
481
]
453
- for c in conds if isinstance (c , dict )
482
+ for c in dep_conds if isinstance (c , dict )
454
483
]
455
484
click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
456
485
else :
457
486
click .echo (" <none>" )
458
487
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 :
464
521
headers = ["TYPE" , "STATUS" , "LAST TRANSITION" , "LAST UPDATE" , "MESSAGE" ]
465
522
rows = [
466
523
[
@@ -470,7 +527,7 @@ def custom_describe(
470
527
c .get ("lastUpdateTime" , "" ),
471
528
c .get ("message" ) or ""
472
529
]
473
- for c in dep_conds if isinstance (c , dict )
530
+ for c in conds if isinstance (c , dict )
474
531
]
475
532
click .echo (tabulate (rows , headers = headers , tablefmt = "github" ))
476
533
else :
0 commit comments