-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Various wrapper scripts improvement #548
Conversation
@muffato bravo! This is seriously beautiful code, it's a huge improvement over the current design! Let me respond with a few thoughts and suggestions.
Could there be a case where there is a common alias and the template script is defined and it is accidentally used? It sounds like you are relying on the container.yaml for the customization, and I'm wondering if we need to put our heads together and think about how this could better be controlled. E.g., is this something that would make sense to define for a view? Should there be an install flag that is a one off "use this wrapper script for this alias?" or some kind of customization file we allow to apply? I think the changes here are good/needed and let's keep thinking about this case of wanting not just customizations for a group of containers, but for a specific container.
Yes I like this design much better.
Will there be an error if something is not? Or more generally, do we have a way to enforce what is needed and alert the user if something is missing?
Yes indeed - this custom format is mapped into the same alias structure (but has more metadata). For your use case, is the wrapper something you think should be added to the registry (and thus added to this alias options section) or it's a one off for your specific cluster? If the latter (to go back to my comment above) I wonder how this could be an easy workflow. Right now you are saying:
Or if it's the case that it's a general script that could be contributed, should we have the wrapper aliases be a different alias? E.g., for your example: aliases:
longranger: /usr/local/bin/longranger
singularity_scripts:
longranger-lsf: singularity_with_lsf.sh Or something of that nature? I could imagine something like: aliases:
- name: longranger-lsf
singularity_script: singularity_with_lsf.sh
description: This is the longranger command as a wrapper intended for running with lsf And that way we could package a bunch of wrapper scripts with a container (for different scenarios) that would be installed, but sort of optional to use. Or maybe we could allow the person to skip aliases, e.g.: $ shpc install <module> --skip-alias longranger-lsf If they have strong feelings about not including something :) But it's a fairly small addition so (personally speaking) I wouldn't have issue. And I haven't thought this out fully yet, but if there is some case where you want to apply a wrapper script more globally to all modules in a view, we could have some way to do that. Or perhaps in the case you don't want to edit the container.yaml but you do want a wrapper: $ shpc install <module> --wrap longranger singularity_with_lsf.sh The above would:
The issue there would be reproducibility - e.g., if your install tree blows up I hope you saved all the commands :) So overall I think let's focus on the following:
|
TODO list:
|
I will be able to review again tomorrow! |
…ontainer technologies
Only use WrapperScript - no more subclasses.
- Don't restrict user-defined global templates to be named singularity.sh or docker.sh as in shpc's default template directory - Properly defined the search path based on all available template directories - Minor bugfix: do not search the templates in the current working directory
Co-authored-by: Matthieu Muffato <mm49@sanger.ac.uk> Co-authored-by: Vanessasaurus <814322+vsoch@users.noreply.github.com>
…rather than hijacking the singularity_scripts section
and returns where to find it
… path, from the one that finds the template file
Hi @vsoch . I need a couple of pointers to add the unit tests:
Matthieu |
Looks like pytest was running on circle, and stopped at some point (I don’t see it running recently). If you want to take a shot at adding to a GitHub recipe go for it (maybe main.yaml) otherwise I can get this added back asap. singularity-hpc/.circleci/config.yml Line 98 in eaf978c
And then for test data just add to an appropriate test data folder. And see this example singularity-hpc/shpc/tests/helpers.py Line 36 in eaf978c
I’ll take a look into circle soon! |
woohoo the circle tests ran! |
@muffato I have some nits above, but it's up to you if you want to change them - I'm happy with the current PR and ready to merge! Let me know your preference. |
Then we're good to go ! |
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.
😎🥳🎉
Hi @vsoch
First of all, let me explain why I'm making this pull-request. I've got a software that necessitates a different wrapper script than the default
singularity.sh
, and I expect that other software will require the same change. Therefore, instead of defining those at the container level (hardcoding the tool / command-line parameters), I would like to save the alternativesingularity.sh
wrapper scripts in a central location. shpc currently only allows a single template per container technology, so there isn't really room for that.The purpose of this PR is therefore to allow defining alternative template scripts that can be selected for different tools. I hijack the
singularity_scripts
directive for this. If an entry insingularity_scripts:
corresponds to an alias listed inaliases:
, then the script is used instead of the defaultsingularity.sh
. The template scripts are searched 1) in thecontainer.yaml
directory, 2) the user-defined global template directory, 3) shpc's own global template directory.For instance, in
container.yaml
I haveand
singularity_with_lsf.sh
lives in the global template directory I've defined inshpc/settings.yml
underwrapper_scripts.templates
. Importantly it requires variables such asalias.command
, etc, to be defined, unlike the usualsingularity_scripts
.I've realised after having written the code that the
aliases
section has a "long" form where aliases can be defined like this:and I think I would now rather add an option there such
singularity_template: singularity_with_lsf.sh
instead of hijackingsingularity_scripts
.At the same time, I've done a few modifications to the way the search path for templates is defined, so that files are not searched in the current directory.
I also removed the constraint that
podman.sh
scripts can't be used (they were turned todocker.sh
by the code). If the user wants to name their template scriptpodman.sh
, why not allow it ?The PR also includes a couple of minor changes in container/{docker,podman}.py to improve how the classes are connected.
Best,
Matthieu