@@ -64,61 +64,74 @@ def cli(ctx: click.Context, config: Optional[str]) -> None:
6464)
6565@click .option ("--bundles-only" , "-b" , is_flag = True , help = "Show only MONAI Bundles" )
6666@click .option ("--tested-only" , "-t" , is_flag = True , help = "Show only tested models" )
67+ @click .option ("--all" , is_flag = True , help = "Show all models regardless of file extension" )
6768@click .pass_context
68- def list (ctx : click .Context , format : str , bundles_only : bool , tested_only : bool ) -> None :
69+ def list (ctx : click .Context , format : str , bundles_only : bool , tested_only : bool , all : bool ) -> None :
6970 """List available models from configured endpoints.
7071
72+ By default, only shows models with TorchScript (.ts) files.
73+ Use --all to show models with any supported extension.
74+
7175 Args:
7276 ctx: Click context containing configuration
7377 format: Output format (table, simple, or json)
7478 bundles_only: If True, show only MONAI Bundles
7579 tested_only: If True, show only tested models
80+ all: If True, show all models regardless of file extension
7681
7782 Example:
7883 pg list --format table --bundles-only
84+ pg list --all # Show all models
7985 """
8086
8187 # Load configuration
8288 config_path = ctx .obj .get ("config_path" )
8389 settings = load_config (config_path )
8490
85- # Get set of tested model IDs from configuration
86- tested_models = set ()
91+ # Get set of verified model IDs from configuration
92+ verified_models = set ()
8793 for endpoint in settings .endpoints :
8894 for model in endpoint .models :
89- tested_models .add (model .model_id )
95+ verified_models .add (model .model_id )
9096
91- # Create HuggingFace client
92- client = HuggingFaceClient ()
97+ # Create HuggingFace client with settings
98+ client = HuggingFaceClient (settings = settings )
9399
94100 # Fetch models from all endpoints
95101 console .print ("[blue]Fetching models from HuggingFace...[/blue]" )
96- models = client .list_models_from_endpoints (settings .get_all_endpoints ())
102+
103+ if all :
104+ # Show all models, but fetch detailed info for MONAI Bundles to get accurate extension data
105+ console .print ("[yellow]Note: Fetching detailed info for MONAI Bundles to show accurate extension data[/yellow]" )
106+ models = client .list_models_from_endpoints (settings .get_all_endpoints (), fetch_details_for_bundles = True )
107+ else :
108+ # Show only models with TorchScript (.ts) files by default
109+ models = client .list_torchscript_models (settings .get_all_endpoints ())
97110
98111 # Filter for bundles if requested
99112 if bundles_only :
100113 models = [m for m in models if m .is_monai_bundle ]
101114
102- # Filter for tested models if requested
115+ # Filter for verified models if requested
103116 if tested_only :
104- models = [m for m in models if m .model_id in tested_models ]
117+ models = [m for m in models if m .model_id in verified_models ]
105118
106119 # Sort models by name
107120 models .sort (key = lambda m : m .display_name )
108121
109122 # Display results based on format
110123 if format == "table" :
111- _display_table (models , tested_models )
124+ _display_table (models , verified_models )
112125 elif format == "simple" :
113- _display_simple (models , tested_models )
126+ _display_simple (models , verified_models )
114127 elif format == "json" :
115- _display_json (models , tested_models )
128+ _display_json (models , verified_models )
116129
117130 # Summary
118131 bundle_count = sum (1 for m in models if m .is_monai_bundle )
119- tested_count = sum (1 for m in models if m .model_id in tested_models )
132+ verified_count = sum (1 for m in models if m .model_id in verified_models )
120133 console .print (
121- f"\n [green]Total models: { len (models )} (MONAI Bundles: { bundle_count } , Verified: { tested_count } )[/green]"
134+ f"\n [green]Total models: { len (models )} (MONAI Bundles: { bundle_count } , Verified: { verified_count } )[/green]"
122135 )
123136
124137
@@ -225,28 +238,37 @@ def gen(
225238 raise click .Abort () from e
226239
227240
228- def _display_table (models : List [ModelInfo ], tested_models : Set [str ]) -> None :
241+ def _display_table (models : List [ModelInfo ], verified_models : Set [str ]) -> None :
229242 """Display models in a rich table format.
230243
231244 Args:
232245 models: List of ModelInfo objects to display
233- tested_models : Set of tested model IDs
246+ verified_models : Set of verified model IDs
234247 """
235248 table = Table (title = "Available Models" , show_header = True , header_style = "bold magenta" )
236249 table .add_column ("Model ID" , style = "cyan" , width = 40 )
237250 table .add_column ("Name" , style = "white" )
238- table .add_column ("Type " , style = "green" )
251+ table .add_column ("MONAI Bundle " , style = "green" )
239252 table .add_column ("Status" , style = "blue" , width = 10 )
240253 table .add_column ("Downloads" , justify = "right" , style = "yellow" )
241254 table .add_column ("Likes" , justify = "right" , style = "red" )
242255
243256 for model in models :
244- model_type = "[green]MONAI Bundle[/green]" if model .is_monai_bundle else "Model"
245- status = "[bold green]✓ Verified[/bold green]" if model .model_id in tested_models else ""
257+ # MONAI Bundle column logic: "Yes" if is_monai_bundle (has .ts), "No (extension)" otherwise
258+ if model .is_monai_bundle :
259+ bundle_status = "[green]✓ Yes[/green]"
260+ else :
261+ primary_ext = model .primary_extension
262+ if primary_ext :
263+ bundle_status = f"[dim]✗ No ({ primary_ext } )[/dim]"
264+ else :
265+ bundle_status = "[dim]✗ No[/dim]"
266+
267+ status = "[bold green]✓ Verified[/bold green]" if model .model_id in verified_models else ""
246268 table .add_row (
247269 model .model_id ,
248270 model .display_name ,
249- model_type ,
271+ bundle_status ,
250272 status ,
251273 str (model .downloads or "N/A" ),
252274 str (model .likes or "N/A" ),
@@ -255,31 +277,31 @@ def _display_table(models: List[ModelInfo], tested_models: Set[str]) -> None:
255277 console .print (table )
256278
257279
258- def _display_simple (models : List [ModelInfo ], tested_models : Set [str ]) -> None :
280+ def _display_simple (models : List [ModelInfo ], verified_models : Set [str ]) -> None :
259281 """Display models in a simple list format.
260282
261283 Shows each model with emoji indicators:
262284 - 📦 for MONAI Bundle, 📄 for regular model
263- - ✓ for tested models
285+ - ✓ for verified models
264286
265287 Args:
266288 models: List of ModelInfo objects to display
267- tested_models : Set of tested model IDs
289+ verified_models : Set of verified model IDs
268290 """
269291 for model in models :
270292 bundle_marker = "📦" if model .is_monai_bundle else "📄"
271- tested_marker = " ✓" if model .model_id in tested_models else ""
272- console .print (f"{ bundle_marker } { model .model_id } - { model .display_name } { tested_marker } " )
293+ verified_marker = " ✓" if model .model_id in verified_models else ""
294+ console .print (f"{ bundle_marker } { model .model_id } - { model .display_name } { verified_marker } " )
273295
274296
275- def _display_json (models : List [ModelInfo ], tested_models : Set [str ]) -> None :
297+ def _display_json (models : List [ModelInfo ], verified_models : Set [str ]) -> None :
276298 """Display models in JSON format.
277299
278300 Outputs a JSON array of model information suitable for programmatic consumption.
279301
280302 Args:
281303 models: List of ModelInfo objects to display
282- tested_models : Set of tested model IDs
304+ verified_models : Set of verified model IDs
283305 """
284306 import json
285307
@@ -288,7 +310,10 @@ def _display_json(models: List[ModelInfo], tested_models: Set[str]) -> None:
288310 "model_id" : m .model_id ,
289311 "name" : m .display_name ,
290312 "is_monai_bundle" : m .is_monai_bundle ,
291- "is_tested" : m .model_id in tested_models ,
313+ "has_torchscript" : m .has_torchscript ,
314+ "model_extensions" : m .model_extensions ,
315+ "primary_extension" : m .primary_extension ,
316+ "is_verified" : m .model_id in verified_models ,
292317 "downloads" : m .downloads ,
293318 "likes" : m .likes ,
294319 "tags" : m .tags ,
0 commit comments