From 450bb597684643eeb7d193107469647f6feb8dd3 Mon Sep 17 00:00:00 2001 From: Soumya Snigdha Kundu Date: Wed, 1 Jul 2026 16:58:39 +0100 Subject: [PATCH 1/2] fix: emit nnUNet store_true flags as bare args in train_single_model_command Boolean kwargs such as --c, --val, --use_compressed and --disable_checkpointing were forwarded as "--c True", which nnUNetv2_train rejects with "unrecognized arguments: True". Emit the flag alone when the value is True and omit it when False, leaving non-boolean args (e.g. -p) unchanged. Fixes #8237 Signed-off-by: Soumya Snigdha Kundu --- monai/apps/nnunet/nnunetv2_runner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/monai/apps/nnunet/nnunetv2_runner.py b/monai/apps/nnunet/nnunetv2_runner.py index 547e73332f..f1da6bdc1c 100644 --- a/monai/apps/nnunet/nnunetv2_runner.py +++ b/monai/apps/nnunet/nnunetv2_runner.py @@ -598,7 +598,11 @@ def train_single_model_command( for _key, _value in kwargs.items(): prefix = "-" if _key in {"p", "pretrained_weights"} else "--" - cmd += [f"{prefix}{_key}", str(_value)] + if isinstance(_value, bool): + if _value: + cmd.append(f"{prefix}{_key}") + else: + cmd += [f"{prefix}{_key}", str(_value)] cmd_str: list[str] = [str(c) for c in cmd] From d3c93d31b20eafdff0b486d1258bd30f7563a118 Mon Sep 17 00:00:00 2001 From: Soumya Snigdha Kundu Date: Wed, 1 Jul 2026 20:54:14 +0100 Subject: [PATCH 2/2] refactor: drop unused store_true_flags set after merge The generic boolean-flag handling supersedes the explicit allowlist introduced by #8944, leaving store_true_flags unused. Signed-off-by: Soumya Snigdha Kundu --- monai/apps/nnunet/nnunetv2_runner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/monai/apps/nnunet/nnunetv2_runner.py b/monai/apps/nnunet/nnunetv2_runner.py index fa2d426cb6..5d5c82801a 100644 --- a/monai/apps/nnunet/nnunetv2_runner.py +++ b/monai/apps/nnunet/nnunetv2_runner.py @@ -596,7 +596,6 @@ def train_single_model_command( if self.export_validation_probabilities: cmd.append("--npz") - store_true_flags = {"c", "val", "use_compressed", "disable_checkpointing"} for _key, _value in kwargs.items(): prefix = "-" if _key in {"p", "pretrained_weights"} else "--" if isinstance(_value, bool):