Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove hard coded key prefix for schema in launcher #3432

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

### General

- 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]

### Template
Expand Down
17 changes: 14 additions & 3 deletions nf_core/pipelines/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
mashehu marked this conversation as resolved.
Show resolved Hide resolved
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]
mashehu marked this conversation as resolved.
Show resolved Hide resolved
answers.update(self.prompt_group(d_key, group_obj))
mashehu marked this conversation as resolved.
Show resolved Hide resolved
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():
Expand Down
Loading