From d1bb86a683cf067b46a3657835255caa64272130 Mon Sep 17 00:00:00 2001 From: Konrad Rokicki Date: Thu, 7 Dec 2023 19:35:22 -0500 Subject: [PATCH 1/5] create modules dir if it doesn't exist --- nf_core/modules/modules_json.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index 9c3d1ae9b1..1cf5117d84 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -67,7 +67,8 @@ def create(self): new_modules_json = {"name": pipeline_name.strip("'"), "homePage": pipeline_url.strip("'"), "repos": {}} if not self.modules_dir.exists(): - raise UserWarning("Can't find a ./modules directory. Is this a DSL2 pipeline?") + log.info(f"Creating ./modules directory in '{self.dir}'") + self.modules_dir.mkdir() # Get repositories repos, _ = self.get_pipeline_module_repositories("modules", self.modules_dir) From ceec3230bb6d3561e3c1f5cd3e7e51a24df621c6 Mon Sep 17 00:00:00 2001 From: Konrad Rokicki Date: Thu, 7 Dec 2023 19:39:35 -0500 Subject: [PATCH 2/5] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c19839df49..93f9e7eabc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Replace ModulePatch by ComponentPatch ([#2482](https://github.com/nf-core/tools/pull/2482)) - Fixed `nf-core modules lint` to work with new module structure for nf-test ([#2494](https://github.com/nf-core/tools/pull/2494)) - Add option `--migrate-pytest` to create a module with nf-test taking into account an existing module ([#2549](https://github.com/nf-core/tools/pull/2549)) +- When installing modules and subworkflows, automatically create the `./modules` directory if it doesn't exist ([#2563](https://github.com/nf-core/tools/issues/2563)) ### Subworkflows From 0e807c22820b42751b5428773ece04db0884bb14 Mon Sep 17 00:00:00 2001 From: Konrad Rokicki Date: Fri, 8 Dec 2023 10:48:21 -0500 Subject: [PATCH 3/5] prompt for confirmation to create modules dir --- nf_core/modules/modules_json.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index 1cf5117d84..aa773dd6e3 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -67,8 +67,12 @@ def create(self): new_modules_json = {"name": pipeline_name.strip("'"), "homePage": pipeline_url.strip("'"), "repos": {}} if not self.modules_dir.exists(): - log.info(f"Creating ./modules directory in '{self.dir}'") - self.modules_dir.mkdir() + import rich.prompt + if rich.prompt.Confirm.ask("[bold][blue]?[/] Can't find a ./modules directory. Would you like me to create one?", default=True): + log.info(f"Creating ./modules directory in '{self.dir}'") + self.modules_dir.mkdir() + else: + raise UserWarning("Cannot proceed without a ./modules directory.") # Get repositories repos, _ = self.get_pipeline_module_repositories("modules", self.modules_dir) From ad2a8ab06cfdf5d040de6d21487021704bb2993a Mon Sep 17 00:00:00 2001 From: Konrad Rokicki Date: Fri, 8 Dec 2023 10:49:32 -0500 Subject: [PATCH 4/5] black formatting --- nf_core/modules/modules_json.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index aa773dd6e3..dfe7b284c2 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -68,7 +68,10 @@ def create(self): if not self.modules_dir.exists(): import rich.prompt - if rich.prompt.Confirm.ask("[bold][blue]?[/] Can't find a ./modules directory. Would you like me to create one?", default=True): + + if rich.prompt.Confirm.ask( + "[bold][blue]?[/] Can't find a ./modules directory. Would you like me to create one?", default=True + ): log.info(f"Creating ./modules directory in '{self.dir}'") self.modules_dir.mkdir() else: From 121bca304e19a63dc3c0848ab7de054c1bc3c9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20H=C3=B6rtenhuber?= Date: Fri, 8 Dec 2023 15:54:09 +0000 Subject: [PATCH 5/5] move import statement to top --- nf_core/modules/modules_json.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nf_core/modules/modules_json.py b/nf_core/modules/modules_json.py index dfe7b284c2..1dbc5eed79 100644 --- a/nf_core/modules/modules_json.py +++ b/nf_core/modules/modules_json.py @@ -9,6 +9,7 @@ import git import questionary +import rich.prompt from git.exc import GitCommandError import nf_core.utils @@ -67,8 +68,6 @@ def create(self): new_modules_json = {"name": pipeline_name.strip("'"), "homePage": pipeline_url.strip("'"), "repos": {}} if not self.modules_dir.exists(): - import rich.prompt - if rich.prompt.Confirm.ask( "[bold][blue]?[/] Can't find a ./modules directory. Would you like me to create one?", default=True ):