From c91648ba234fc87bf106a48e48d411f6473ca0d9 Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 25 Nov 2022 16:49:05 +0100 Subject: [PATCH 01/10] improve handling of multitple remotes --- nf_core/modules/lint/__init__.py | 39 +++++++++++++++++++------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index fcce0e982f..3df3ccaa51 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -88,24 +88,31 @@ def __init__( if self.repo_type == "pipeline": modules_json = ModulesJson(self.dir) + import ipdb + + ipdb.set_trace() modules_json.check_up_to_date() - all_pipeline_modules = modules_json.get_all_components(self.component_type) - if self.modules_repo.remote_url in all_pipeline_modules: - module_dir = Path(self.dir, "modules", "nf-core") - self.all_remote_modules = [ - NFCoreModule(m[1], self.modules_repo.remote_url, module_dir / m[1], self.repo_type, Path(self.dir)) - for m in all_pipeline_modules[self.modules_repo.remote_url] - ] # m = (module_dir, module_name) - if not self.all_remote_modules: - raise LookupError(f"No modules from {self.modules_repo.remote_url} installed in pipeline.") + self.all_remote_modules = [] + for repo_url, components in modules_json.get_all_components(self.component_type).items(): + for org, comp in components: + self.all_remote_modules.append( + NFCoreModule( + comp, + repo_url, + Path(self.dir, self.component_type, org, comp), + self.repo_type, + Path(self.dir), + ) + ) local_module_dir = Path(self.dir, "modules", "local") - self.all_local_modules = [ - NFCoreModule(m, None, local_module_dir / m, self.repo_type, Path(self.dir), nf_core_module=False) - for m in self.get_local_components() - ] - - else: - raise LookupError(f"No modules from {self.modules_repo.remote_url} installed in pipeline.") + self.all_local_modules = [] + if local_module_dir.exists(): + self.all_local_modules = [ + NFCoreModule( + m, None, Path(local_module_dir, m), self.repo_type, Path(self.dir), nf_core_module=False + ) + for m in self.get_local_components() + ] else: module_dir = Path(self.dir, self.default_modules_path) self.all_remote_modules = [ From 27d40d6d29721a509f6a49ad151f9afaee4bd3c5 Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 29 Nov 2022 13:33:59 +0100 Subject: [PATCH 02/10] fix linting for non-nf-core modlues --- nf_core/modules/lint/module_changes.py | 9 ++++++--- nf_core/modules/lint/module_version.py | 9 ++++++--- nf_core/modules/modules_json.py | 7 +++++-- nf_core/modules/modules_repo.py | 3 +-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/nf_core/modules/lint/module_changes.py b/nf_core/modules/lint/module_changes.py index c2f1c2e1dd..dde48624a9 100644 --- a/nf_core/modules/lint/module_changes.py +++ b/nf_core/modules/lint/module_changes.py @@ -5,6 +5,7 @@ import tempfile from pathlib import Path +import nf_core.modules.modules_repo from nf_core.modules.modules_differ import ModulesDiffer @@ -39,10 +40,12 @@ def module_changes(module_lint_object, module): return else: tempdir = module.module_dir + module.branch = module_lint_object.modules_json.get_component_branch( + "modules", module.module_name, module.repo_url, module.module_dir.parent.name + ) + modules_repo = nf_core.modules.modules_repo.ModulesRepo(remote_url=module.repo_url, branch=module.branch) - for f, same in module_lint_object.modules_repo.module_files_identical( - module.module_name, tempdir, module.git_sha - ).items(): + for f, same in modules_repo.module_files_identical(module.module_dir, tempdir, module.git_sha).items(): if same: module.passed.append( ( diff --git a/nf_core/modules/lint/module_version.py b/nf_core/modules/lint/module_version.py index 3f68395031..565f5fb4f7 100644 --- a/nf_core/modules/lint/module_version.py +++ b/nf_core/modules/lint/module_version.py @@ -22,10 +22,9 @@ def module_version(module_lint_object, module): """ modules_json_path = Path(module_lint_object.dir, "modules.json") - # Verify that a git_sha exists in the `modules.json` file for this module version = module_lint_object.modules_json.get_module_version( - module.module_name, module_lint_object.modules_repo.remote_url, module_lint_object.modules_repo.repo_path + module.module_name, module.repo_url, module.module_dir.parent.name ) if version is None: module.failed.append(("git_sha", "No git_sha entry in `modules.json`", modules_json_path)) @@ -36,7 +35,11 @@ def module_version(module_lint_object, module): # Check whether a new version is available try: - modules_repo = nf_core.modules.modules_repo.ModulesRepo() + module.branch = module_lint_object.modules_json.get_component_branch( + "modules", module.module_name, module.repo_url, module.module_dir.parent.name + ) + modules_repo = nf_core.modules.modules_repo.ModulesRepo(remote_url=module.repo_url, branch=module.branch) + module_git_log = modules_repo.get_component_git_log(module.module_name, "modules") if version == next(module_git_log)["git_sha"]: module.passed.append(("module_version", "Module is the latest version", module.module_dir)) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index beb6d61adc..4d6924c920 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -355,7 +355,10 @@ def find_correct_commit_sha(self, component_type, component_name, component_path for commit in modules_repo.get_component_git_log(component_name, component_type, depth=1000) ) for commit_sha in commit_shas: - if all(modules_repo.module_files_identical(component_name, component_path, commit_sha).values()): + module_dir = modules_repo.get_component_dir(component_name, component_type) + if all( + modules_repo.module_files_identical(module_dir, component_name, component_path, commit_sha).values() + ): return commit_sha return None @@ -977,7 +980,7 @@ def get_component_branch(self, component_type, component, repo_url, install_dir) Returns: (str): The branch name Raises: - LookupError: If their is no branch entry in the `modules.json` + LookupError: If there is no branch entry in the `modules.json` """ if self.modules_json is None: self.load() diff --git a/nf_core/modules/modules_repo.py b/nf_core/modules/modules_repo.py index 77a266b4e9..1356ba5c71 100644 --- a/nf_core/modules/modules_repo.py +++ b/nf_core/modules/modules_repo.py @@ -361,7 +361,7 @@ def install_component(self, component_name, install_dir, commit, component_type) self.checkout_branch() return True - def module_files_identical(self, module_name, base_path, commit): + def module_files_identical(self, module_dir, base_path, commit): """ Checks whether the module files in a pipeline are identical to the ones in the remote Args: @@ -376,7 +376,6 @@ def module_files_identical(self, module_name, base_path, commit): else: self.checkout(commit) module_files = ["main.nf", "meta.yml"] - module_dir = self.get_component_dir(module_name, "modules") files_identical = {file: True for file in module_files} for file in module_files: try: From a827842adfefab9cd143f1a44beaf02abd8de920 Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 29 Nov 2022 16:22:51 +0100 Subject: [PATCH 03/10] fix tool/subtool cases --- nf_core/modules/lint/__init__.py | 2 +- nf_core/modules/lint/module_changes.py | 2 +- nf_core/modules/lint/module_version.py | 6 ++---- nf_core/modules/nfcore_module.py | 7 ++++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index d6ad68331d..fdbcdff2c6 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -106,7 +106,7 @@ def __init__( if local_module_dir.exists(): self.all_local_modules = [ NFCoreModule( - m, None, Path(local_module_dir, m), self.repo_type, Path(self.dir), nf_core_module=False + m, None, Path(local_module_dir, m), self.repo_type, Path(self.dir), remote_module=False ) for m in self.get_local_components() ] diff --git a/nf_core/modules/lint/module_changes.py b/nf_core/modules/lint/module_changes.py index dde48624a9..65c293d2eb 100644 --- a/nf_core/modules/lint/module_changes.py +++ b/nf_core/modules/lint/module_changes.py @@ -41,7 +41,7 @@ def module_changes(module_lint_object, module): else: tempdir = module.module_dir module.branch = module_lint_object.modules_json.get_component_branch( - "modules", module.module_name, module.repo_url, module.module_dir.parent.name + "modules", module.module_name, module.repo_url, module.org ) modules_repo = nf_core.modules.modules_repo.ModulesRepo(remote_url=module.repo_url, branch=module.branch) diff --git a/nf_core/modules/lint/module_version.py b/nf_core/modules/lint/module_version.py index 565f5fb4f7..1cf142e8eb 100644 --- a/nf_core/modules/lint/module_version.py +++ b/nf_core/modules/lint/module_version.py @@ -23,9 +23,7 @@ def module_version(module_lint_object, module): modules_json_path = Path(module_lint_object.dir, "modules.json") # Verify that a git_sha exists in the `modules.json` file for this module - version = module_lint_object.modules_json.get_module_version( - module.module_name, module.repo_url, module.module_dir.parent.name - ) + version = module_lint_object.modules_json.get_module_version(module.module_name, module.repo_url, module.org) if version is None: module.failed.append(("git_sha", "No git_sha entry in `modules.json`", modules_json_path)) return @@ -36,7 +34,7 @@ def module_version(module_lint_object, module): # Check whether a new version is available try: module.branch = module_lint_object.modules_json.get_component_branch( - "modules", module.module_name, module.repo_url, module.module_dir.parent.name + "modules", module.module_name, module.repo_url, module.org ) modules_repo = nf_core.modules.modules_repo.ModulesRepo(remote_url=module.repo_url, branch=module.branch) diff --git a/nf_core/modules/nfcore_module.py b/nf_core/modules/nfcore_module.py index e8bff1f686..b8c9eb846e 100644 --- a/nf_core/modules/nfcore_module.py +++ b/nf_core/modules/nfcore_module.py @@ -10,7 +10,7 @@ class NFCoreModule: Includes functionality for linting """ - def __init__(self, module_name, repo_url, module_dir, repo_type, base_dir, nf_core_module=True): + def __init__(self, module_name, repo_url, module_dir, repo_type, base_dir, remote_module=True): """ Initialize the object @@ -20,7 +20,7 @@ def __init__(self, module_name, repo_url, module_dir, repo_type, base_dir, nf_co whether the directory is a pipeline or clone of nf-core/modules. base_dir (Path): The absolute path to the pipeline base dir - nf_core_module (bool): Whether the module is to be treated as a + remote_module (bool): Whether the module is to be treated as a nf-core or local module """ self.module_name = module_name @@ -38,12 +38,13 @@ def __init__(self, module_name, repo_url, module_dir, repo_type, base_dir, nf_co self.is_patched = False self.is_patched = None - if nf_core_module: + if remote_module: # Initialize the important files self.main_nf = self.module_dir / "main.nf" self.meta_yml = self.module_dir / "meta.yml" repo_dir = self.module_dir.parts[: self.module_dir.parts.index(self.module_name.split("/")[0])][-1] + self.org = repo_dir self.test_dir = Path(self.base_dir, "tests", "modules", repo_dir, self.module_name) self.test_yml = self.test_dir / "test.yml" self.test_main_nf = self.test_dir / "main.nf" From fe4287cefdae7539b7ec07ccedb4a3760512ba90 Mon Sep 17 00:00:00 2001 From: Arthur Gymer <24782660+awgymer@users.noreply.github.com> Date: Tue, 29 Nov 2022 17:06:56 +0000 Subject: [PATCH 04/10] Drop unused parameter --- nf_core/modules/modules_json.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index 4d6924c920..112d13fd2a 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -356,9 +356,7 @@ def find_correct_commit_sha(self, component_type, component_name, component_path ) for commit_sha in commit_shas: module_dir = modules_repo.get_component_dir(component_name, component_type) - if all( - modules_repo.module_files_identical(module_dir, component_name, component_path, commit_sha).values() - ): + if all(modules_repo.module_files_identical(module_dir, component_path, commit_sha).values()): return commit_sha return None From bb0e2944ff58158af5fe81c1e68dd4a6b4dc309a Mon Sep 17 00:00:00 2001 From: Arthur Gymer <24782660+awgymer@users.noreply.github.com> Date: Tue, 29 Nov 2022 18:25:38 +0000 Subject: [PATCH 05/10] Change return value of ModulesJson.get_all_components if there are none found --- nf_core/components/info.py | 4 ++-- nf_core/modules/modules_json.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/nf_core/components/info.py b/nf_core/components/info.py index b371290006..b89baaf99e 100644 --- a/nf_core/components/info.py +++ b/nf_core/components/info.py @@ -103,13 +103,13 @@ def init_mod_name(self, component): components = self.get_components_clone_modules() else: components = self.modules_json.get_all_components(self.component_type).get( - self.modules_repo.remote_url + self.modules_repo.remote_url, {} ) components = [ component if directory == self.modules_repo.repo_path else f"{directory}/{component}" for directory, component in components ] - if components is None: + if not components: raise UserWarning( f"No {self.component_type[:-1]} installed from '{self.modules_repo.remote_url}'" ) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index 112d13fd2a..cc8e087510 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -927,8 +927,6 @@ def get_all_components(self, component_type): if component_type in repo_entry: for dir, components in repo_entry[component_type].items(): self.pipeline_components[repo] = [(dir, m) for m in components] - if self.pipeline_components == {}: - self.pipeline_components = None return self.pipeline_components From 444401ebb5ff2b66717bf567a277201fa102d2ac Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 30 Nov 2022 11:34:37 +0100 Subject: [PATCH 06/10] add test for multiple remotes --- tests/modules/lint.py | 11 +++++++++++ tests/test_modules.py | 1 + 2 files changed, 12 insertions(+) diff --git a/tests/modules/lint.py b/tests/modules/lint.py index 183276672b..b942d25704 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -68,6 +68,17 @@ def test_modules_lint_gitlab_modules(self): assert len(module_lint.warned) >= 0 +def test_modules_lint_multiple_remotes(self): + """Lint modules from a different remote""" + self.mods_install.install("fastqc") + self.mods_install_gitlab.install("multiqc") + module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) + module_lint.lint(print_results=False, all_modules=True) + assert len(module_lint.failed) == 0 + assert len(module_lint.passed) > 0 + assert len(module_lint.warned) >= 0 + + def test_modules_lint_patched_modules(self): """ Test creating a patch file and applying it to a new version of the the files diff --git a/tests/test_modules.py b/tests/test_modules.py index 56a32af77b..b34bdb4f00 100644 --- a/tests/test_modules.py +++ b/tests/test_modules.py @@ -158,6 +158,7 @@ def test_modulesrepo_class(self): from .modules.lint import ( test_modules_lint_empty, test_modules_lint_gitlab_modules, + test_modules_lint_multiple_remotes, test_modules_lint_new_modules, test_modules_lint_no_gitlab, test_modules_lint_patched_modules, From 7c2237ca4d53b9e9ef8debfdebbd5f7934aa13cc Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 30 Nov 2022 15:58:28 +0100 Subject: [PATCH 07/10] fix some tests --- nf_core/modules/lint/__init__.py | 20 +++++++++++--------- tests/modules/lint.py | 3 +++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index fdbcdff2c6..1b12ef3897 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -101,15 +101,17 @@ def __init__( Path(self.dir), ) ) - local_module_dir = Path(self.dir, "modules", "local") - self.all_local_modules = [] - if local_module_dir.exists(): - self.all_local_modules = [ - NFCoreModule( - m, None, Path(local_module_dir, m), self.repo_type, Path(self.dir), remote_module=False - ) - for m in self.get_local_components() - ] + if not self.all_remote_modules: + raise LookupError(f"No modules from {self.modules_repo.remote_url} installed in pipeline.") + local_module_dir = Path(self.dir, "modules", "local") + self.all_local_modules = [] + if local_module_dir.exists(): + self.all_local_modules = [ + NFCoreModule( + m, None, Path(local_module_dir, m), self.repo_type, Path(self.dir), remote_module=False + ) + for m in self.get_local_components() + ] else: module_dir = Path(self.dir, self.default_modules_path) self.all_remote_modules = [ diff --git a/tests/modules/lint.py b/tests/modules/lint.py index b942d25704..56053cc40d 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -53,6 +53,9 @@ def test_modules_lint_new_modules(self): def test_modules_lint_no_gitlab(self): """Test linting a pipeline with no modules installed""" + self.mods_remove_gitlab.remove("fastqc", force=True) + self.mods_remove_gitlab.remove("multiqc", force=True) + self.mods_remove_gitlab.remove("custom/dumpsoftwareversions", force=True) with pytest.raises(LookupError): nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) From 30d9c16259d254c4ab230d4a42f0d5148e57b1d5 Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 30 Nov 2022 16:31:24 +0100 Subject: [PATCH 08/10] add helper function to get `installed_by` without relying on modules_repo --- nf_core/components/remove.py | 6 ++---- nf_core/components/update.py | 10 ++++------ nf_core/modules/modules_json.py | 24 ++++++++++++++++++++++++ tests/modules/lint.py | 15 ++++++++++----- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/nf_core/components/remove.py b/nf_core/components/remove.py index 0916d56e85..528f032124 100644 --- a/nf_core/components/remove.py +++ b/nf_core/components/remove.py @@ -161,10 +161,8 @@ def remove(self, component, removed_by=None, removed_components=None, force=Fals else: log.info(f"Removed files for '{component}'.") else: - installed_by = modules_json.modules_json["repos"][self.modules_repo.remote_url][self.component_type][ - repo_path - ][component]["installed_by"] - if installed_by == self.component_type: + installed_by = modules_json.get_installed_by_entries(self.component_type, component) + if installed_by == [self.component_type]: log.error( f"Did not remove '{component}', because it was also manually installed. Only updated 'installed_by' entry in modules.json." ) diff --git a/nf_core/components/update.py b/nf_core/components/update.py index 7e1d67ce87..003dbf71b6 100644 --- a/nf_core/components/update.py +++ b/nf_core/components/update.py @@ -234,7 +234,7 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr else: updated.append(component) recursive_update = True - modules_to_update, subworkflows_to_update = self.get_components_to_update(component, modules_repo) + modules_to_update, subworkflows_to_update = self.get_components_to_update(component) if not silent and len(modules_to_update + subworkflows_to_update) > 0: log.warning( f"All modules and subworkflows linked to the updated {self.component_type[:-1]} will be added to the same diff file.\n" @@ -281,7 +281,7 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr self.modules_json.update(self.component_type, modules_repo, component, version, self.component_type) updated.append(component) recursive_update = True - modules_to_update, subworkflows_to_update = self.get_components_to_update(component, modules_repo) + modules_to_update, subworkflows_to_update = self.get_components_to_update(component) if not silent and not self.update_all and len(modules_to_update + subworkflows_to_update) > 0: log.warning( f"All modules and subworkflows linked to the updated {self.component_type[:-1]} will be {'asked for update' if self.show_diff else 'automatically updated'}.\n" @@ -819,7 +819,7 @@ def try_apply_patch( return True - def get_components_to_update(self, component, modules_repo): + def get_components_to_update(self, component): """ Get all modules and subworkflows linked to the updated component. @@ -829,9 +829,7 @@ def get_components_to_update(self, component, modules_repo): mods_json = self.modules_json.get_modules_json() modules_to_update = [] subworkflows_to_update = [] - installed_by = mods_json["repos"][modules_repo.remote_url][self.component_type][modules_repo.repo_path][ - component - ]["installed_by"] + installed_by = self.modules_json.get_installed_by_entries(self.component_type, component) if self.component_type == "modules": # All subworkflow names in the installed_by section of a module are subworkflows using this module diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index 3f67e13bc5..c7015bd5c9 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -960,6 +960,30 @@ def get_dependent_components( return dependent_components + def get_installed_by_entries(self, component_type, name): + """ + Retrieves all entries of installed_by for a given component + + Args: + component_type (str): Type of component [modules, subworkflows] + name (str): Name of the component to find dependencies for + + Returns: + (list): The list of installed_by entries + + """ + if self.modules_json is None: + self.load() + installed_by_entries = {} + for repo_url, repo_entry in self.modules_json.get("repos", {}).items(): + if component_type in repo_entry: + for install_dir, components in repo_entry[component_type].items(): + if name in components: + installed_by_entries = components[name]["installed_by"] + break + + return installed_by_entries + def get_component_branch(self, component_type, component, repo_url, install_dir): """ Gets the branch from which the module/subworkflow was installed diff --git a/tests/modules/lint.py b/tests/modules/lint.py index 56053cc40d..476481a109 100644 --- a/tests/modules/lint.py +++ b/tests/modules/lint.py @@ -53,9 +53,9 @@ def test_modules_lint_new_modules(self): def test_modules_lint_no_gitlab(self): """Test linting a pipeline with no modules installed""" - self.mods_remove_gitlab.remove("fastqc", force=True) - self.mods_remove_gitlab.remove("multiqc", force=True) - self.mods_remove_gitlab.remove("custom/dumpsoftwareversions", force=True) + self.mods_remove.remove("fastqc", force=True) + self.mods_remove.remove("multiqc", force=True) + self.mods_remove.remove("custom/dumpsoftwareversions", force=True) with pytest.raises(LookupError): nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL) @@ -95,8 +95,13 @@ def test_modules_lint_patched_modules(self): # change temporarily working directory to the pipeline directory # to avoid error from try_apply_patch() during linting with set_wd(self.pipeline_dir): - module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL, branch=PATCH_BRANCH) - module_lint.lint(print_results=False, all_modules=True) + module_lint = nf_core.modules.ModuleLint( + dir=self.pipeline_dir, remote_url=GITLAB_URL, branch=PATCH_BRANCH, hide_progress=True + ) + module_lint.lint( + print_results=False, + all_modules=True, + ) assert len(module_lint.failed) == 0 assert len(module_lint.passed) > 0 From 6671a23ab7c6bab0d825deb8d679e0b7023519f6 Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 30 Nov 2022 17:28:34 +0100 Subject: [PATCH 09/10] go back to module_name instead of module_dir --- nf_core/modules/lint/module_changes.py | 2 +- nf_core/modules/modules_json.py | 3 +-- nf_core/modules/modules_repo.py | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nf_core/modules/lint/module_changes.py b/nf_core/modules/lint/module_changes.py index 65c293d2eb..61b416e5f7 100644 --- a/nf_core/modules/lint/module_changes.py +++ b/nf_core/modules/lint/module_changes.py @@ -45,7 +45,7 @@ def module_changes(module_lint_object, module): ) modules_repo = nf_core.modules.modules_repo.ModulesRepo(remote_url=module.repo_url, branch=module.branch) - for f, same in modules_repo.module_files_identical(module.module_dir, tempdir, module.git_sha).items(): + for f, same in modules_repo.module_files_identical(module.module_name, tempdir, module.git_sha).items(): if same: module.passed.append( ( diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index c7015bd5c9..aea5e733c6 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -355,8 +355,7 @@ def find_correct_commit_sha(self, component_type, component_name, component_path for commit in modules_repo.get_component_git_log(component_name, component_type, depth=1000) ) for commit_sha in commit_shas: - module_dir = modules_repo.get_component_dir(component_name, component_type) - if all(modules_repo.module_files_identical(module_dir, component_path, commit_sha).values()): + if all(modules_repo.module_files_identical(component_name, component_path, commit_sha).values()): return commit_sha return None diff --git a/nf_core/modules/modules_repo.py b/nf_core/modules/modules_repo.py index 1356ba5c71..606514e55e 100644 --- a/nf_core/modules/modules_repo.py +++ b/nf_core/modules/modules_repo.py @@ -361,7 +361,7 @@ def install_component(self, component_name, install_dir, commit, component_type) self.checkout_branch() return True - def module_files_identical(self, module_dir, base_path, commit): + def module_files_identical(self, module_name, base_path, commit): """ Checks whether the module files in a pipeline are identical to the ones in the remote Args: @@ -377,6 +377,7 @@ def module_files_identical(self, module_dir, base_path, commit): self.checkout(commit) module_files = ["main.nf", "meta.yml"] files_identical = {file: True for file in module_files} + module_dir = self.get_component_dir(module_name, "modules") for file in module_files: try: files_identical[file] = filecmp.cmp(os.path.join(module_dir, file), os.path.join(base_path, file)) From 252e39d66cb448c08b025b128651cbb9814e3f00 Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 30 Nov 2022 17:28:56 +0100 Subject: [PATCH 10/10] remove duplicated initialization --- nf_core/modules/nfcore_module.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nf_core/modules/nfcore_module.py b/nf_core/modules/nfcore_module.py index b8c9eb846e..431ef23381 100644 --- a/nf_core/modules/nfcore_module.py +++ b/nf_core/modules/nfcore_module.py @@ -36,7 +36,6 @@ def __init__(self, module_name, repo_url, module_dir, repo_type, base_dir, remot self.has_meta = False self.git_sha = None self.is_patched = False - self.is_patched = None if remote_module: # Initialize the important files