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

Update modules install to support version control #1116

Merged
merged 39 commits into from
Jun 23, 2021

Conversation

ErikDanielsson
Copy link
Contributor

@ErikDanielsson ErikDanielsson commented Jun 16, 2021

Updated nf-core modules install command to accommodate version control for modules, as suggested in #868.

  • New flag --latest installs the latest version of the module.
  • New flag --force overwrites the installed version of the module
  • New option --sha <commit sha> to install specific version of module.
  • questionary select for interactive selection of version

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@codecov
Copy link

codecov bot commented Jun 16, 2021

Codecov Report

Merging #1116 (5b7c79b) into dev (afbed88) will decrease coverage by 0.33%.
The diff coverage is 67.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1116      +/-   ##
==========================================
- Coverage   70.36%   70.02%   -0.34%     
==========================================
  Files          36       38       +2     
  Lines        4545     4748     +203     
==========================================
+ Hits         3198     3325     +127     
- Misses       1347     1423      +76     
Impacted Files Coverage Δ
nf_core/__main__.py 60.85% <57.14%> (-0.21%) ⬇️
nf_core/modules/pipeline_modules.py 69.19% <60.55%> (-10.34%) ⬇️
nf_core/modules/module_utils.py 63.10% <63.10%> (ø)
nf_core/modules/modules_repo.py 90.74% <90.74%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afbed88...5b7c79b. Read the comment docs.

Copy link
Contributor

@KevinMenden KevinMenden left a comment

Choose a reason for hiding this comment

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

Really nice! This looks already pretty good.

The main suggestion I have here is to make the code robuster and surround especially the GitHub API call with a try-except and try to capture any errors that you expect.
You might also do this when reading/writing the json file, just to be on eht esafe side. But definitely for the api call.

@KevinMenden
Copy link
Contributor

Ah and one more thing we should add some logging to inform the user that e.g. a modules.json file has been created.

Co-authored-by: Kevin Menden <kevin.menden@live.com>
Copy link
Contributor

@KevinMenden KevinMenden left a comment

Choose a reason for hiding this comment

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

@ErikDanielsson tested this a bit and I think this is really nice!
So feel free to remove the draft state of that PR.

@KevinMenden KevinMenden marked this pull request as ready for review June 18, 2021 07:41
@KevinMenden
Copy link
Contributor

Okay did it myself 😁

@ErikDanielsson
Copy link
Contributor Author

ErikDanielsson commented Jun 21, 2021

It works for me when trying it on fastqc, which has quite a lot of commits. It crashes when it reaches the end of the commit history though -- will look into that.

@ErikDanielsson
Copy link
Contributor Author

The latest commit addresses that the directory structure of the modules repo was changed with nf-core/modules#80. Hence commits prior to this PR should not be fetched.

Copy link
Contributor

@KevinMenden KevinMenden left a comment

Choose a reason for hiding this comment

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

Okay this looks good to me! 👍
Still need to update the changelog.
I'll approve now but want to test around with it before merging.

Copy link
Contributor

@KevinMenden KevinMenden left a comment

Choose a reason for hiding this comment

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

Really nice, I think we're almost there.
Only a bit of code around force and sha 👍

Comment on lines 382 to 385
@click.option("-t", "--tool", type=str, metavar="<tool> or <tool/subtool>")
def install(ctx, pipeline_dir, tool):
@click.option("-l", "--latest", is_flag=True, default=False, help="Install the latest version of the module")
@click.option("--force", is_flag=True, default=False, help="Force installation of module if module already exists")
def install(ctx, pipeline_dir, tool, latest, force):
Copy link
Contributor

Choose a reason for hiding this comment

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

We need an option to specify the sha here, e.g. -s, --sha as discussed on slack

Comment on lines 170 to 174
if not force:
log.error(
"Module directory already exists but module {} is not present in 'module.json'".format(module_dir)
)
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

Here it would be nice to ask the user whether to overwrite (we should have something similar somewhere else, I think nf-core modules create-test-yml).
Basically a simple question whether to force overwrite and if yes, set 'force' to true.

@ErikDanielsson
Copy link
Contributor Author

ErikDanielsson commented Jun 22, 2021

All options are added now, I think, but they still need thorough testing. I think we will have to refactor pipeline_modules.py into one file per command at some point -- its quite a mess now.

Copy link
Contributor

@KevinMenden KevinMenden left a comment

Choose a reason for hiding this comment

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

Hi @ErikDanielsson , nice work!
Just a couple of minor comments.

I've tested around with it a bit and we need to add the option to update all modules, as we won't include the nf-core modules update command now. But I would actually like to treat this as a separate PR and get this one here merged now, so we can continue working on the features.

So I'm approving it now and then I say we get this one merged in! We might find some other issues along the way but can then still solve them before the release.

Nice work!

nf_core/__main__.py Outdated Show resolved Hide resolved
Comment on lines +107 to +108
if self.latest and self.sha is not None:
log.error("Cannot use '--sha' and '--latest' at the same time!")
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably exit here

nf_core/modules/pipeline_modules.py Outdated Show resolved Hide resolved
@ErikDanielsson ErikDanielsson merged commit d6f616e into nf-core:dev Jun 23, 2021
@ErikDanielsson ErikDanielsson deleted the update-modules-install branch July 25, 2022 09:02
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