Skip to content

Commit 7228bcf

Browse files
authored
Merge pull request #3432 from mashehu/fix-launch-cli-draft
remove hard coded key prefix for schema in launcher
2 parents a0d5270 + 9f973ab commit 7228bcf

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
### General
3434

35+
- remove hard coded key prefix for schema in launcher ([#3432](https://github.com/nf-core/tools/pull/3432))
3536
- output passed to write_params_file as Path object ([#3435](https://github.com/nf-core/tools/pull/3435))
3637
- chore(deps): update python:3.12-slim docker digest to 69ce3ae ([#3433](https://github.com/nf-core/tools/pull/3433))
3738
- chore(deps): update dependency pytest-textual-snapshot to v1.1.0 ([#3439](https://github.com/nf-core/tools/pull/3439))

nf_core/pipelines/launch.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,20 @@ def prompt_schema(self):
406406
"""Go through the pipeline schema and prompt user to change defaults"""
407407
answers = {}
408408
# Start with the subschema in the definitions - use order of allOf
409-
definitions_schemas = self.schema_obj.schema.get("$defs", self.schema_obj.schema.get("definitions", {})).items()
409+
defs_notation = self.schema_obj.defs_notation
410+
log.debug(f"defs_notation: {defs_notation}")
411+
definitions_schemas = self.schema_obj.schema.get(defs_notation, {})
410412
for allOf in self.schema_obj.schema.get("allOf", []):
411-
d_key = allOf["$ref"][14:]
412-
answers.update(self.prompt_group(d_key, definitions_schemas[d_key]))
413+
# Extract the key from the $ref by removing the prefix
414+
ref_value = allOf["$ref"]
415+
prefix = f"#/{defs_notation}/"
416+
d_key = ref_value[len(prefix) :] if ref_value.startswith(prefix) else ref_value
417+
log.debug(f"d_key: {d_key}")
418+
try:
419+
answers.update(self.prompt_group(d_key, definitions_schemas[d_key]))
420+
except KeyError:
421+
log.warning(f"Could not find definition for {d_key}")
422+
continue
413423

414424
# Top level schema params
415425
for param_id, param_obj in self.schema_obj.schema.get("properties", {}).items():

0 commit comments

Comments
 (0)