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 nf-core subworkflows update command #2019

Merged
merged 37 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3467f58
first refactoring of update commands
mirpedrol Nov 10, 2022
bde678c
refactor components update
mirpedrol Nov 10, 2022
c8f2494
more refactoring of update command
mirpedrol Nov 11, 2022
f29249c
update changelog
mirpedrol Nov 11, 2022
bf0fc03
Merge branch 'dev' of https://github.com/nf-core/tools into subworkfl…
mirpedrol Nov 11, 2022
3376ed2
add subworkflows update command to main
mirpedrol Nov 11, 2022
bf1eb28
update modules and subworkflows recursively
mirpedrol Nov 11, 2022
6f335f3
add silent and updated arguments and add prompt
mirpedrol Nov 11, 2022
03f5cdb
add recursivity and warnings also for show diff and add diff to file
mirpedrol Nov 11, 2022
8418690
handle update all
mirpedrol Nov 11, 2022
370c6cb
don't prompt warning if update all
mirpedrol Nov 11, 2022
80fd5f6
run black
mirpedrol Nov 14, 2022
c99f34f
take into account different repos
mirpedrol Nov 14, 2022
615b975
add argument to update recursively without prompts
mirpedrol Nov 14, 2022
544a4ff
remove print
mirpedrol Nov 14, 2022
57750dc
Merge branch 'dev' of https://github.com/nf-core/tools into subworkfl…
mirpedrol Nov 14, 2022
5874a0b
merge from dev
mirpedrol Nov 14, 2022
6a8af3d
fix typo and modules.json update when new component type
mirpedrol Nov 14, 2022
7f69ac3
remove duplicated sw install objects
mirpedrol Nov 14, 2022
4fd9b8c
add tests for subworkflows update
mirpedrol Nov 14, 2022
30f2c07
all subworkflows tests pass
mirpedrol Nov 14, 2022
3e6660e
run black
mirpedrol Nov 14, 2022
98ffb73
Apply suggestions from code review
mirpedrol Nov 16, 2022
7a01132
Merge branch 'dev' into subworkflowsupdate
mirpedrol Nov 16, 2022
449885f
add command to rich-click
mirpedrol Nov 16, 2022
9383c77
add default to questionary.select
mirpedrol Nov 16, 2022
33ef4b6
change --recursive by --update-deps
mirpedrol Nov 16, 2022
637a036
fix lint mess
mirpedrol Nov 16, 2022
0cd4996
only warn about other modules/subworkflows to update if there are some
mirpedrol Nov 16, 2022
6b311cd
change sw_install by subworkflow_install
mirpedrol Nov 16, 2022
166ad3e
modify wrong variable names
mirpedrol Nov 16, 2022
cf31aab
improve error message
mirpedrol Nov 16, 2022
dfedafb
Merge branch 'subworkflowsupdate' of https://github.com/mirpedrol/too…
mirpedrol Nov 16, 2022
5c51822
[automated] Fix code linting
nf-core-bot Nov 16, 2022
2e07990
revert suggestion that makes tests fail
mirpedrol Nov 16, 2022
e489008
Merge branch 'subworkflowsupdate' of https://github.com/mirpedrol/too…
mirpedrol Nov 16, 2022
e1e0fdc
Merge branch 'dev' into subworkflowsupdate
mirpedrol Nov 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- `check_up_to_date()` function from `modules_json` also checks for subworkflows.
- Update subworkflows install so it installs also imported modules and subworkflows ([#1904](https://github.com/nf-core/tools/pull/1904))
- Function create() from modules_json.py adds also subworkflows to modules.json file ([#2005](https://github.com/nf-core/tools/pull/2005))
- Add `nf-core subworkflows update` command ([#2019](https://github.com/nf-core/tools/pull/2019))

## [v2.6 - Tin Octopus](https://github.com/nf-core/tools/releases/tag/2.6) - [2022-10-04]

Expand Down
77 changes: 75 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"nf-core subworkflows": [
{
"name": "For pipelines",
"commands": ["list", "install"],
"commands": ["list", "install", "update"],
},
{
"name": "Developing new subworkflows",
Expand Down Expand Up @@ -554,7 +554,14 @@ def install(ctx, tool, dir, prompt, force, sha):
default=None,
help="Save diffs to a file instead of updating in place",
)
def update(ctx, tool, dir, force, prompt, sha, all, preview, save_diff):
@click.option(
"-u",
"--update-deps",
is_flag=True,
default=False,
help="Automatically update all linked modules and subworkflows without asking for confirmation",
)
def update(ctx, tool, dir, force, prompt, sha, all, preview, save_diff, update_deps):
"""
Update DSL2 modules within a pipeline.

Expand All @@ -569,6 +576,7 @@ def update(ctx, tool, dir, force, prompt, sha, all, preview, save_diff):
all,
preview,
save_diff,
update_deps,
ctx.obj["modules_repo_url"],
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
Expand Down Expand Up @@ -1055,6 +1063,71 @@ def local(ctx, keywords, json, dir): # pylint: disable=redefined-builtin
sys.exit(1)


# nf-core subworkflows update
@subworkflows.command()
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.option(
"-d",
"--dir",
type=click.Path(exists=True),
default=".",
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
)
@click.option("-f", "--force", is_flag=True, default=False, help="Force update of subworkflow")
@click.option("-p", "--prompt", is_flag=True, default=False, help="Prompt for the version of the subworkflow")
@click.option("-s", "--sha", type=str, metavar="<commit sha>", help="Install subworkflow at commit SHA")
@click.option("-a", "--all", is_flag=True, default=False, help="Update all subworkflow installed in pipeline")
@click.option(
"-x/-y",
"--preview/--no-preview",
is_flag=True,
default=None,
help="Preview / no preview of changes before applying",
)
@click.option(
"-D",
"--save-diff",
type=str,
metavar="<filename>",
default=None,
help="Save diffs to a file instead of updating in place",
)
@click.option(
"-u",
"--update-deps",
is_flag=True,
default=False,
help="Automatically update all linked modules and subworkflows without asking for confirmation",
)
def update(ctx, subworkflow, dir, force, prompt, sha, all, preview, save_diff, update_deps):
"""
Update DSL2 subworkflow within a pipeline.

Fetches and updates subworkflow files from a remote repo e.g. nf-core/modules.
"""
try:
subworkflow_install = nf_core.subworkflows.SubworkflowUpdate(
dir,
force,
prompt,
sha,
all,
preview,
save_diff,
update_deps,
ctx.obj["modules_repo_url"],
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
)
exit_status = subworkflow_install.update(subworkflow)
if not exit_status and all:
sys.exit(1)
except (UserWarning, LookupError) as e:
log.error(e)
sys.exit(1)


# nf-core schema subcommands
@nf_core_cli.group()
def schema():
Expand Down
Loading