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

Add save_to_oci_registry ptyhon client method #800

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

Crazyglue
Copy link
Contributor

Description

This PR aims to add a helper method to the python client to append a set of files to a given oci-compatible container image. In the future this method will be used as a part of the PR found here: #761 which aims to provide yet another helper method that will both upload and register a model to the MR.

With this PR and the one mentioned above, the use case for the client (after training) is to simply call 1 method to both push the newly trained model to a storage location AND register that newly trained model in the MR. Removing a number of manual steps that would have to be done separately as a part of a standard DS flow.

How Has This Been Tested?

Added an E2E test and validated that they run. The E2E test uses a local registry to upload test-images to.

The local environment will need to at a minimum install skopeo on the system (for MacOS and Brew, this means running brew install skopeo).

Merge criteria:

  • All the commits have been signed-off (To pass the DCO check)
  • The commits have meaningful messages; the author will squash them after approval or in case of manual merges will ask to merge with squash.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work.
  • Code changes follow the kubeflow contribution guidelines.

If you have UI changes

  • The developer has added tests or explained why testing cannot be added.
  • Included any necessary screenshots or gifs if it was a UI change.
  • Verify that UI/UX changes conform the UX guidelines for Kubeflow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added as a way to have the e2e tests include image download/upload. A registry is needed to perform the upload step, and so a local registry should be good enough to perform this test.

Comment on lines 139 to 156
if backend == 'skopeo':
from olot.backend.skopeo import is_skopeo, skopeo_pull, skopeo_push

if not is_skopeo():
raise ValueError('skopeo is selected, but it is not present on the machine. Please validate the skopeo cli is installed and available in the PATH')

skopeo_pull(base_image, local_image_path)
oci_layers_on_top(local_image_path, model_files, modelcard)
skopeo_push(dest_dir, oci_ref)

elif backend == 'oras':
from olot.backend.oras_cp import is_oras, oras_pull, oras_push
if not is_oras():
raise ValueError('oras is selected, but it is not present on the machine. Please validate the oras cli is installed and available in the PATH')

oras_pull(base_image, local_image_path)
oci_layers_on_top(local_image_path, model_files, modelcard)
oras_push(local_image_path, oci_ref)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose not to abstract this away into an interface/facade because the steps are very straightforward, and i think it would over-engineer what is effectively calling 3 separate functions.

If olot supports more backends, this will probably need to be refactored to include an interface of some kind.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, but as in #800 (comment)
I would consider passing to a monkeypatched method all params, so that at least we steer users to a provider mechanism of sort

@@ -27,9 +27,11 @@ nest-asyncio = "^1.6.0"
eval-type-backport = "^0.2.0"

huggingface-hub = { version = ">=0.20.1,<0.29.0", optional = true }
olot = { version = "^0.1.2", optional = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is following the same pattern by huggingface-hub above. This particular dependency is optional because if you choose not to use this new "save" method, you would never need this dependency. The README was updated to reflect this

Copy link
Member

Choose a reason for hiding this comment

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

+1

@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch from 40dec90 to 2678e81 Compare February 14, 2025 14:45
Copy link
Member

@tarilabs tarilabs left a comment

Choose a reason for hiding this comment

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

some early comment, thank you @Crazyglue

@@ -27,9 +27,11 @@ nest-asyncio = "^1.6.0"
eval-type-backport = "^0.2.0"

huggingface-hub = { version = ">=0.20.1,<0.29.0", optional = true }
olot = { version = "^0.1.2", optional = true }
Copy link
Member

Choose a reason for hiding this comment

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

+1

@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch from 4554ce2 to 51a7812 Compare February 17, 2025 15:09
Signed-off-by: Eric Dobroveanu <[email protected]>
Signed-off-by: Eric Dobroveanu <[email protected]>
Signed-off-by: Eric Dobroveanu <[email protected]>
@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch 5 times, most recently from b8e68e6 to 9795f0b Compare February 18, 2025 19:07
@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch from 9795f0b to 7fb8bef Compare February 18, 2025 19:28
Signed-off-by: Eric Dobroveanu <[email protected]>
@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch from 7fb8bef to 47a7b88 Compare February 18, 2025 19:29
@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch 2 times, most recently from 3287526 to 37b60e4 Compare February 20, 2025 20:14
@Crazyglue Crazyglue force-pushed the feat/oci-registry-client branch from 37b60e4 to 0fcdde7 Compare February 20, 2025 20:22
Copy link
Contributor

@dhirajsb dhirajsb left a comment

Choose a reason for hiding this comment

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

/lgtm
reviewed at a high level, and I don't see any red flags
@tarilabs will have to approve to merge this initial version

Copy link

@dhirajsb: changing LGTM is restricted to collaborators

In response to this:

/lgtm
reviewed at a high level, and I don't see any red flags
@tarilabs will have to approve to merge this initial version

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dhirajsb
Once this PR has been reviewed and has the lgtm label, please assign rareddy for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Successfully merging this pull request may close these issues.

5 participants