Skip to content

Commit d43bf62

Browse files
aymuos15ericspod
andauthored
fix: emit nnUNet store_true flags as bare CLI args in nnUNetV2Runner (#8968)
Fixes #8237 . ### Description The runner passed boolean flags like `--c` through as `--c True`, but nnU-Net treats these as `store_true` flags that take no value, so it errored out with `unrecognized arguments: True`. Now we emit just the bare flag when it's set, drop it when it isn't, and leave the other args alone. ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved how command-line options are passed for training and validation, so boolean settings now behave as expected. * Validation now runs through the standard training workflow with validation enabled, helping ensure more consistent results. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk> Signed-off-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 946fd4f commit d43bf62

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

monai/apps/nnunet/nnunetv2_runner.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,16 +596,13 @@ def train_single_model_command(
596596
if self.export_validation_probabilities:
597597
cmd.append("--npz")
598598

599-
store_true_flags = {"c", "val", "use_compressed", "disable_checkpointing"}
600599
for _key, _value in kwargs.items():
601-
if _key in store_true_flags:
600+
prefix = "-" if _key in {"p", "pretrained_weights"} else "--"
601+
if isinstance(_value, bool):
602602
if _value:
603-
cmd.append(f"--{_key}")
604-
elif _key in {"p", "pretrained_weights"}:
605-
if _value:
606-
cmd += [f"-{_key}", str(_value)]
603+
cmd.append(f"{prefix}{_key}")
607604
else:
608-
cmd += [f"--{_key}", str(_value)]
605+
cmd += [f"{prefix}{_key}", str(_value)]
609606

610607
cmd_str: list[str] = [str(c) for c in cmd]
611608

0 commit comments

Comments
 (0)