From 5d54718e6e7ce3ad283dd8a99c6d08f5862f528e Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 28 Jan 2025 17:35:16 +0100 Subject: [PATCH 1/4] remove hard coded key prefix in schema --- nf_core/pipelines/launch.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/nf_core/pipelines/launch.py b/nf_core/pipelines/launch.py index aab0ec4287..86cde9a9c7 100644 --- a/nf_core/pipelines/launch.py +++ b/nf_core/pipelines/launch.py @@ -406,10 +406,21 @@ def prompt_schema(self): """Go through the pipeline schema and prompt user to change defaults""" answers = {} # Start with the subschema in the definitions - use order of allOf - definitions_schemas = self.schema_obj.schema.get("$defs", self.schema_obj.schema.get("definitions", {})).items() + defs_notation = self.schema_obj.defs_notation + log.debug(f"defs_notation: {defs_notation}") + definitions_schemas = self.schema_obj.schema.get(defs_notation, {}).items() for allOf in self.schema_obj.schema.get("allOf", []): - d_key = allOf["$ref"][14:] - answers.update(self.prompt_group(d_key, definitions_schemas[d_key])) + # Extract the key from the $ref by removing the prefix + ref_value = allOf["$ref"] + prefix = f"#/{defs_notation}/" + d_key = ref_value[len(prefix) :] if ref_value.startswith(prefix) else ref_value + log.debug(f"d_key: {d_key}") + try: + group_obj = dict(definitions_schemas)[d_key] + answers.update(self.prompt_group(d_key, group_obj)) + except KeyError: + log.warning(f"Could not find definition for {d_key}") + continue # Top level schema params for param_id, param_obj in self.schema_obj.schema.get("properties", {}).items(): From aa05cf744d252043b2867442d8e6d92c81694334 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Tue, 28 Jan 2025 16:38:26 +0000 Subject: [PATCH 2/4] [automated] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 653f7cca6e..bb465d0384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ ### General +- remove hard coded key prefix in schema ([#3432](https://github.com/nf-core/tools/pull/3432)) + ## [v3.2.0 - Pewter Pangolin](https://github.com/nf-core/tools/releases/tag/3.2.0) - [2025-01-27] ### Template From 717a0bb9c8de6c23ac8ed51c49bbcf5da88f4ce9 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Wed, 29 Jan 2025 06:52:08 +0000 Subject: [PATCH 3/4] [automated] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb465d0384..3966b97246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ ### General -- remove hard coded key prefix in schema ([#3432](https://github.com/nf-core/tools/pull/3432)) +- remove hard coded key prefix for schema in launcher ([#3432](https://github.com/nf-core/tools/pull/3432)) ## [v3.2.0 - Pewter Pangolin](https://github.com/nf-core/tools/releases/tag/3.2.0) - [2025-01-27] From 0265b618d9904d135edfa629872a43228e40c584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20H=C3=B6rtenhuber?= Date: Thu, 30 Jan 2025 07:49:02 +0100 Subject: [PATCH 4/4] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: JĂșlia Mir Pedrol --- nf_core/pipelines/launch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nf_core/pipelines/launch.py b/nf_core/pipelines/launch.py index 86cde9a9c7..364da1c113 100644 --- a/nf_core/pipelines/launch.py +++ b/nf_core/pipelines/launch.py @@ -408,7 +408,7 @@ def prompt_schema(self): # Start with the subschema in the definitions - use order of allOf defs_notation = self.schema_obj.defs_notation log.debug(f"defs_notation: {defs_notation}") - definitions_schemas = self.schema_obj.schema.get(defs_notation, {}).items() + definitions_schemas = self.schema_obj.schema.get(defs_notation, {}) for allOf in self.schema_obj.schema.get("allOf", []): # Extract the key from the $ref by removing the prefix ref_value = allOf["$ref"] @@ -416,8 +416,7 @@ def prompt_schema(self): d_key = ref_value[len(prefix) :] if ref_value.startswith(prefix) else ref_value log.debug(f"d_key: {d_key}") try: - group_obj = dict(definitions_schemas)[d_key] - answers.update(self.prompt_group(d_key, group_obj)) + answers.update(self.prompt_group(d_key, definitions_schemas[d_key])) except KeyError: log.warning(f"Could not find definition for {d_key}") continue