From a9f2602eeb0300c97ce71806be81d899faeaeaa2 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 8 Sep 2022 15:14:12 +0200 Subject: [PATCH 1/6] check that name provided with template doesn't contain dashes --- nf_core/create.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nf_core/create.py b/nf_core/create.py index 1cd4fecba0..8c4d86761a 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -106,6 +106,10 @@ def create_param_dict(self, name, description, author, version, template_yaml_pa param_dict["name"] = self.get_param("name", name, template_yaml, template_yaml_path) param_dict["description"] = self.get_param("description", description, template_yaml, template_yaml_path) param_dict["author"] = self.get_param("author", author, template_yaml, template_yaml_path) + # Check that the pipeline name matches the requirements + if not re.match(r"^[a-z]+$", param_dict["name"]): + log.error("[red]Invalid workflow name: must be lowercase without punctuation.") + sys.exit(1) if "version" in template_yaml: if version is not None: From 31758174367ea758659fd066d7e4f79c83337376 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 8 Sep 2022 15:15:07 +0200 Subject: [PATCH 2/6] ask for Name insteas of Workflow name with prompts --- nf_core/create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/create.py b/nf_core/create.py index 8c4d86761a..1bdc92f3d6 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -201,7 +201,7 @@ def get_param(self, param_name, passed_value, template_yaml, template_yaml_path) return passed_value def prompt_wf_name(self): - wf_name = questionary.text("Workflow name", style=nf_core.utils.nfcore_question_style).unsafe_ask() + wf_name = questionary.text("Name", style=nf_core.utils.nfcore_question_style).unsafe_ask() while not re.match(r"^[a-z]+$", wf_name): log.error("[red]Invalid workflow name: must be lowercase without punctuation.") wf_name = questionary.text( From e7ea34274862d6b11b1ca6f827cab520a7bee9aa Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 8 Sep 2022 15:21:00 +0200 Subject: [PATCH 3/6] update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ee1a97beb..d418f15aa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Add `actions/upload-artifact` step to the awstest workflows, to expose the debug log file - Bioconda incompatible conda channel setups now result in more informative error messages ([#1812](https://github.com/nf-core/tools/pull/1812)) +- Check that the workflow name provided with a template doesn't contain dashes ([#1822](https://github.com/nf-core/tools/pull/1822)) +- Ask for `Name` instead of `Workflow name` when creating a pipeline with prompts ([#1822](https://github.com/nf-core/tools/pull/1822)) ### Linting From 3c95159fc5e321742c3d5a8d0cc92060b7e3cbef Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 8 Sep 2022 15:42:15 +0200 Subject: [PATCH 4/6] fix checking wrong name --- nf_core/create.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nf_core/create.py b/nf_core/create.py index 1bdc92f3d6..644fccf715 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -106,10 +106,6 @@ def create_param_dict(self, name, description, author, version, template_yaml_pa param_dict["name"] = self.get_param("name", name, template_yaml, template_yaml_path) param_dict["description"] = self.get_param("description", description, template_yaml, template_yaml_path) param_dict["author"] = self.get_param("author", author, template_yaml, template_yaml_path) - # Check that the pipeline name matches the requirements - if not re.match(r"^[a-z]+$", param_dict["name"]): - log.error("[red]Invalid workflow name: must be lowercase without punctuation.") - sys.exit(1) if "version" in template_yaml: if version is not None: @@ -166,6 +162,11 @@ def create_param_dict(self, name, description, author, version, template_yaml_pa param_dict["logo_dark"] = f"{param_dict['name_noslash']}_logo_dark.png" param_dict["version"] = version + # Check that the pipeline name matches the requirements + if not re.match(r"^[a-z]+$", param_dict["short_name"]): + log.error("[red]Invalid workflow name: must be lowercase without punctuation.") + sys.exit(1) + return param_dict, skip_paths def customize_template(self, template_areas): From d7c145f4ad03999fd289b9a6f2df4258922d418c Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Thu, 8 Sep 2022 16:12:09 +0200 Subject: [PATCH 5/6] remove underscore from testpipeline name in tests --- tests/test_launch.py | 2 +- tests/test_schema.py | 2 +- tests/test_sync.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_launch.py b/tests/test_launch.py index a438f98c2f..a7b42844d1 100644 --- a/tests/test_launch.py +++ b/tests/test_launch.py @@ -71,7 +71,7 @@ def test_make_pipeline_schema(self, tmp_path): """Create a workflow, but delete the schema file, then try to load it""" test_pipeline_dir = os.path.join(tmp_path, "wf") create_obj = nf_core.create.PipelineCreate( - "test_pipeline", "", "", outdir=test_pipeline_dir, no_git=True, plain=True + "testpipeline", "", "", outdir=test_pipeline_dir, no_git=True, plain=True ) create_obj.init_pipeline() os.remove(os.path.join(test_pipeline_dir, "nextflow_schema.json")) diff --git a/tests/test_schema.py b/tests/test_schema.py index 4f829875e7..2261c5ed97 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -31,7 +31,7 @@ def setUp(self): self.tmp_dir = tempfile.mkdtemp() self.template_dir = os.path.join(self.tmp_dir, "wf") create_obj = nf_core.create.PipelineCreate( - "test_pipeline", "", "", outdir=self.template_dir, no_git=True, plain=True + "testpipeline", "", "", outdir=self.template_dir, no_git=True, plain=True ) create_obj.init_pipeline() diff --git a/tests/test_sync.py b/tests/test_sync.py index 2779f9e356..90a73590a4 100644 --- a/tests/test_sync.py +++ b/tests/test_sync.py @@ -21,7 +21,7 @@ class TestModules(unittest.TestCase): def setUp(self): """Create a new pipeline to test""" self.tmp_dir = tempfile.mkdtemp() - self.pipeline_dir = os.path.join(self.tmp_dir, "test_pipeline") + self.pipeline_dir = os.path.join(self.tmp_dir, "testpipeline") self.create_obj = nf_core.create.PipelineCreate( "testing", "test pipeline", "tester", outdir=self.pipeline_dir, plain=True ) From 0004b9b8808d3f405c8dde6a90accd9ca49c74db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Mir=20Pedrol?= Date: Thu, 20 Oct 2022 11:02:45 +0200 Subject: [PATCH 6/6] back to use Workflow name --- nf_core/create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/create.py b/nf_core/create.py index c3bc73870b..457adc3266 100644 --- a/nf_core/create.py +++ b/nf_core/create.py @@ -203,7 +203,7 @@ def get_param(self, param_name, passed_value, template_yaml, template_yaml_path) return passed_value def prompt_wf_name(self): - wf_name = questionary.text("Name", style=nf_core.utils.nfcore_question_style).unsafe_ask() + wf_name = questionary.text("Workflow name", style=nf_core.utils.nfcore_question_style).unsafe_ask() while not re.match(r"^[a-z]+$", wf_name): log.error("[red]Invalid workflow name: must be lowercase without punctuation.") wf_name = questionary.text(