Skip to content
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

Attempt to use versioned container #537

Merged
merged 1 commit into from
Jan 7, 2025
Merged

Conversation

ericcurtin
Copy link
Collaborator

@ericcurtin ericcurtin commented Jan 5, 2025

Check if it's locally available, then try and pull. Then just use latest if it's not available.

Summary by Sourcery

Enhancements:

  • Attempt to use a versioned container if it exists locally or can be pulled.

Copy link
Contributor

sourcery-ai bot commented Jan 5, 2025

Reviewer's Guide by Sourcery

This pull request introduces versioned containers to improve reproducibility and dependency management. It modifies the model.py and common.py files to attempt using a versioned container if available. If the versioned container image is not found locally, it attempts to pull it. If the pull fails, it defaults to using the "latest" tag.

Sequence diagram for container version resolution

sequenceDiagram
    participant C as Container Manager
    participant M as Model
    participant R as Registry

    M->>C: inspect versioned image
    alt Image exists locally
        C-->>M: Success
    else Image not found locally
        M->>C: pull versioned image
        C->>R: pull image
        alt Pull successful
            R-->>C: Image downloaded
            C-->>M: Success
        else Pull failed
            R-->>C: Error
            C-->>M: Failure
            Note over M: Fallback to latest tag
        end
    end
Loading

Class diagram showing updated Model class

classDiagram
    class Model {
        +remove(args)
        +attempt_to_use_versioned(conman, image, vers, args) bool
        -_image(args) str
        +setup_container(args)
    }
    note for Model "New method attempt_to_use_versioned
handles versioned container resolution"
Loading

State diagram for container version resolution process

stateDiagram-v2
    [*] --> CheckLocal
    CheckLocal --> UseVersioned: Version exists locally
    CheckLocal --> AttemptPull: Version not found
    AttemptPull --> UseVersioned: Pull successful
    AttemptPull --> UseLatest: Pull failed
    UseVersioned --> [*]
    UseLatest --> [*]
Loading

File-Level Changes

Change Details Files
Added logic to attempt using a versioned container image.
  • Added the attempt_to_use_versioned function to check for and pull a versioned container image.
  • Modified the _image function to use the versioned image if available, falling back to the "latest" tag if not.
ramalama/model.py
Modified run_cmd function to handle ignoring all output.
  • Added the ignore_all parameter to the run_cmd function to suppress all output if set.
  • Modified the run_cmd function to use subprocess.DEVNULL for stdout and stderr if ignore_all is True.
ramalama/common.py
Modified default image name.
  • Removed the ":latest" tag from the default image name in the default_image function, allowing the model.py logic to handle versioning.
ramalama/common.py

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.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a 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. You can also use
    this command to specify where the summary should be inserted.

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

Overall Comments:

  • The broad Exception catch in attempt_to_use_versioned could mask important errors. Consider catching specific exceptions (like ContainerError or NetworkError) that you expect might occur.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

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.

ramalama/model.py Show resolved Hide resolved
ramalama/common.py Outdated Show resolved Hide resolved
@ericcurtin ericcurtin force-pushed the versioned-container-images branch from 3da2779 to ba37fbc Compare January 6, 2025 00:01
try:
if run_cmd([conman, "inspect", f"{image}:{vers}"], ignore_all=True, debug=args.debug):
return True
elif run_cmd([conman, "pull", f"{image}:{vers}"], debug=args.debug):
Copy link
Member

Choose a reason for hiding this comment

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

No elif required here, just return it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do!

@rhatdan
Copy link
Member

rhatdan commented Jan 6, 2025

LGTM once tests pass.

@ericcurtin
Copy link
Collaborator Author

ericcurtin commented Jan 6, 2025

Part of me wishes we prepared vLLM and llama.cpp Containerfiles and upstreamed these Containerfiles to both projects specifically, so we would have UBI-based images published by both projects. At least CUDA ones (and maybe ROCm, etc.).

Both projects publish their own images but they are debian/ubuntu-based I believe.

Maybe they would be willing to publish :ubi9-cuda images alongside the debian/ubuntu ones.

@ericcurtin ericcurtin force-pushed the versioned-container-images branch 4 times, most recently from 0448ae7 to ef44bf4 Compare January 7, 2025 13:15
@rhatdan
Copy link
Member

rhatdan commented Jan 7, 2025

Needs a rebase.

@ericcurtin ericcurtin force-pushed the versioned-container-images branch 5 times, most recently from 82a400f to 11b8e48 Compare January 7, 2025 14:40
Check if it's locally available, then try and pull. Then just use
latest if it's not available.

Signed-off-by: Eric Curtin <[email protected]>
@ericcurtin ericcurtin force-pushed the versioned-container-images branch from 11b8e48 to 19500b9 Compare January 7, 2025 16:27
@rhatdan
Copy link
Member

rhatdan commented Jan 7, 2025

LGTM

@rhatdan rhatdan merged commit 4bf31ec into main Jan 7, 2025
11 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.

2 participants