Skip to content

Commit f98c74f

Browse files
6559 update check properties (#6560)
Fixes #6559 . ### Description This PR is used to skip optional property checks on expression based content in a bundle config. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Yiheng Wang <[email protected]> Signed-off-by: monai-bot <[email protected]> Co-authored-by: monai-bot <[email protected]>
1 parent 9d6ccce commit f98c74f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

monai/bundle/workflows.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ def _check_optional_id(self, name: str, property: dict) -> bool:
378378
ref = h.get(ref_id, None)
379379
else:
380380
ref = self.parser.get(ref_id, None)
381-
if ref is not None and ref != ID_REF_KEY + id:
381+
# for reference IDs that not refer to a property directly but using expressions, skip the check
382+
if ref is not None and not ref.startswith(EXPR_KEY) and ref != ID_REF_KEY + id:
382383
return False
383384
return True
384385

tests/test_bundle_workflow.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ def test_train_config(self, config_file):
117117
trainer.initialize()
118118
# test required and optional properties
119119
self.assertListEqual(trainer.check_properties(), [])
120+
# test override optional properties
121+
trainer.parser.update(
122+
pairs={"validate#evaluator#postprocessing": "$@validate#postprocessing if @val_interval > 0 else None"}
123+
)
124+
trainer.initialize()
125+
self.assertListEqual(trainer.check_properties(), [])
120126
# test read / write the properties
121127
dataset = trainer.train_dataset
122128
self.assertTrue(isinstance(dataset, Dataset))

0 commit comments

Comments
 (0)