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

Extract client code into separate module? #16

Closed
jdolitsky opened this issue Oct 14, 2020 · 10 comments
Closed

Extract client code into separate module? #16

jdolitsky opened this issue Oct 14, 2020 · 10 comments

Comments

@jdolitsky
Copy link

There has been some demand in providing Python-based OCI code for pushing to registries (see https://github.com/deislabs/oras/issues/166)

I see lots of stuff with requests here: https://github.com/vsoch/django-oci/blob/master/tests/test_api.py

What are your thoughts on creating a Python version of Reggie? https://github.com/bloodorangeio/reggie (Note: this is used for dist-spec conformance)

@vsoch
Copy link
Owner

vsoch commented Oct 14, 2020

Sure! That would actually be a lot of fun! It adds an extra dependency and wouldn't be worth it for one repository, but definitely if there are other efforts it would make sense.

Who is reggie?

@jdolitsky
Copy link
Author

Reggie is the patron saint of content distribution

@vsoch
Copy link
Owner

vsoch commented Oct 14, 2020

He must be quite active in his saintly pursuits, nibabel (for reading imaging files like dicom) in Python has a rabbit named reggie, you can see him in the right column here https://nipy.org/nibabel/.

All hail patron saint reggie!

@jdolitsky
Copy link
Author

The unique part w/ that lib is the UX, which allows path substitution. See https://github.com/bloodorangeio/reggie#path-substitutions

Would be cool to see a Python the equivalent of:

req := client.NewRequest(reggie.GET, "/v2/<name>/tags/list",
    reggie.WithName("megacorp/superapp"))

Where user can specify paths containing <name>, <digest>, and <reference>. There are also helpers such as GetRelativeLocation() and GetAbsoluteLocation(), and support for the whole auth dance

@vsoch
Copy link
Owner

vsoch commented Oct 15, 2020

@jdolitsky one more question before I'm ready to go. What are the differences between reggie and oras, do they both aim to (essentially) provide the same interactions? But reggie provides a nicer UI? And with that answer in mind, does it make sense to make a reggie-python or ORAS-python (as was noted in the issue you linked)?

@jdolitsky
Copy link
Author

I think you need both layers. There is somebody saying "I want ORAS in python" (see above) so if you want to address that, great! But ORAS builds on docker/containerd layers that do these transport pieces that work well within the ecosystem but are not OCI-centric (docker-centric). This is why a python oci library would be neat. "oras-py" with identical UX would be also very very neat

@vsoch
Copy link
Owner

vsoch commented Oct 15, 2020

Here’s an idea - what about adding the client to OCI-Python? https://github.com/vsoch/oci-python Right now it’s just the various spec data structures, with the client it would actually be useful (and use those data structures)! And I could bring in the Reggie UI, and even Saint Reggie himself if the intention is for him to be the patron saint, regardless of programming language.

@jdolitsky
Copy link
Author

Didnt know that was a thing. That's perfect 👍

@vsoch
Copy link
Owner

vsoch commented Oct 18, 2020

Hey @jdolitsky ! Okay I have a first draft ready https://vsoch.github.io/oci-python/docs/getting-started#distribution-specification (not release on pypi) and actually I'm going to be working on this repository again to update the test to use it (and make any necessary tweaks). I had a small list of questions for you specific to the implementation - these were quick notes so please let me know if you need more detail for any of them:

The following questions are related to translating the reggie client to python-reggie here for the distribution spec.

  • GetAbsoluteLocation can return nil/None,while Get RelativeLocation returns an empty string. Is this intentional? My thinking is that it would be logical for them to be consistent.
  • For response.Errors it seems to be important that Errors is defined and not empty. Is it okay if Errors is not defined? Wouldn't a response without errors not pass along this attribute? I'd like to return an empty list either way, and the only real check is if the json parses. And even in that case, couldn't a response come back from a registry without any content to parse?
  • is HEAD a valid request for a distribution registry?
  • For the original implementation, it seems to be allowed to create a client with a bad address but for my version I validate this right away so I'm not able to do that full test.

So - my plan is to update the tests using the client to ensure all is good, and then I'll do a quick release to pypi, and then back here for more work on django-oci (we need authentication and other core stuffs).

@vsoch
Copy link
Owner

vsoch commented Oct 19, 2020

I'll open these questions as an issue on the other reggie repo, the (at least initial work) to add and use the client is done here. Thanks for the idea, it was really fun to do!

@vsoch vsoch closed this as completed Oct 19, 2020
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

No branches or pull requests

2 participants