44handling the presentation of model information, status updates, and metrics.
55"""
66
7+ import json
78from pathlib import Path
89from typing import Any , Union
910
@@ -27,9 +28,7 @@ class LaunchResponseFormatter:
2728 Parameters
2829 ----------
2930 model_name : str
30- Name of the launched model
31- params : dict[str, Any]
32- Launch parameters and configuration
31+ Name of the launched model params : dict[str, Any] Launch parameters and configuration
3332 """
3433
3534 def __init__ (self , model_name : str , params : dict [str , Any ]):
@@ -116,28 +115,14 @@ def format_table_output(self) -> Table:
116115 for model_name in self .params ["models" ]:
117116 table .add_row ("Model Name" , model_name , style = "magenta" )
118117 # Add resource allocation details
119- table .add_row (
120- "Partition" , f" { self .params ['models' ][model_name ]['partition' ]} "
121- )
118+ table .add_row ("Partition" , f" { self .params ['models' ][model_name ]['partition' ]} " )
122119 table .add_row ("QoS" , f" { self .params ['models' ][model_name ]['qos' ]} " )
123- table .add_row (
124- "Time Limit" , f" { self .params ['models' ][model_name ]['time' ]} "
125- )
126- table .add_row (
127- "Num Nodes" , f" { self .params ['models' ][model_name ]['num_nodes' ]} "
128- )
129- table .add_row (
130- "GPUs/Node" , f" { self .params ['models' ][model_name ]['gpus_per_node' ]} "
131- )
132- table .add_row (
133- "CPUs/Task" , f" { self .params ['models' ][model_name ]['cpus_per_task' ]} "
134- )
135- table .add_row (
136- "Memory/Node" , f" { self .params ['models' ][model_name ]['mem_per_node' ]} "
137- )
138- table .add_row (
139- "Log Directory" , f" { self .params ['models' ][model_name ]['log_dir' ]} "
140- )
120+ table .add_row ("Time Limit" , f" { self .params ['models' ][model_name ]['time' ]} " )
121+ table .add_row ("Num Nodes" , f" { self .params ['models' ][model_name ]['num_nodes' ]} " )
122+ table .add_row ("GPUs/Node" , f" { self .params ['models' ][model_name ]['gpus_per_node' ]} " )
123+ table .add_row ("CPUs/Task" , f" { self .params ['models' ][model_name ]['cpus_per_task' ]} " )
124+ table .add_row ("Memory/Node" , f" { self .params ['models' ][model_name ]['mem_per_node' ]} " )
125+ table .add_row ("Log Directory" , f" { self .params ['models' ][model_name ]['log_dir' ]} " )
141126
142127 return table
143128
@@ -176,7 +161,12 @@ def output_json(self) -> None:
176161 json_data ["pending_reason" ] = self .status_info .pending_reason
177162 if self .status_info .failed_reason :
178163 json_data ["failed_reason" ] = self .status_info .failed_reason
179- click .echo (json_data )
164+
165+ # Convert dict to json compliant string with double quotes
166+ json_string = json .dumps (json_data )
167+
168+ # Output json to console
169+ click .echo (json_string )
180170
181171 def output_table (self ) -> Table :
182172 """Create and display rich table.
@@ -352,9 +342,7 @@ def __init__(self, console: Console, json_mode: bool = False):
352342 self .model_config = None
353343 self .model_names : list [str ] = []
354344
355- def _format_single_model_output (
356- self , config : ModelConfig
357- ) -> Union [dict [str , Any ], Table ]:
345+ def _format_single_model_output (self , config : ModelConfig ) -> Union [dict [str , Any ], Table ]:
358346 """Format output table for a single model.
359347
360348 Parameters
@@ -372,9 +360,7 @@ def _format_single_model_output(
372360 excluded = {"venv" , "log_dir" }
373361 config_dict = config .model_dump (exclude = excluded )
374362 # Convert Path objects to strings
375- config_dict ["model_weights_parent_dir" ] = str (
376- config_dict ["model_weights_parent_dir" ]
377- )
363+ config_dict ["model_weights_parent_dir" ] = str (config_dict ["model_weights_parent_dir" ])
378364 return config_dict
379365
380366 table = create_table (key_title = "Model Config" , value_title = "Value" )
@@ -387,9 +373,7 @@ def _format_single_model_output(
387373 table .add_row (f" { vllm_arg } :" , str (vllm_value ))
388374 return table
389375
390- def _format_all_models_output (
391- self , model_infos : list [ModelInfo ]
392- ) -> Union [list [str ], list [Panel ]]:
376+ def _format_all_models_output (self , model_infos : list [ModelInfo ]) -> Union [list [str ], list [Panel ]]:
393377 """Format output table for all models.
394378
395379 Parameters
0 commit comments