Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -95,6 +95,7 @@
- update test to new upstream subworkflow structure ([#4038](https://github.com/nf-core/tools/pull/4038))
- Fix lint: preserve underscores for subworkflow includes via full path ([#4074](https://github.com/nf-core/tools/pull/4074))
- update modules and subworkflows in template ([#4077](https://github.com/nf-core/tools/pull/4077))
- add `--force` parameter to `modules remove` and `subworkflow remove` ([#4213](https://github.com/nf-core/tools/pull/4213))

### Template

Expand Down
22 changes: 18 additions & 4 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,11 +1130,18 @@ def command_modules_patch(ctx, tool, directory, remove):
default=".",
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
)
def command_modules_remove(ctx, directory, tool):
@click.option(
"-f",
"--force",
is_flag=True,
default=False,
help="Force removal of the module, even if it is included in the pipeline.",
)
def command_modules_remove(ctx, directory, tool, force):
"""
Remove a module from a pipeline.
"""
modules_remove(ctx, directory, tool)
modules_remove(ctx, directory, tool, force)


# nf-core modules create
Expand Down Expand Up @@ -1789,11 +1796,18 @@ def subworkflows_patch(ctx, subworkflow, directory, remove):
default=".",
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
)
def command_subworkflows_remove(ctx, directory, subworkflow):
@click.option(
"-f",
"--force",
is_flag=True,
default=False,
help="Force removal of the subworkflow, even if it is included in the pipeline.",
)
def command_subworkflows_remove(ctx, directory, subworkflow, force):
"""
Remove a subworkflow from a pipeline.
"""
subworkflows_remove(ctx, directory, subworkflow)
subworkflows_remove(ctx, directory, subworkflow, force)


# nf-core subworkflows update
Expand Down
4 changes: 2 additions & 2 deletions nf_core/commands_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def modules_patch(ctx, tool, directory, remove):
sys.exit(1)


def modules_remove(ctx, directory, tool):
def modules_remove(ctx, directory, tool, force):
"""
Remove a module from a pipeline.
"""
Expand All @@ -156,7 +156,7 @@ def modules_remove(ctx, directory, tool):
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
)
module_remove.remove(tool)
module_remove.remove(tool, force=force)
except (UserWarning, LookupError) as e:
log.critical(e)
sys.exit(1)
Expand Down
4 changes: 2 additions & 2 deletions nf_core/commands_subworkflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def subworkflows_install(ctx, subworkflow, directory, prompt, force, sha):
sys.exit(1)


def subworkflows_remove(ctx, directory, subworkflow):
def subworkflows_remove(ctx, directory, subworkflow, force):
"""
Remove a subworkflow from a pipeline.
"""
Expand All @@ -216,7 +216,7 @@ def subworkflows_remove(ctx, directory, subworkflow):
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
)
module_remove.remove(subworkflow)
module_remove.remove(subworkflow, force=force)
except (UserWarning, LookupError) as e:
log.critical(e)
sys.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion nf_core/components/components_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[
"""
include_stmts: dict[str, list[dict[str, int | str]]] = {}
if self.repo_type == "pipeline":
workflow_files = Path(self.directory, "workflows").glob("*.nf")
workflow_files = Path(self.directory, "workflows").rglob("*.nf")
for workflow_file in workflow_files:
with open(workflow_file) as fh, mmap.mmap(fh.fileno(), 0, access=mmap.ACCESS_READ) as s:
# Check if component path is in the file using mmap
Expand Down
5 changes: 3 additions & 2 deletions nf_core/components/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ def remove(self, component, repo_url=None, repo_path=None, removed_by=None, remo
if dependency_removed:
removed_components.append(component_name.replace("/", "_"))
# print removed dependencies
if removed_components:
log.info(f"Removed files for '{component}' and its dependencies '{', '.join(removed_components)}'.")
dependencies = set(removed_components) - {component}
if dependencies:
log.info(f"Removed files for '{component}' and its dependencies '{', '.join(dependencies)}'.")
else:
log.info(f"Removed files for '{component}'.")
else:
Expand Down
Loading