-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix up building and pushing OCI Images #492
Conversation
Reviewer's Guide by SourceryThis PR refactors the OCI image building and pushing functionality to improve error handling and provide better separation of concerns. The changes split the build process into distinct steps (build, create manifest, and convert) while also improving the push operation's error messages and handling. Sequence diagram for OCI image build and push processsequenceDiagram
participant User
participant CLI
participant OCI
participant Conman
User->>CLI: push_cli(args)
CLI->>OCI: New(tgt, args)
OCI->>OCI: push(source, args)
alt Source is not target
OCI->>OCI: _convert(source, target, args)
OCI->>OCI: _build(source, target, args)
OCI->>Conman: build image
Conman-->>OCI: imageid
OCI->>OCI: _create_manifest(target, imageid, args)
OCI->>Conman: create manifest
OCI->>Conman: add image to manifest
end
OCI->>Conman: push image
Conman-->>OCI: success or error
OCI-->>CLI: success or error
CLI-->>User: success or error
Updated class diagram for OCI classclassDiagram
class OCI {
-conman
-model
+push(source, args)
+pull(args)
-_build(source, target, args) : string
-_create_manifest(target, imageid, args)
-_convert(source, target, args)
}
note for OCI "Refactored to separate build, create manifest, and convert steps"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this 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:
Overall Comments:
- Consider using proper logging instead of print statements for better operability and consistency with library practices
- The error handling in _convert() could be more specific - catching all CalledProcessError instances might mask important issues
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ramalama/oci.py
Outdated
except subprocess.CalledProcessError as e: | ||
pass | ||
imageid = self._build(source, target, args) | ||
imageid = self._create_manifest(target, imageid, args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): The _create_manifest method doesn't return a value, making this assignment incorrect
2a83126
to
3921547
Compare
@nalind PTAL |
ramalama/oci.py
Outdated
cmd_args = [ | ||
self.conman, | ||
"manifest", | ||
"create", | ||
"--annotation", | ||
f"{annotations.AnnotationModel}=true", | ||
"--annotation", | ||
f"{ocilabeltype}=''", | ||
"--annotation", | ||
f"{annotations.AnnotationTitle}=args.SOURCE", | ||
target, | ||
] | ||
run_cmd(cmd_args, stdout=None, debug=args.debug) | ||
run_cmd([self.conman, "manifest", "add", target, imageid], stdout=None, debug=args.debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/should we set the artifact-type here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably, one issue I am having is Docker support for this stuff kind of sucks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I will just list all manifest lists as AI Models via ramalama list when using Docker, and then I can handle annotations differently with Podman.
2cd7616
to
a2eadee
Compare
With the new functionality we have to force the use of podman 5.0 for creation of OCI Images. Anything less is not working properly. This means we need Ubuntu 24.10 or newer, which kind of stinks. |
b77e10f
to
34af17e
Compare
@ericcurtin @saschagrunert @lsm5 I am thinking the tests are never running because github can not find VMs with the newer version of Ubuntu on it. The issue I have is that the features added in this PR require a newer version of Podman to run "Podman 5." and ubuntu 24.04 only has Podman 4.9 I can make RamaLama work with the Docker path for Podman < 5.0 but we will not end up with annotations in the OCI images. |
Yup, that's where testing-farm / TMT work much better. You get the latest fedora and centos OOTB and can be triggered via packit. I see there's a testing-farm job for centos-stream already. RE: pushing images, IIUC, tmt folks are working on secrets handling feature, so if pushing can be handled separately, TMT should be able to handle everything else. |
NVM, I see there are other testing-farm jobs already. Let me check with testing-farm people about latest on secrets support. |
secrets support seems to be implemented in testing-farm but not yet deployed. https://issues.redhat.com/browse/TFT-2472 . So, I guess hopefully soon. |
be65b97
to
461cb2e
Compare
@@ -19,7 +19,7 @@ Running in containers eliminates the need for users to configure the host system | |||
|
|||
RamaLama pulls AI Models from model registries. Starting a chatbot or a rest API service from a simple single command. Models are treated similarly to how Podman and Docker treat container images. | |||
|
|||
When both Podman and Docker are installed, RamaLama defaults to Podman, The `RAMALAMA_CONTAINER_ENGINE=docker` environment variable can override this behavior. When neither are installed RamaLama attempts to run the model with software on the local system. | |||
When both Podman and Docker are installed, RamaLama defaults to Podman, The `RAMALAMA_CONTAINER_ENGINE=docker` environment variable can override this behaviour. When neither are installed RamaLama attempts to run the model with software on the local system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both are correct depending on where you are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I've noticed this a few times, UK Vs US English. IMO just merge, because both are correct !
ramalama/oci.py
Outdated
return imageid | ||
|
||
def tag(self, imageid, target, args): | ||
# Create manifest list for target with imageid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy/pasted comment?
This allows us to assign annotations to help identify the model. Pull in annotations for the OCI model specification defined in https://github.com/CloudNativeAI/model-spec Then make all of the commands handle models stored in manifest list as well as images. Fix up building and pushing OCI Images Signed-off-by: Daniel J Walsh <[email protected]>
Summary by Sourcery
Refactor the OCI image building and pushing process to separate the build and manifest creation steps, and fix the push command to handle image names correctly.
Bug Fixes:
Enhancements: