From 9898589f12d6faa31eac004828e9c8bda364ceb2 Mon Sep 17 00:00:00 2001 From: Reid <61492567+reidliu41@users.noreply.github.com> Date: Sat, 22 Feb 2025 00:10:34 +0800 Subject: [PATCH] fix: convert back to model descriptor for model in list --downloaded (#1201) # What does this PR do? [Provide a short summary of what this PR does and why. Link to relevant issues if applicable.] Currently , `model` in `--downloaded` just use the directory(already replace `:`), so covert back to descriptor keep the same with ` llama model list`, and remove command also use `descriptor`. ``` before: $ llama model list --downloaded +-------------------------------------+----------+---------------------+ | Model | Size | Modified Time | +-------------------------------------+----------+---------------------+ | Llama3.2-1B-Instruct-int4-qlora-eo8 | 1.53 GB | 2025-02-20 16:32:49 | +-------------------------------------+----------+---------------------+ after: $ llama model list --downloaded +-------------------------------------+----------+---------------------+ | Model | Size | Modified Time | +-------------------------------------+----------+---------------------+ | Llama3.2-1B-Instruct:int4-qlora-eo8 | 1.53 GB | 2025-02-20 16:32:49 | +-------------------------------------+----------+---------------------+ ``` [//]: # (If resolving an issue, uncomment and update the line below) [//]: # (Closes #[issue-number]) ## Test Plan [Describe the tests you ran to verify your changes with result summaries. *Provide clear instructions so the plan can be easily re-executed.*] [//]: # (## Documentation) Signed-off-by: reidliu Co-authored-by: reidliu --- llama_stack/cli/model/list.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llama_stack/cli/model/list.py b/llama_stack/cli/model/list.py index 2f62cb9ce..622a6b4e7 100644 --- a/llama_stack/cli/model/list.py +++ b/llama_stack/cli/model/list.py @@ -19,6 +19,13 @@ def _get_model_size(model_dir): return sum(f.stat().st_size for f in Path(model_dir).rglob("*") if f.is_file()) +def _convert_to_model_descriptor(model): + for m in all_registered_models(): + if model == m.descriptor().replace(":", "-"): + return str(m.descriptor()) + return str(model) + + def _run_model_list_downloaded_cmd() -> None: headers = ["Model", "Size", "Modified Time"] @@ -30,7 +37,7 @@ def _run_model_list_downloaded_cmd() -> None: modified_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(os.path.getmtime(abs_path))) rows.append( [ - model, + _convert_to_model_descriptor(model), model_size, modified_time, ]