From 97da643b4d968809a8853b079f44d39e91d52f10 Mon Sep 17 00:00:00 2001 From: Alex Hermida Date: Tue, 19 Mar 2024 22:18:52 +0100 Subject: [PATCH 1/4] Get immediate path parent name --- nf_core/schema.py | 4 +++- tests/test_schema.py | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nf_core/schema.py b/nf_core/schema.py index a4e8ad7cdc..4f5acfa0af 100644 --- a/nf_core/schema.py +++ b/nf_core/schema.py @@ -587,10 +587,12 @@ def make_skeleton_schema(self): loader=jinja2.PackageLoader("nf_core", "pipeline-template"), keep_trailing_newline=True ) schema_template = env.get_template("nextflow_schema.json") + template_vars = { - "name": self.pipeline_manifest.get("name", str(Path(self.schema_filename).parent)).strip("'"), + "name": self.pipeline_manifest.get("name", Path(self.schema_filename).parent.name).strip("'"), "description": self.pipeline_manifest.get("description", "").strip("'"), } + self.schema = json.loads(schema_template.render(template_vars)) self.get_schema_defaults() diff --git a/tests/test_schema.py b/tests/test_schema.py index b9cb108fae..a05fdf6b92 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -218,6 +218,13 @@ def test_make_skeleton_schema(self): self.schema_obj.make_skeleton_schema() self.schema_obj.validate_schema(self.schema_obj.schema) + def test_make_skeleton_schema_absent_name(self): + """Test making a new schema skeleton""" + self.schema_obj.schema_filename = self.template_schema + self.schema_obj.pipeline_manifest["description"] = "Test pipeline" + self.schema_obj.make_skeleton_schema() + self.schema_obj.validate_schema(self.schema_obj.schema) + def test_get_wf_params(self): """Test getting the workflow parameters from a pipeline""" self.schema_obj.schema_filename = self.template_schema From b9c4746ff8bb648c4e84f6f38bd868678df7ade0 Mon Sep 17 00:00:00 2001 From: Alex Hermida Date: Tue, 19 Mar 2024 22:34:08 +0100 Subject: [PATCH 2/4] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac60a404e4..79d29ca32d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ - Update gitpod/workspace-base Docker digest to 168d78b ([#2899](https://github.com/nf-core/tools/pull/2899)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.3.4 ([#2894](https://github.com/nf-core/tools/pull/2894)) - Update GitHub Actions ([#2902](https://github.com/nf-core/tools/pull/2902)) +- Get immediate parent path name for schema creation ([#2886](https://github.com/nf-core/tools/pull/2886)) ## [v2.13.1 - Tin Puppy Patch](https://github.com/nf-core/tools/releases/tag/2.13) - [2024-02-29] From 31240de0d2c826c120813a9e84237ba7a77a4d83 Mon Sep 17 00:00:00 2001 From: Alex Hermida Date: Wed, 20 Mar 2024 14:56:19 +0100 Subject: [PATCH 3/4] Update tests --- tests/test_schema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_schema.py b/tests/test_schema.py index a05fdf6b92..b69b61762f 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -217,6 +217,7 @@ def test_make_skeleton_schema(self): self.schema_obj.pipeline_manifest["description"] = "Test pipeline" self.schema_obj.make_skeleton_schema() self.schema_obj.validate_schema(self.schema_obj.schema) + assert self.schema_obj.schema['title'] == "nf-core/test pipeline parameters" def test_make_skeleton_schema_absent_name(self): """Test making a new schema skeleton""" @@ -224,6 +225,7 @@ def test_make_skeleton_schema_absent_name(self): self.schema_obj.pipeline_manifest["description"] = "Test pipeline" self.schema_obj.make_skeleton_schema() self.schema_obj.validate_schema(self.schema_obj.schema) + assert self.schema_obj.schema['title'] == "wf pipeline parameters" def test_get_wf_params(self): """Test getting the workflow parameters from a pipeline""" From 2975f6af13bd4476739aadb499d6c707ddefa02a Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Wed, 20 Mar 2024 14:23:08 +0000 Subject: [PATCH 4/4] [automated] Fix code linting --- tests/test_schema.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_schema.py b/tests/test_schema.py index b69b61762f..e0921908d4 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -217,7 +217,7 @@ def test_make_skeleton_schema(self): self.schema_obj.pipeline_manifest["description"] = "Test pipeline" self.schema_obj.make_skeleton_schema() self.schema_obj.validate_schema(self.schema_obj.schema) - assert self.schema_obj.schema['title'] == "nf-core/test pipeline parameters" + assert self.schema_obj.schema["title"] == "nf-core/test pipeline parameters" def test_make_skeleton_schema_absent_name(self): """Test making a new schema skeleton""" @@ -225,7 +225,7 @@ def test_make_skeleton_schema_absent_name(self): self.schema_obj.pipeline_manifest["description"] = "Test pipeline" self.schema_obj.make_skeleton_schema() self.schema_obj.validate_schema(self.schema_obj.schema) - assert self.schema_obj.schema['title'] == "wf pipeline parameters" + assert self.schema_obj.schema["title"] == "wf pipeline parameters" def test_get_wf_params(self): """Test getting the workflow parameters from a pipeline"""