Skip to content

move --image & --keep-groups to run, serve, perplexity, bench commands #1669

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 1 commit into from
Jul 8, 2025

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Jul 7, 2025

This eliminates the need for pulling images by accident when not using containers. Since these commands are only used for container commands, no need for them in other places.

Fixes: #1662

Summary by Sourcery

Restrict image and podman keep-groups options to only containerized commands and update related behavior, documentation, and tests.

Bug Fixes:

  • Prevent accidental image pulls when not using containers by removing global --image and --keep-groups options.

Enhancements:

  • Move --image and --keep-groups arguments into run, serve, perplexity, and bench subcommands instead of the global CLI.
  • Change the info command to derive the container image from the default configuration rather than a global argument.

Documentation:

  • Update manual pages to document --image and --keep-groups only under relevant container commands.

Tests:

  • Adjust the system test to set the image via RAMALAMA_IMAGE and relax the regex to match the new default image source.

Copy link
Contributor

sourcery-ai bot commented Jul 7, 2025

Reviewer's Guide

This PR confines the "--image" and "--keep-groups" options to the container-specific commands (run, serve, perplexity, bench) instead of the global CLI, updates the info command to always resolve the image from configuration, adjusts documentation accordingly, and revises system tests to use the RAMALAMA_IMAGE environment variable for image selection.

File-Level Changes

Change Details Files
Scoped image and keep-groups flags to container commands
  • Removed global parser.add_argument calls for --image and --keep-groups in configure_arguments
  • Suppressed the placeholder --image help entry at the global level
  • Added parser.add_argument definitions for --image and --keep-groups in runtime_options for run, serve, perplexity, bench
ramalama/cli.py
Refactored info_cli to derive image from configuration
  • Replaced use of args.image with accel_image(CONFIG) when building the info output
ramalama/cli.py
Updated command documentation for container flags
  • Added --image and --keep-groups sections to ramalama-bench.1.md, ramalama-perplexity.1.md, ramalama-run.1.md, ramalama-serve.1.md
  • Removed the global --image and --keep-groups sections from ramalama.1.md
docs/ramalama-bench.1.md
docs/ramalama-perplexity.1.md
docs/ramalama-run.1.md
docs/ramalama-serve.1.md
docs/ramalama.1.md
Adjusted system tests for info command image handling
  • Relaxed the Image field regex in 060-info.bats to accept any quay.io/ramalama image
  • Switched from passing --image to setting RAMALAMA_IMAGE env var for info invocations
test/system/060-info.bats

Possibly linked issues


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

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @rhatdan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the command-line interface for the ramalama tool by scoping container-related options to only the commands that utilize containers. This change improves the clarity and usability of the CLI by preventing users from accidentally interacting with container options when not running containerized workloads, and it cleans up the main command's help output.

Highlights

  • CLI Argument Relocation: I've moved the --image and --keep-groups command-line options from the main ramalama command to specific subcommands: run, serve, perplexity, and bench. This ensures these container-specific options are only available where they are relevant.
  • Documentation Updates: I've updated the man pages (.1.md files) for ramalama-bench, ramalama-perplexity, ramalama-run, and ramalama-serve to include the documentation for the newly added --image and --keep-groups options. Conversely, I've removed their documentation from the general ramalama.1.md man page.
  • Internal Argument Parsing Logic: In ramalama/cli.py, I've adjusted the argument parsing. The --image and --keep-groups arguments are now suppressed from the global parser and are instead added dynamically to the parsers for the run, serve, perplexity, and bench commands via the runtime_options function. The info_cli function now directly uses the accel_image(CONFIG) for image information, reflecting that --image is no longer a global argument.
  • Test Suite Adjustments: I've updated the system tests in test/system/060-info.bats to reflect these changes. Specifically, the test for the 'Image' field now uses a more general regex, and the image is passed via the RAMALAMA_IMAGE environment variable instead of the --image CLI flag for the info command, aligning with the new argument structure.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

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 @rhatdan - I've reviewed your changes - here's some feedback:

  • Consider emitting a deprecation warning for the removed global --image/--keep-groups flags rather than silently suppressing them to smooth user migration.
  • The repeated man-page blocks for --image and --keep-groups are duplicated across several docs—consider centralizing or templating that text to avoid drift.
  • Info no longer honors an explicit --image override; you may want to restore support for user-specified images in info rather than always using accel_image(CONFIG).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider emitting a deprecation warning for the removed global --image/--keep-groups flags rather than silently suppressing them to smooth user migration.
- The repeated man-page blocks for --image and --keep-groups are duplicated across several docs—consider centralizing or templating that text to avoid drift.
- Info no longer honors an explicit --image override; you may want to restore support for user-specified images in info rather than always using accel_image(CONFIG).

## Individual Comments

### Comment 1
<location> `docs/ramalama-bench.1.md:52` </location>
<code_context>
 show this help message and exit

+#### **--image**=IMAGE
+OCI container image to run with specified AI model. RamaLama defaults to use
+images based on the accelerator it discovers. For example:
+`quay.io/ramalama/ramalama`. See the table below for all default images.
+The default image tag is based on the minor version of the RamaLama package.
</code_context>

<issue_to_address>
Consider rephrasing 'defaults to use images' for grammatical correctness.

Change to 'RamaLama defaults to using images' or 'RamaLama defaults to images' for better grammar.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
=======
OCI container image to run with specified AI model. RamaLama defaults to using
images based on the accelerator it discovers. For example:
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `docs/ramalama-perplexity.1.md:57` </location>
<code_context>
 show this help message and exit

+#### **--image**=IMAGE
+OCI container image to run with specified AI model. RamaLama defaults to use
+images based on the accelerator it discovers. For example:
+`quay.io/ramalama/ramalama`. See the table below for all default images.
+The default image tag is based on the minor version of the RamaLama package.
</code_context>

<issue_to_address>
Consider rephrasing 'defaults to use images' for grammatical correctness.

Change to 'RamaLama defaults to using images' or 'RamaLama defaults to images' for better grammar.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
=======
OCI container image to run with specified AI model. RamaLama defaults to using
images based on the accelerator it discovers. For example:
>>>>>>> REPLACE

</suggested_fix>

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.

Comment on lines 52 to 53
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Consider rephrasing 'defaults to use images' for grammatical correctness.

Change to 'RamaLama defaults to using images' or 'RamaLama defaults to images' for better grammar.

Suggested change
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
OCI container image to run with specified AI model. RamaLama defaults to using
images based on the accelerator it discovers. For example:

Comment on lines 57 to 58
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (typo): Consider rephrasing 'defaults to use images' for grammatical correctness.

Change to 'RamaLama defaults to using images' or 'RamaLama defaults to images' for better grammar.

Suggested change
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
OCI container image to run with specified AI model. RamaLama defaults to using
images based on the accelerator it discovers. For example:

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request moves the --image and --keep-groups flags from global options to the run, serve, perplexity, and bench subcommands, which is a good refactoring to make the CLI more logical. The implementation looks correct, including updates to tests and documentation. I've found a minor formatting issue in a help string and a copy-paste error in the documentation that should be addressed.

Comment on lines 52 to 56
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
`quay.io/ramalama/ramalama`. See the table below for all default images.
The default image tag is based on the minor version of the RamaLama package.
Version 0.10.0 of RamaLama pulls $IMAGE:0.10 from the quay.io/ramalama OCI repository. The --image option overrides this default.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This documentation for --image appears to be copied from another file and has a couple of issues that could confuse users:

  1. It mentions "See the table below for all default images", but there is no table in this file. This reference is broken. It would be better to refer to the ramalama(1) man page where the table is located.
  2. The sentence "Version 0.10.0 of RamaLama pulls $IMAGE:0.10..." is unclear because $IMAGE is not a defined variable in this context.

This same issue is present in the other new documentation files: docs/ramalama-perplexity.1.md, docs/ramalama-run.1.md, and docs/ramalama-serve.1.md.

Suggested change
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
`quay.io/ramalama/ramalama`. See the table below for all default images.
The default image tag is based on the minor version of the RamaLama package.
Version 0.10.0 of RamaLama pulls $IMAGE:0.10 from the quay.io/ramalama OCI repository. The --image option overrides this default.
OCI container image to run with specified AI model. RamaLama defaults to use
images based on the accelerator it discovers. For example:
`quay.io/ramalama/ramalama`. See `ramalama(1)` for a table of all default images.
The default image tag is based on the minor version of the RamaLama package.
Version 0.10.0 of RamaLama pulls an image with a `:0.10` tag from the quay.io/ramalama OCI repository. The --image option overrides this default.

ramalama/cli.py Outdated
Comment on lines 793 to 790
help="""pass `--group-add keep-groups` to podman, if using podman.
Needed to access gpu on some systems, but has security implications.""",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The help text for --keep-groups has incorrect indentation on the second line. This will cause the help message displayed to the user to have extra leading spaces, which can look unprofessional. The second line of the help string should not be indented relative to the start of the string content on the first line.

Suggested change
help="""pass `--group-add keep-groups` to podman, if using podman.
Needed to access gpu on some systems, but has security implications.""",
help="""pass `--group-add keep-groups` to podman, if using podman.
Needed to access gpu on some systems, but has security implications.""",

@rhatdan
Copy link
Member Author

rhatdan commented Jul 7, 2025

This is a possible breaking change, which is why I kept the hidden --image option on ramalama, I don't think it is worth having a --keep-groups hidden option, since I don't believe many people use it or know about it.

Since these options are only used for container operations, makes little sense to keep them global. So moving them specifically to container operations eliminates the side effect of us pulling an image for commands like ramalama rm, pull rm ...

We could also move the --container and --nocontainer options, and perhaps should.

@rhatdan rhatdan force-pushed the image branch 4 times, most recently from dc2df27 to 384b958 Compare July 8, 2025 10:57
This eliminates the need for pulling images by accident when not
using containers.  Since these commands are only used for container
commands, no need for them in other places.

Fixes: containers#1662

Signed-off-by: Daniel J Walsh <[email protected]>
@bmahabirbu
Copy link
Collaborator

LGTM! Once bat tests are done can merge!

@bmahabirbu
Copy link
Collaborator

Tested works!

@rhatdan rhatdan merged commit 99f56a7 into containers:main Jul 8, 2025
37 checks passed
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.

Notify the user when pulling ramalama container
2 participants