Skip to content

Commit affe073

Browse files
committed
fix: update status output
1 parent ccc73f7 commit affe073

File tree

2 files changed

+72
-54
lines changed

2 files changed

+72
-54
lines changed

src/emd/cfn/ecs/template.yaml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -388,25 +388,6 @@ Resources:
388388
GroupId: !Ref ServiceSecurityGroup
389389
IpProtocol: -1
390390
SourceSecurityGroupId: !Ref PublicLoadBalancerSecurityGroup
391-
ListenerRulePath:
392-
Type: AWS::ElasticLoadBalancingV2::ListenerRule
393-
Properties:
394-
ListenerArn: !Ref PublicLoadBalancerListenerArn
395-
Priority: !GetAtt GetPriorityNumber.Priority
396-
Conditions:
397-
- Field: path-pattern
398-
PathPatternConfig:
399-
Values:
400-
- !Join
401-
- ''
402-
- - '/'
403-
- !Ref ModelId
404-
- '/'
405-
- !Ref ModelTag
406-
- '/*'
407-
Actions:
408-
- Type: forward
409-
TargetGroupArn: !Ref ServiceTargetGroup
410391

411392
ForceApiRouterDeployment:
412393
Type: Custom::ForceApiRouterDeployment

src/emd/commands/status.py

Lines changed: 72 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from typing import Annotated, Optional
99
from emd.sdk.status import get_model_status
1010
from rich.table import Table
11+
from rich.panel import Panel
12+
from rich.box import Box, SIMPLE, MINIMAL
1113
from emd.utils.decorators import catch_aws_credential_errors,check_emd_env_exist,load_aws_profile
1214
from emd.constants import MODEL_DEFAULT_TAG
1315
from emd.utils.logger_utils import make_layout
@@ -31,7 +33,7 @@ def status(
3133
str, typer.Argument(help="Model tag")
3234
] = MODEL_DEFAULT_TAG,
3335
):
34-
ret = get_model_status(model_id,model_tag=model_tag)
36+
ret = get_model_status(model_id, model_tag=model_tag)
3537
inprogress = ret['inprogress']
3638
completed = ret['completed']
3739

@@ -40,49 +42,84 @@ def status(
4042
if d['status'] == "Stopped":
4143
continue
4244
data.append({
43-
"model_id":d['model_id'],
44-
"model_tag":d['model_tag'],
45+
"model_id": d['model_id'],
46+
"model_tag": d['model_tag'],
4547
"status": f"{d['status']} ({d['stage_name']})",
46-
"service_type":d['service_type'],
47-
"instance_type":d['instance_type'],
48-
"create_time":d['create_time'],
49-
"outputs":d['outputs'],
48+
"service_type": d['service_type'],
49+
"instance_type": d['instance_type'],
50+
"create_time": d['create_time'],
51+
"outputs": d['outputs'],
5052
})
5153

5254
for d in completed:
5355
data.append({
54-
"model_id":d['model_id'],
55-
"model_tag":d['model_tag'],
56+
"model_id": d['model_id'],
57+
"model_tag": d['model_tag'],
5658
"status": d['stack_status'],
57-
"service_type":d['service_type'],
58-
"instance_type":d['instance_type'],
59-
"create_time":d['create_time'],
60-
"outputs":d['outputs'],
59+
"service_type": d['service_type'],
60+
"instance_type": d['instance_type'],
61+
"create_time": d['create_time'],
62+
"outputs": d['outputs'],
6163
})
6264

6365
account_id = get_account_id()
64-
table = Table(show_lines=True, expand=True)
65-
table.add_column("ModelId", justify="left",overflow='fold')
66-
table.add_column("ModelTag", justify="left",overflow='fold')
67-
table.add_column("Status", justify="left",overflow='fold')
68-
table.add_column("Service", justify="left",overflow='fold',max_width=19)
69-
table.add_column("Instance", justify="left",overflow='fold')
70-
table.add_column("CreateTime", justify="left",overflow='fold')
71-
table.add_column("Outputs", justify="left",overflow='fold')
72-
73-
# table.field_names = ["model_id", "status"]
74-
for d in data:
75-
table.add_row(
76-
d['model_id'],
77-
d['model_tag'],
78-
d['status'],
79-
d['service_type'],
80-
d['instance_type'],
81-
d['create_time'].replace(" ", "\n"),
82-
d['outputs']
83-
)
84-
# table.add_row([d['model_id'], d['status']])
85-
console.print(table)
66+
67+
# Display each model in its own table box
68+
for model_data in data:
69+
# Create a table for the model with a thinner border
70+
model_table = Table(show_header=False, expand=True)
71+
72+
# Add a single column for the model name header
73+
model_table.add_column(justify="center")
74+
75+
# Add the model name as the first row with bold styling
76+
model_name = f"{model_data['model_id']}/{model_data['model_tag']}"
77+
model_table.add_row(model_name, style="bold")
78+
79+
# Create a nested table for model details
80+
details_table = Table(show_header=False, box=None, expand=True)
81+
details_table.add_column(justify="left", style="cyan", width=20)
82+
details_table.add_column(justify="left", overflow="fold")
83+
84+
# Add model details as name/value pairs
85+
details_table.add_row("Status", model_data['status'])
86+
details_table.add_row("Service Type", model_data['service_type'])
87+
details_table.add_row("Instance Type", model_data['instance_type'])
88+
details_table.add_row("Create Time", model_data['create_time'])
89+
90+
# Parse and add outputs as separate rows
91+
try:
92+
# Check if outputs is a string that looks like a dictionary
93+
if model_data['outputs'] and isinstance(model_data['outputs'], str) and '{' in model_data['outputs']:
94+
# Try to convert the string to a dictionary
95+
import ast
96+
outputs_dict = ast.literal_eval(model_data['outputs'])
97+
if isinstance(outputs_dict, dict):
98+
# Define the order of priority keys
99+
priority_keys = ["BaseURL", "Model", "ModelAPIKey"]
100+
101+
# First add priority keys if they exist
102+
for key in priority_keys:
103+
if key in outputs_dict:
104+
details_table.add_row(key, str(outputs_dict[key]))
105+
106+
# Then add any remaining keys
107+
for key, value in outputs_dict.items():
108+
if key not in priority_keys:
109+
details_table.add_row(key, str(value))
110+
else:
111+
details_table.add_row("Outputs", model_data['outputs'])
112+
else:
113+
details_table.add_row("Outputs", model_data['outputs'])
114+
except (SyntaxError, ValueError):
115+
# If parsing fails, just show the raw outputs
116+
details_table.add_row("Outputs", model_data['outputs'])
117+
118+
# Add the details table as a row in the main table
119+
model_table.add_row(details_table)
120+
121+
console.print(model_table)
122+
console.print() # Add a blank line between models
86123

87124

88125
if __name__ == "__main__":

0 commit comments

Comments
 (0)