Skip to content

Conversation

vsoch
Copy link
Member

@vsoch vsoch commented Aug 3, 2022

This is a huge PR to replace #567 that will make the default registry remote, and add the concept of a registry backend, either remote (GitHub) or a local filesystem. I've done careful work to ensure all tests try both cases, but likely this will need a lot of manual testing to be double sure I didn't break anything!

vsoch added 11 commits July 19, 2022 17:16
this still needs tests written - I think I will need to make an external
remote registry with some arbitrary change to test, OR just test the
interaction with the remote provider and handle the updates via local
test files

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
I am wondering if the upgrade function should be done between two registries,
where the registry being upgraded is required to be a filesystem?

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 3, 2022

@muffato @marcodelapierre @surak I pulled it off!

@muffato
Copy link
Contributor

muffato commented Aug 7, 2022

Hi @vsoch . That looks very impressive 👏🏼 ! I've started looking at the code, but I haven't run any tests yet. I'll try to get to it this week if that's OK ?

@vsoch
Copy link
Member Author

vsoch commented Aug 7, 2022

Definitely OK by me!

Copy link
Contributor

@muffato muffato left a comment

Choose a reason for hiding this comment

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

Looks very good to me. sync-registry is a great addition, and I think it can simplify our workflow tremendously. But most importantly, the repository feels so clean with the container.yaml out of the way 😌 !

I've tested a few things (installing and adding a container) and left some comments.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 18, 2022

@muffato I've done various tweaks (and ran isort/black) a55c243.

For next steps:

  • I want to add GitLab but we will need a template first. I'm going to make a new issue for this that I will tackle after the initial work here. update, added and done
  • I want to add functionality for the registry file - can you give me the example you were wanting to use (or do we need another remote to be made first?) (done, I made the GitLab registry and could use that).
  • Can you give me the sync commands that borked your registry? I am going to see if I can add more logic to only consider container modules (and a test for it).

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 19, 2022

okay - and got started on creating a GitLab equivalent! https://gitlab.com/singularityhub/shpc-registry supposedly pages take 30 minutes to deploy... so not sure if I did it right yet! I also realized default branches there are "master" so I added a branch arg to the docgen command here.

vsoch added 3 commits August 18, 2022 22:05
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 19, 2022

okay Gitlab registry (and remote here) is added, and I un-broke the CI! 😆

vsoch added 2 commits August 19, 2022 19:24
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 20, 2022

@muffato I've finished 2/3 things we discussed above - creating a GitLab remote (and support for it) and configuring sync from file. The last bullet I'll need some pointers from you for how to reproduce the bugs you saw (and to be sure we test for them!)

@vsoch
Copy link
Member Author

vsoch commented Aug 20, 2022

Okay - I opted for https://docs.python.org/3/library/shutil.html#shutil.copy2 because that also preserves metadata (in addition to data and permissions).

Copy link
Contributor

@muffato muffato left a comment

Choose a reason for hiding this comment

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

Hi. FYI I'm looking at the code that does the copying, to make it exclude .git. I found where the bug is, and I'll submit a PR onto this PR later today

@muffato
Copy link
Contributor

muffato commented Aug 20, 2022

I'm not sure where I'm going with my changes, so best is that I describe what I've noticed.

  • sync_from_remote identifies what needs to be copied by first calling iter_modules (it then calls update_container_module when required).
  • iter_modules calls shpc.utils.recursive_find and then discards the files that start with a dot, therefore allowing the directories that start with a dot.

vsoch added 2 commits August 20, 2022 16:49
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 20, 2022

@muffato give that a shot! I'm going for a run, then probably a break/dinner, I promise I'll be back later tonight after that! 🥑

@muffato
Copy link
Contributor

muffato commented Aug 21, 2022

8739676 made the trick, fantastic ! 💯

I can't find how to do it anymore, but #576 (comment) and #576 (comment) can be marked as resolved 🚀

I think the only things I want to test today are:

  • GitLab remote
  • sync yaml file

@vsoch
Copy link
Member Author

vsoch commented Aug 21, 2022

Sounds good!

Copy link
Contributor

@muffato muffato left a comment

Choose a reason for hiding this comment

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

Hi

The yaml file works great (with that little addition) ! And I've also tested the check for unknown arguments on the command-line: a life saver !

About GitLab:

  • shpc show breaks if the repo is under groups because shpc does org, repo = self.source.split("/")[3:], while gitlab allows groups in between the org and repo name, e.g. https://gitlab.internal.sanger.ac.uk/tol-it/software/shpc-installation.git
  • Once moved to match org, repo, then it fails because I don't have anything under https://$org.gitlab.io/$repo/library.json, and it's due to two things:
    • I haven't set up .gitlab-ci.yml (I guess that's what's needed to generate library.json ?)
    • Even if had it, our "pages" are at https://$org.pages.internal.sanger.ac.uk/$repo_name (I don't know how it looks like with groups !)
  • At least shpc sync-registry works, even with our internal one

Questions:

  • How important is this library.json API ? In case it can't be found, what about taking a temporary local checkout and building a cache from there ?
  • Then, what about ssh support ? If a substitute for library.json can be found, I guess we don't require https any more, and ssh would be just fine (since all git access would be done via git clone)
  • How / where to define the tag/branch and the subdir ? I can see the code supports that, but only the tag option in sync-registry
  • Do you really want to support on-prem installations of gitlab ? and do they all follow this pattern ?

@vsoch
Copy link
Member Author

vsoch commented Aug 21, 2022

@muffato try using my dummy as an example: https://gitlab.com/singularityhub/shpc-registry. That should have the workflow to generate and deploy to pages - I'm kind of a GitLab noob but after that I was able to click pages and make sure my artifact in "public" worked. For the other stuffs I'll take a closer look and make some tweaks tonight, and in the meantime if you want to share the update to match "org" and "repo" I can be sure to have it handy later! We should probably have a fallback for show that checks for the library and then issues an error if it doesn't exist, and tells the user to visit the repository if they want to browse. More specifically:

How important is this library.json API ? In case it can't be found, what about taking a temporary local checkout and building a cache from there ?

I think this is important for quick query - e.g., shpc show. I wouldn't want it to do a clone to tmp every time someone ran that! But as I mentioned above, I think we can add a fallback that tells the user to visit the repository if there is no library.json. The alternative (if it's available without token auth) is to use some GItHub/GitLab API to list the top level contents of the repo (in the same way that we do after we clone).

Then, what about ssh support ? If a substitute for library.json can be found, I guess we don't require https any more, and ssh would be just fine (since all git access would be done via git clone)

We could definitely look into this! My thinking is we should work on this after this PR (which is already very big). If you want to open an issue with some details about how this works / what you want to work we can have it handy for when that time comes.

How / where to define the tag/branch and the subdir ? I can see the code supports that, but only the tag option in sync-registry

Currently it's just via the command line, so you can provide it with or without a file. I think we might honor the branch but I don't recall if we pass forward a subdirectory preference, the reason being we assume a remote registry is going to honor a convention of always having recipes at the root (do you see a use case where this isn't the case?).

Do you really want to support on-prem installations of gitlab ? and do they all follow this pattern ?

I don't know - what do you think? My senses are we should support official Gitlab, and if on-prem isn't too hard, we should strive for that too.

@muffato
Copy link
Contributor

muffato commented Aug 24, 2022

Status update:

  • I could get something to run our GitLab CI, but it's not working properly: it can't find any of the local recipes
  • I've found the URL format of GitLab Pages when there are groups or sub-groups, and can make a PR for that
  • Re. on prem, GitLab Pages can actually be deployed anywhere, it's left to the administrators to decide. shpc can't find this out by itself without a dedicated config option

the reason being we assume a remote registry is going to honor a convention of always having recipes at the root (do you see a use case where this isn't the case?).

The other shpc asset is the general template scripts (i.e. ones that can be shared between recipes and therefore are not in the same directory as container.yaml). Having both the registry and the templates in the same repository can be useful to track things under the same git history

@muffato
Copy link
Contributor

muffato commented Aug 24, 2022

I got the CI to work ! It was doing a pip install of the main branch. Changed it to add/remote-registry

Copy link
Contributor

@muffato muffato left a comment

Choose a reason for hiding this comment

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

I think that's all I wanted to test. I'll create issues with additional features that can be addressed later

Comment on lines 147 to 158
if not self.source.startswith("http"):
self.source = "https://%s" % self.source

# Check for API
org, repo = self.source.split("/")[3:]
gh_pages = "https://%s.%s.io/%s/library.json" % (org, self.provider_name, repo)
response = requests.get(gh_pages)
if response.status_code != 200:
sys.exit(
"Remote %s is not deploying a Registry API. Open a GitHub issue to ask for help."
% self.source
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if not self.source.startswith("http"):
self.source = "https://%s" % self.source
# Check for API
org, repo = self.source.split("/")[3:]
gh_pages = "https://%s.%s.io/%s/library.json" % (org, self.provider_name, repo)
response = requests.get(gh_pages)
if response.status_code != 200:
sys.exit(
"Remote %s is not deploying a Registry API. Open a GitHub issue to ask for help."
% self.source
)
url = self.source
if not url.startswith("http"):
url = "https://%s" % url
if url.endswith(".git"):
url = source[:-4]
# Check for API
url_parts = url.split("/")[3:]
gh_pages = "https://%s.%s.io/%s/library.json" % (url_parts[0], self.provider_name, "/".join(url_parts[1:]))
response = requests.get(gh_pages)
if response.status_code != 200:
sys.exit(
"Remote %s is not deploying a Registry API (%s). Open a GitHub issue to ask for help."
% (self.source, gh_pages)
)

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you walk me through this change? Why wouldn't we want to change the source (for good) with a proper https url?

Copy link
Contributor

@muffato muffato Aug 24, 2022

Choose a reason for hiding this comment

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

About this particular change, I actually don't understand why the source would not start with https:// at this stage, since the constructor checks that and raises an error.
That's why I had suggested to remove it in https://github.com/singularityhub/singularity-hpc/pull/579/files#diff-183e41e47a9fe06125f88dd47d33eb5bc399a6458ad3bc0e8d5c98e422179239L147-L148

Copy link
Member Author

Choose a reason for hiding this comment

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

I did that because a person may just want to specify it as github.com/<org>/<name> . I don't see that the constructor checks and throws an error, it seems to just set it:

self._url = self.source
.

Copy link
Contributor

Choose a reason for hiding this comment

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

The check happens in the super-class

def __init__(self, source, *args, **kwargs):
if not (source.startswith("https://") or os.path.exists(source)):
raise ValueError(
"Registry source must exist on the filesystem or be given as https://."
)
self.source = source

Copy link
Member Author

@vsoch vsoch Aug 24, 2022

Choose a reason for hiding this comment

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

But not to get distracted with this check, which could be argued is redundant (but certainly isn't causing any major issues?) - can you explain the changes in the above? What problem is it fixing? I think we are close and (things look generally ok) and could merge/release soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

The patch is to allow support for "groups" in gitlab, cf your message (#576 (comment)):

and in the meantime if you want to share the update to match "org" and "repo"

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah gotcha, thank you for clarifying! Let me see if I can organize the functions a bit - brb!

Copy link
Member Author

Choose a reason for hiding this comment

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

okay check out 1f29489. !

@muffato
Copy link
Contributor

muffato commented Aug 24, 2022

FYI I will not create an issue to support cloning over ssh, as the only advantage I think it'd bring is being able to clone private repositories. But shpc anyway requires a public library.json, which defeats the purpose of keeping the registry private.

@vsoch
Copy link
Member Author

vsoch commented Aug 24, 2022

@muffato I think we could have support for that still, it just would be a different kind of clone (and show/list would do a directory listing instead of library.json).

@muffato
Copy link
Contributor

muffato commented Aug 24, 2022

🤔 . You also said

I think this is important for quick query - e.g., shpc show. I wouldn't want it to do a clone to tmp every time someone ran that!

I'm confused 😅 !

@vsoch
Copy link
Member Author

vsoch commented Aug 24, 2022

There are two different cases here:

  • Anything with a public GitHub (or GitLab) url should work with show. If pages is available, we expect a library.json.
  • Anything that is private we cannot enforce that expectation (ssh).

It could be the case that a public GitHub/GitLab registry is allowed to not have a library.json, but I'd rather (to start) force people to start with my template to use a (better) practice of having the library easily seen. The reason is because along with the API, it provides a user interface for recipes: https://singularityhub.github.io/shpc-registry/.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch
Copy link
Member Author

vsoch commented Aug 26, 2022

@muffato let me know if you have more questions for the review! Apologies my responses are a bit scattered.

@muffato
Copy link
Contributor

muffato commented Aug 26, 2022

I get from your previous message that you don't see the registry providing a pseudo API and library.json as a hard requirement anymore. So, I can create a ticket about adding support for private repositories (access could be done over https and ssh), and we'll deal with the implications of not having library.json there ?
Apart from that, I think I had tested everything I wanted to test, and I should be able to approve this PR. I'll double-check later today if that's OK ?

@vsoch
Copy link
Member Author

vsoch commented Aug 26, 2022

I get from your previous message that you don't see the registry providing a pseudo API and library.json as a hard requirement anymore. So, I can create a ticket about adding support for private repositories (access could be done over https and ssh), and we'll deal with the implications of not having library.json there ?

Yes absolutely, I do think we should support this - encourage folks to provide the extra metadata but it shouldn't be a hard requirement. Open away!

Apart from that, I think I had tested everything I wanted to test, and I should be able to approve this PR. I'll double-check later today if that's OK ?
Yes totally! I'm in a workday I won't be able to do another pass and/or release until the evening. Thank you @muffato !

Copy link
Contributor

@muffato muffato left a comment

Choose a reason for hiding this comment

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

Can you add to the developer guide instructions for making your own registry ? (especially setting up the CI)


Use the default

TODO WRITE THESE OUT SHOW HOW TO UPDATE
Copy link
Contributor

@muffato muffato Aug 26, 2022

Choose a reason for hiding this comment

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

Is it still TODO ?

Copy link
Member Author

Choose a reason for hiding this comment

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

lol, I think I just totally forget - yes let me add a few lines!

Copy link
Member Author

Choose a reason for hiding this comment

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

See da4c91c !

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
@vsoch vsoch merged commit ce1452d into main Aug 27, 2022
@vsoch vsoch deleted the add/remote-registry branch August 27, 2022 01:34
@muffato
Copy link
Contributor

muffato commented Aug 27, 2022

giphy.gif.mp4

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