From dadb11c2a42a5011fb91716e5d10dfe43b00d65a Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Tue, 8 Nov 2022 09:38:01 +0100 Subject: [PATCH 1/2] change installed by installed_by --- nf_core/components/components_install.py | 2 +- nf_core/modules/modules_json.py | 26 ++++++++++++------------ nf_core/pipeline-template/modules.json | 6 +++--- tests/modules/modules_json.py | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/nf_core/components/components_install.py b/nf_core/components/components_install.py index 7680134d14..5ad00695bc 100644 --- a/nf_core/components/components_install.py +++ b/nf_core/components/components_install.py @@ -100,4 +100,4 @@ def clean_modules_json(component, component_type, modules_repo, modules_json): f"Removing {component_type[:-1]} '{modules_repo.repo_path}/{component}' from repo '{repo_to_remove}' from modules.json" ) modules_json.remove_entry(component_type, component, repo_to_remove, modules_repo.repo_path) - return component_values["installed"] + return component_values["installed_by"] diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index eabaa51c73..d643057781 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -277,7 +277,7 @@ def determine_module_branches_and_shas(self, install_dir, remote_url, modules): repo_entry[module] = { "branch": modules_repo.branch, "git_sha": correct_commit_sha, - "installed": "modules", + "installed_by": "modules", } # Clean up the modules we were unable to find the sha for @@ -481,7 +481,7 @@ def check_up_to_date(self): If a module/subworkflow is installed but the entry in 'modules.json' is missing we iterate through the commit log in the remote to try to determine the SHA. - Check that we have the "installed" value in 'modules.json', otherwise add it. + Check that we have the "installed_by" value in 'modules.json', otherwise add it. Assume that the modules/subworkflows were installed by and nf-core command (don't track installed by subworkflows). """ try: @@ -517,13 +517,13 @@ def check_up_to_date(self): if len(subworkflows_missing_from_modules_json) > 0: self.resolve_missing_from_modules_json(subworkflows_missing_from_modules_json, "subworkflows") - # If the "installed" value is not present for modules/subworkflows, add it. + # If the "installed_by" value is not present for modules/subworkflows, add it. for repo, repo_content in self.modules_json["repos"].items(): for component_type, dir_content in repo_content.items(): for install_dir, installed_components in dir_content.items(): for component, component_features in installed_components.items(): - if "installed" not in component_features: - self.modules_json["repos"][repo][component_type][install_dir][component]["installed"] = [ + if "installed_by" not in component_features: + self.modules_json["repos"][repo][component_type][install_dir][component]["installed_by"] = [ component_type ] @@ -572,12 +572,12 @@ def update(self, modules_repo, module_name, module_version, installed_by, instal repo_modules_entry[module_name]["git_sha"] = module_version repo_modules_entry[module_name]["branch"] = branch try: - if installed_by not in repo_modules_entry[module_name]["installed"]: - repo_modules_entry[module_name]["installed"].append(installed_by) + if installed_by not in repo_modules_entry[module_name]["installed_by"]: + repo_modules_entry[module_name]["installed_by"].append(installed_by) except KeyError: - repo_modules_entry[module_name]["installed"] = [installed_by] + repo_modules_entry[module_name]["installed_by"] = [installed_by] finally: - repo_modules_entry[module_name]["installed"].extend(installed_by_log) + repo_modules_entry[module_name]["installed_by"].extend(installed_by_log) # Sort the 'modules.json' repo entries self.modules_json["repos"] = nf_core.utils.sort_dictionary(self.modules_json["repos"]) @@ -616,12 +616,12 @@ def update_subworkflow( repo_subworkflows_entry[subworkflow_name]["git_sha"] = subworkflow_version repo_subworkflows_entry[subworkflow_name]["branch"] = branch try: - if installed_by not in repo_subworkflows_entry[subworkflow_name]["installed"]: - repo_subworkflows_entry[subworkflow_name]["installed"].append(installed_by) + if installed_by not in repo_subworkflows_entry[subworkflow_name]["installed_by"]: + repo_subworkflows_entry[subworkflow_name]["installed_by"].append(installed_by) except KeyError: - repo_subworkflows_entry[subworkflow_name]["installed"] = [installed_by] + repo_subworkflows_entry[subworkflow_name]["installed_by"] = [installed_by] finally: - repo_subworkflows_entry[subworkflow_name]["installed"].extend(installed_by_log) + repo_subworkflows_entry[subworkflow_name]["installed_by"].extend(installed_by_log) # Sort the 'modules.json' repo entries self.modules_json["repos"] = nf_core.utils.sort_dictionary(self.modules_json["repos"]) diff --git a/nf_core/pipeline-template/modules.json b/nf_core/pipeline-template/modules.json index 6a1bf1f96a..8618bacab6 100644 --- a/nf_core/pipeline-template/modules.json +++ b/nf_core/pipeline-template/modules.json @@ -8,17 +8,17 @@ "custom/dumpsoftwareversions": { "branch": "master", "git_sha": "5e34754d42cd2d5d248ca8673c0a53cdf5624905", - "installed": ["modules"] + "installed_by": ["modules"] }, "fastqc": { "branch": "master", "git_sha": "5e34754d42cd2d5d248ca8673c0a53cdf5624905", - "installed": ["modules"] + "installed_by": ["modules"] }, "multiqc": { "branch": "master", "git_sha": "5e34754d42cd2d5d248ca8673c0a53cdf5624905", - "installed": ["modules"] + "installed_by": ["modules"] } } } diff --git a/tests/modules/modules_json.py b/tests/modules/modules_json.py index 3b6be3101f..20eee54e30 100644 --- a/tests/modules/modules_json.py +++ b/tests/modules/modules_json.py @@ -41,7 +41,7 @@ def test_mod_json_update(self): NF_CORE_MODULES_DEFAULT_BRANCH == mod_json["repos"][NF_CORE_MODULES_REMOTE]["modules"]["nf-core"]["MODULE_NAME"]["branch"] ) - assert "modules" in mod_json["repos"][NF_CORE_MODULES_REMOTE]["modules"]["nf-core"]["MODULE_NAME"]["installed"] + assert "modules" in mod_json["repos"][NF_CORE_MODULES_REMOTE]["modules"]["nf-core"]["MODULE_NAME"]["installed_by"] def test_mod_json_create(self): From a5073fa6b9fb5dcb17466e46d2aa2dd002cf7f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Tue, 8 Nov 2022 10:22:17 +0100 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matthias Hörtenhuber --- nf_core/modules/modules_json.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index d643057781..e2c45b935b 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -482,7 +482,7 @@ def check_up_to_date(self): the commit log in the remote to try to determine the SHA. Check that we have the "installed_by" value in 'modules.json', otherwise add it. - Assume that the modules/subworkflows were installed by and nf-core command (don't track installed by subworkflows). + Assume that the modules/subworkflows were installed by an nf-core command (don't track installed by subworkflows). """ try: self.load()