Skip to content

Add --all option to ramalama ls #1528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2025

Conversation

engelmi
Copy link
Member

@engelmi engelmi commented Jun 14, 2025

Relates to: #1278

By default, ramalama ls should not display partially downloaded AI Models. In order to enable users to view all models, the new option --all for the ls command has been introduced.

Summary by Sourcery

Add an --all flag to ramalama ls/list to show partially downloaded models (excluded by default), annotate them in the output, and update documentation and model-store logic accordingly.

New Features:

  • Add --all option to the list (ls) command to include partially downloaded AI models
  • Annotate partially downloaded models with a “(partial)” suffix in the output

Enhancements:

  • Exclude partially downloaded models from listing by default
  • Streamline partial download detection logic in the model store

Documentation:

  • Document the --all option in the CLI manual and update listing examples

Relates to: containers#1278

By default, ramalama ls should not display partially downloaded
AI Models. In order to enable users to view all models, the new
option --all for the ls command has been introduced.

Signed-off-by: Michael Engel <[email protected]>
Copy link
Contributor

sourcery-ai bot commented Jun 14, 2025

Reviewer's Guide

Introduces a new --all flag to the ramalama ls command, altering the CLI parser, listing logic, model store detection, and documentation so that partially downloaded models are hidden by default but can be included and labeled when requested.

Sequence Diagram for ramalama ls (Default Behavior)

sequenceDiagram
    actor User
    participant CLI
    participant ListFunc as "_list_models_from_store(args)"
    participant Store as "GlobalModelStore"

    User->>CLI: ramalama ls
    CLI->>ListFunc: Invoke with args.all = false
    ListFunc->>Store: list_models()
    Store-->>ListFunc: models (with ModelFile.is_partial info)
    ListFunc->>ListFunc: Filter: remove model if model.is_partial == true
    ListFunc-->>CLI: Filtered list of models (names unchanged)
    CLI-->>User: Display non-partial models
Loading

Sequence Diagram for ramalama ls --all

sequenceDiagram
    actor User
    participant CLI
    participant ListFunc as "_list_models_from_store(args)"
    participant Store as "GlobalModelStore"

    User->>CLI: ramalama ls --all
    CLI->>ListFunc: Invoke with args.all = true
    ListFunc->>Store: list_models()
    Store-->>ListFunc: models (with ModelFile.is_partial info)
    ListFunc->>ListFunc: Format names: append " (partial)" if model.is_partial == true
    ListFunc-->>CLI: Full list of models (partial models suffixed)
    CLI-->>User: Display all models (partial ones marked)
Loading

Class Diagram: Changes for ramalama ls --all Option

classDiagram
    direction LR
    class ListCommandParser {
      <<CLI Argument Parser for 'ls'>>
      +add_argument(name="--all", dest="all", action="store_true", help="include partially downloaded AI Models")
      +add_argument(name="--json", dest="json", action="store_true")
      +add_argument(name="-n", alias="--noheading", dest="noheading", action="store_true")
    }
    class ParsedArgs {
      +all: bool
      +json: bool
      +noheading: bool
      +store: str
      +engine: str
      +container: bool
    }
    ListCommandParser ..> ParsedArgs : Creates
    class CliModule {
      <<ramalama.cli>>
      +_list_models_from_store(args: ParsedArgs) List~ModelDisplayInfo~
    }
    class ModelStoreModule {
      <<ramalama.model_store>>
      +GlobalModelStore
    }
    class GlobalModelStore {
      +list_models(engine: str, show_container: bool) Map~String, List~ModelFile~~
    }
    class ModelFile {
      +is_partial: bool
    }
    class ModelDisplayInfo {
      +name: str
      +modified: str
      +size: float
    }
    CliModule ..> ParsedArgs : uses
    CliModule ..> GlobalModelStore : uses
    GlobalModelStore ..> ModelFile : produces
    CliModule ..> ModelFile : processes
    CliModule ..> ModelDisplayInfo : creates
Loading

File-Level Changes

Change Details Files
Extended CLI to support an --all flag
  • Added --all argument to list_parser
  • Updated help text to note partial exclusion by default
ramalama/cli.py
Adjusted listing logic to filter and label partial downloads
  • Computed is_partially_downloaded for each model
  • Skipped models when partial and --all is not set
  • Appended “(partial)” suffix to model names when appropriate
ramalama/cli.py
Simplified partial detection in ModelStore
  • Removed redundant filename check
  • Set is_partially_downloaded directly when partial file exists
ramalama/model_store.py
Updated manpage with --all option and example
  • Documented --all flag in OPTIONS section
  • Adjusted output example to show “(partial)” suffix
docs/ramalama-list.1.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @engelmi - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ericcurtin
Copy link
Member

Another weird thing about ramalama ls recently is it seems to show directories for multi-modal or multi-file models, which doesn't make much sense, i.e.:

$ bin/ramalama ls
NAME                                                                              MODIFIED    SIZE
hf://ggml-org/gemma-3-1b-it-GGUF/gemma-3-1b-it-Q4_K_M.gguf                        3 days ago  15.05 MB
hf://ggml-org/SmolVLM2-2.2B-Instruct-GGUF/SmolVLM2-2.2B-Instruct-Q8_0.gguf        1 day ago   1.8 GB
hf://ggml-org/SmolVLM2-2.2B-Instruct-GGUF/mmproj-SmolVLM2-2.2B-Instruct-Q8_0.gguf 1 day ago   565.07 MB
hf://ggml-org/gemma-3-4b-it-GGUF                                                  2 days ago  119.26 MB
hf://ggml-org/gemma-3-4b-it-GGUF/mmproj-model-f16.gguf                            1 month ago 811.82 MB
hf://ggml-org/gemma-3-4b-it-GGUF/gemma-3-4b-it-f16.gguf                           1 month ago 7.23 GB
hf://ggml-org/SmolVLM-500M-Instruct-GGUF                                          3 weeks ago 520.32 MB
hf://ggml-org/SmolVLM-500M-Instruct-GGUF/mmproj-SmolVLM-500M-Instruct-Q8_0.gguf   1 month ago 103.74 MB
hf://ggml-org/SmolVLM-500M-Instruct-GGUF/SmolVLM-500M-Instruct-Q8_0.gguf          1 month ago 416.57 MB
ollama://llama3/llama3:latest                                                     3 weeks ago 4.34 GB
ollama://granite3.1-dense/granite3.1-dense:latest                                 1 month ago 4.65 GB
ollama://qwen3/qwen3:latest                                                       2 days ago  124.84 MB
ollama://tinyllama/tinyllama:latest                                               1 month ago 608.16 MB
ollama://smollm/smollm:135m                                                       3 weeks ago 87.48 MB
ollama://granite3-moe/granite3-moe:latest                                         1 month ago 783.77 MB

@engelmi
Copy link
Member Author

engelmi commented Jun 14, 2025

Another weird thing about ramalama ls recently is it seems to show directories for multi-modal or multi-file models, which doesn't make much sense, i.e.:

I'll have a look 👀
And open another PR to fix this.

@ericcurtin ericcurtin merged commit 7a2c304 into containers:main Jun 14, 2025
15 checks passed
@engelmi
Copy link
Member Author

engelmi commented Jun 14, 2025

Another weird thing about ramalama ls recently is it seems to show directories for multi-modal or multi-file models, which doesn't make much sense, i.e.:

I'll have a look 👀 And open another PR to fix this.

I couldn't reproduce the issue @ericcurtin
I tried to checkout the multi-model model gemma-3-4b-it-GGUF and ran:

ramalama pull hf://ggml-org/gemma-3-4b-it-GGUF

A subsequent ls looked like this:

$ ramalama ls
hf://ggml-org/gemma-3-4b-it-GGUF                                                 2 minutes ago 3.11 GB  
url://huggingface.co/mradermacher/SmolLM-135M-GGUF/SmolLM-135M.IQ3_M.gguf:main   1 month ago   86.03 MB

Looking at your output:

hf://ggml-org/gemma-3-4b-it-GGUF                                                  2 days ago  119.26 MB
hf://ggml-org/gemma-3-4b-it-GGUF/mmproj-model-f16.gguf                            1 month ago 811.82 MB
hf://ggml-org/gemma-3-4b-it-GGUF/gemma-3-4b-it-f16.gguf                           1 month ago 7.23 GB

it seems you have a different LLM model gemma-3-4b-it-f16.gguf, while I have gemma-3-4b-it-Q4_K_M.gguf. The overall size of hf://ggml-org/gemma-3-4b-it-GGUF is also off with 119.26MB.

Could you run ramalama ls again with the changes from this PR? @ericcurtin

@ericcurtin
Copy link
Member

I'll clean up my model store and ignore it for now @engelmi there's been a lot of changes recently. Who knows at this point...

@ericcurtin
Copy link
Member

Here's the output with the --all:

NAME                                                                              MODIFIED    SIZE
hf://ggml-org/gemma-3-1b-it-GGUF/gemma-3-1b-it-Q4_K_M.gguf (partial)              3 days ago  15.05 MB
hf://ggml-org/SmolVLM2-2.2B-Instruct-GGUF/SmolVLM2-2.2B-Instruct-Q8_0.gguf        1 day ago   1.8 GB
hf://ggml-org/SmolVLM2-2.2B-Instruct-GGUF/mmproj-SmolVLM2-2.2B-Instruct-Q8_0.gguf 1 day ago   565.07 MB
hf://ggml-org/gemma-3-4b-it-GGUF (partial)                                        2 days ago  119.26 MB
hf://ggml-org/gemma-3-4b-it-GGUF/mmproj-model-f16.gguf                            1 month ago 811.82 MB
hf://ggml-org/gemma-3-4b-it-GGUF/gemma-3-4b-it-f16.gguf                           1 month ago 7.23 GB
hf://ggml-org/SmolVLM-500M-Instruct-GGUF                                          3 weeks ago 520.32 MB
hf://ggml-org/SmolVLM-500M-Instruct-GGUF/mmproj-SmolVLM-500M-Instruct-Q8_0.gguf   1 month ago 103.74 MB
hf://ggml-org/SmolVLM-500M-Instruct-GGUF/SmolVLM-500M-Instruct-Q8_0.gguf          1 month ago 416.57 MB
ollama://llama3/llama3:latest                                                     3 weeks ago 4.34 GB
ollama://granite3.1-dense/granite3.1-dense:latest                                 1 month ago 4.65 GB
ollama://qwen3/qwen3:latest (partial)                                             2 days ago  124.84 MB
ollama://tinyllama/tinyllama:latest                                               1 month ago 608.16 MB
ollama://smollm/smollm:135m                                                       3 weeks ago 87.48 MB
ollama://granite3-moe/granite3-moe:latest                                         1 month ago 783.77 MB

@engelmi
Copy link
Member Author

engelmi commented Jun 14, 2025

I'll clean up my model store and ignore it for now @engelmi there's been a lot of changes recently. Who knows at this point...

Fair point. Please let me know when the issue persists :)

Note: Based on the --all output is really seems related to some inconsistency due to the many changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants