1111from rich .panel import Panel
1212from rich .table import Table
1313
14- import vec_inf .shared ._utils as utils
15- from vec_inf .shared ._config import ModelConfig
16- from vec_inf .shared ._helper import LaunchHelper , ListHelper , MetricsHelper , StatusHelper
14+ import vec_inf .client ._utils as utils
15+ from vec_inf .cli ._models import MODEL_TYPE_COLORS , MODEL_TYPE_PRIORITY
16+ from vec_inf .client ._config import ModelConfig
17+ from vec_inf .client ._helper import (
18+ ModelLauncher ,
19+ ModelRegistry ,
20+ ModelStatusMonitor ,
21+ PerformanceMetricsCollector ,
22+ )
1723
1824
19- class CLILaunchHelper ( LaunchHelper ):
20- """CLI Helper class for handling launch information ."""
25+ class CLIModelLauncher ( ModelLauncher ):
26+ """CLI Helper class for handling inference server launch ."""
2127
2228 def __init__ (self , model_name : str , kwargs : Optional [dict [str , Any ]]):
2329 super ().__init__ (model_name , kwargs )
@@ -26,12 +32,12 @@ def _warn(self, message: str) -> None:
2632 """Warn the user about a potential issue."""
2733 click .echo (click .style (f"Warning: { message } " , fg = "yellow" ), err = True )
2834
29- def _format_table_output (self , job_id : str ) -> Table :
35+ def format_table_output (self ) -> Table :
3036 """Format output as rich Table."""
3137 table = utils .create_table (key_title = "Job Config" , value_title = "Value" )
3238
3339 # Add key information with consistent styling
34- table .add_row ("Slurm Job ID" , job_id , style = "blue" )
40+ table .add_row ("Slurm Job ID" , self . slurm_job_id , style = "blue" )
3541 table .add_row ("Job Name" , self .model_name )
3642
3743 # Add model details
@@ -71,33 +77,12 @@ def _format_table_output(self, job_id: str) -> Table:
7177
7278 return table
7379
74- def post_launch_processing (self , output : str , console : Console ) -> None :
75- """Process and display launch output."""
76- json_mode = bool (self .kwargs .get ("json_mode" , False ))
77- slurm_job_id = output .split (" " )[- 1 ].strip ().strip ("\n " )
78- self .params ["slurm_job_id" ] = slurm_job_id
79- job_json = Path (
80- self .params ["log_dir" ],
81- f"{ self .model_name } .{ slurm_job_id } " ,
82- f"{ self .model_name } .{ slurm_job_id } .json" ,
83- )
84- job_json .parent .mkdir (parents = True , exist_ok = True )
85- job_json .touch (exist_ok = True )
86-
87- with job_json .open ("w" ) as file :
88- json .dump (self .params , file , indent = 4 )
89- if json_mode :
90- click .echo (self .params )
91- else :
92- table = self ._format_table_output (slurm_job_id )
93- console .print (table )
9480
81+ class CLIModelStatusMonitor (ModelStatusMonitor ):
82+ """CLI Helper class for handling server status information and monitoring."""
9583
96- class CLIStatusHelper (StatusHelper ):
97- """CLI Helper class for handling status information."""
98-
99- def __init__ (self , slurm_job_id : int , output : str , log_dir : Optional [str ] = None ):
100- super ().__init__ (slurm_job_id , output , log_dir )
84+ def __init__ (self , slurm_job_id : int , log_dir : Optional [str ] = None ):
85+ super ().__init__ (slurm_job_id , log_dir )
10186
10287 def output_json (self ) -> None :
10388 """Format and output JSON data."""
@@ -127,7 +112,7 @@ def output_table(self, console: Console) -> None:
127112 console .print (table )
128113
129114
130- class CLIMetricsHelper ( MetricsHelper ):
115+ class CLIMetricsCollector ( PerformanceMetricsCollector ):
131116 """CLI Helper class for streaming metrics information."""
132117
133118 def __init__ (self , slurm_job_id : int , log_dir : Optional [str ] = None ):
@@ -204,8 +189,8 @@ def display_metrics(self, table: Table, metrics: dict[str, float]) -> None:
204189 )
205190
206191
207- class CLIListHelper ( ListHelper ):
208- """Helper class for handling model listing functionality."""
192+ class CLIModelRegistry ( ModelRegistry ):
193+ """CLI Helper class for handling model listing functionality."""
209194
210195 def __init__ (self , json_mode : bool = False ):
211196 super ().__init__ ()
@@ -237,28 +222,15 @@ def format_all_models_output(self) -> Union[list[str], list[Panel]]:
237222 return [config .model_name for config in self .model_configs ]
238223
239224 # Sort by model type priority
240- type_priority = {
241- "LLM" : 0 ,
242- "VLM" : 1 ,
243- "Text_Embedding" : 2 ,
244- "Reward_Modeling" : 3 ,
245- }
246225 sorted_configs = sorted (
247226 self .model_configs ,
248- key = lambda x : type_priority .get (x .model_type , 4 ),
227+ key = lambda x : MODEL_TYPE_PRIORITY .get (x .model_type , 4 ),
249228 )
250229
251230 # Create panels with color coding
252- model_type_colors = {
253- "LLM" : "cyan" ,
254- "VLM" : "bright_blue" ,
255- "Text_Embedding" : "purple" ,
256- "Reward_Modeling" : "bright_magenta" ,
257- }
258-
259231 panels = []
260232 for config in sorted_configs :
261- color = model_type_colors .get (config .model_type , "white" )
233+ color = MODEL_TYPE_COLORS .get (config .model_type , "white" )
262234 variant = config .model_variant or ""
263235 display_text = f"[magenta]{ config .model_family } [/magenta]"
264236 if variant :
0 commit comments