@@ -36,6 +36,20 @@ def _get_upet_repo_files() -> List[str]:
3636 return [f [7 :] for f in repo_files if f .startswith ("models/" )]
3737
3838
39+ def get_available_models () -> List [str ]:
40+ """Get all available base model names from the HuggingFace repository.
41+
42+ :return: Sorted list of base model names (e.g., ["pet-mad", "pet-omat", ...])
43+ """
44+ files = _get_upet_repo_files ()
45+ models = set ()
46+ for f in files :
47+ match = CHECKPOINT_NAME_PATTERN .match (f )
48+ if match :
49+ models .add (match .group ("model" ))
50+ return sorted (models )
51+
52+
3953def get_sizes_for_model (model : str ) -> List [str ]:
4054 """Get all available sizes for a given model from the cached repo files.
4155
@@ -278,6 +292,53 @@ def save_upet(
278292 logging .info (f"Saved UPET model to { output } " )
279293
280294
295+ def list_upet (
296+ * ,
297+ model : Optional [str ] = None ,
298+ size : Optional [str ] = None ,
299+ print_summary : bool = True ,
300+ ) -> List [dict ]:
301+ """List available UPET models, sizes, and versions.
302+
303+ When called without arguments, returns all available model/size/version
304+ combinations. When ``model`` is given, filters to that model. When both
305+ ``model`` and ``size`` are given, filters to that specific combination.
306+
307+ :param model: Base model name (e.g., "pet-mad", "pet-omat"). If ``None``,
308+ lists all available models.
309+ :param size: Model size (e.g., "s", "m", "l"). If ``None`` and ``model`` is
310+ given, lists all sizes for that model.
311+ :param print_summary: Whether to print a human-readable summary to stdout.
312+ Defaults to ``True``.
313+ :return: A list of dictionaries, each with keys ``"model"``, ``"size"``,
314+ and ``"version"``.
315+ """
316+ if model is None :
317+ models = get_available_models ()
318+ else :
319+ models = [model ]
320+
321+ result = []
322+ for m in models :
323+ if size is None :
324+ sizes = get_sizes_for_model (m )
325+ else :
326+ sizes = [size ]
327+ for s in sizes :
328+ for v in get_versions_for_model (m , s ):
329+ result .append ({"model" : m , "size" : s , "version" : str (v )})
330+
331+ if print_summary :
332+ if not result :
333+ print ("No UPET models found." )
334+ else :
335+ print ("Available UPET models:" )
336+ for entry in result :
337+ print (f" - { entry ['model' ]} -{ entry ['size' ]} v{ entry ['version' ]} " )
338+
339+ return result
340+
341+
281342BASE_URL_PET_MAD_DOS = "https://huggingface.co/lab-cosmo/pet-mad-dos/resolve/{tag}/models/pet-mad-dos-{version}.pt"
282343BASE_URL_BANDGAP_MODEL = (
283344 "https://huggingface.co/lab-cosmo/pet-mad-dos/resolve/{tag}/models/bandgap-model.pt"
0 commit comments