Skip to content

Commit

Permalink
Merge pull request #2042 from awgymer/fix-remove-remote
Browse files Browse the repository at this point in the history
Return remote params to remove commands
  • Loading branch information
awgymer authored Nov 25, 2022
2 parents bbb5415 + aefa3d5 commit 73f6b49
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
14 changes: 12 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,12 @@ def remove(ctx, dir, tool):
Remove a module from a pipeline.
"""
try:
module_remove = nf_core.modules.ModuleRemove(dir)
module_remove = nf_core.modules.ModuleRemove(
dir,
ctx.obj["modules_repo_url"],
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
)
module_remove.remove(tool)
except (UserWarning, LookupError) as e:
log.critical(e)
Expand Down Expand Up @@ -1194,7 +1199,12 @@ def remove(ctx, dir, subworkflow):
Remove a subworkflow from a pipeline.
"""
try:
module_remove = nf_core.subworkflows.SubworkflowRemove(dir)
module_remove = nf_core.subworkflows.SubworkflowRemove(
dir,
ctx.obj["modules_repo_url"],
ctx.obj["modules_repo_branch"],
ctx.obj["modules_repo_no_pull"],
)
module_remove.remove(subworkflow)
except (UserWarning, LookupError) as e:
log.critical(e)
Expand Down
4 changes: 2 additions & 2 deletions nf_core/components/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


class ComponentRemove(ComponentCommand):
def __init__(self, component_type, pipeline_dir):
super().__init__(component_type, pipeline_dir)
def __init__(self, component_type, pipeline_dir, remote_url=None, branch=None, no_pull=False):
super().__init__(component_type, pipeline_dir, remote_url, branch, no_pull)

def remove(self, component, force=False):
"""
Expand Down
2 changes: 2 additions & 0 deletions nf_core/modules/modules_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ def remove_entry(self, component_type, name, repo_url, install_dir, removed_by=N
self.modules_json["repos"][repo_url][component_type][install_dir].pop(name)
if len(repo_entry[component_type][install_dir]) == 0:
self.modules_json["repos"][repo_url].pop(component_type)
if len(repo_entry) == 0:
self.modules_json["repos"].pop(repo_url)
# write the updated modules.json file
self.dump()
return True
Expand Down
4 changes: 2 additions & 2 deletions nf_core/modules/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@


class ModuleRemove(ComponentRemove):
def __init__(self, pipeline_dir):
super().__init__("modules", pipeline_dir)
def __init__(self, pipeline_dir, remote_url=None, branch=None, no_pull=False):
super().__init__("modules", pipeline_dir, remote_url=remote_url, branch=branch, no_pull=no_pull)
4 changes: 2 additions & 2 deletions nf_core/subworkflows/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@


class SubworkflowRemove(ComponentRemove):
def __init__(self, pipeline_dir):
super().__init__("subworkflows", pipeline_dir)
def __init__(self, pipeline_dir, remote_url=None, branch=None, no_pull=False):
super().__init__("subworkflows", pipeline_dir, remote_url=remote_url, branch=branch, no_pull=no_pull)
13 changes: 6 additions & 7 deletions tests/modules/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ def test_modules_remove_trimgalore_uninstalled(self):
assert self.mods_remove.remove("trimgalore") is False


# TODO Remove comments once external repository to have same structure as nf-core/modules
# def test_modules_remove_trimgalore_alternative_source(self):
# """Test removing TrimGalore! module after installing it from an alternative source"""
# self.mods_install_alt.install("trimgalore")
# module_path = os.path.join(self.mods_install.dir, "modules", "external", "trimgalore")
# assert self.mods_remove_alt.remove("trimgalore")
# assert os.path.exists(module_path) is False
def test_modules_remove_multiqc_from_gitlab(self):
"""Test removing multiqc module after installing it from an alternative source"""
self.mods_install_gitlab.install("multiqc")
module_path = os.path.join(self.mods_install_gitlab.dir, "modules", "nf-core", "multiqc")
assert self.mods_remove_gitlab.remove("multiqc", force=True)
assert os.path.exists(module_path) is False
7 changes: 6 additions & 1 deletion tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def setUp(self):

# Set up remove objects
self.mods_remove = nf_core.modules.ModuleRemove(self.pipeline_dir)
self.mods_remove_alt = nf_core.modules.ModuleRemove(self.pipeline_dir)
self.mods_remove_gitlab = nf_core.modules.ModuleRemove(
self.pipeline_dir,
remote_url=GITLAB_URL,
branch=GITLAB_DEFAULT_BRANCH,
)

# Set up the nf-core/modules repo dummy
self.nfcore_modules = create_modules_repo_dummy(self.tmp_dir)
Expand Down Expand Up @@ -195,6 +199,7 @@ def test_modulesrepo_class(self):
test_create_patch_update_success,
)
from .modules.remove import (
test_modules_remove_multiqc_from_gitlab,
test_modules_remove_trimgalore,
test_modules_remove_trimgalore_uninstalled,
)
Expand Down

0 comments on commit 73f6b49

Please sign in to comment.