Skip to content

Commit a1c4371

Browse files
6602 Update bundle properties (#6607)
Fixes #6602 . ### Description This PR is used to change the required properties of bundle workflow. It also modifies the `_check_optional_id` function to ensure `ref` is existing. ### 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 <vennw@nvidia.com>
1 parent 4e53af4 commit a1c4371

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

monai/bundle/properties.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@
5858
BundleProperty.REQUIRED: True,
5959
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}dataset",
6060
},
61-
"train_dataset_data": {
62-
BundleProperty.DESC: "data source for the training dataset.",
63-
BundleProperty.REQUIRED: True,
64-
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}dataset{ID_SEP_KEY}data",
65-
},
6661
"train_inferer": {
6762
BundleProperty.DESC: "MONAI Inferer object to execute the model computation in training.",
6863
BundleProperty.REQUIRED: True,
6964
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}inferer",
7065
},
66+
"train_dataset_data": {
67+
BundleProperty.DESC: "data source for the training dataset.",
68+
BundleProperty.REQUIRED: False,
69+
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}dataset{ID_SEP_KEY}data",
70+
BundlePropertyConfig.REF_ID: None, # no reference to this ID
71+
},
7172
"train_handlers": {
7273
BundleProperty.DESC: "event-handlers for the training logic.",
7374
BundleProperty.REQUIRED: False,
@@ -169,11 +170,6 @@
169170
BundleProperty.REQUIRED: True,
170171
BundlePropertyConfig.ID: "dataset",
171172
},
172-
"dataset_data": {
173-
BundleProperty.DESC: "data source for the inference / evaluation dataset.",
174-
BundleProperty.REQUIRED: True,
175-
BundlePropertyConfig.ID: f"dataset{ID_SEP_KEY}data",
176-
},
177173
"evaluator": {
178174
BundleProperty.DESC: "inference / evaluation workflow engine.",
179175
BundleProperty.REQUIRED: True,
@@ -189,6 +185,12 @@
189185
BundleProperty.REQUIRED: True,
190186
BundlePropertyConfig.ID: "inferer",
191187
},
188+
"dataset_data": {
189+
BundleProperty.DESC: "data source for the inference / evaluation dataset.",
190+
BundleProperty.REQUIRED: False,
191+
BundlePropertyConfig.ID: f"dataset{ID_SEP_KEY}data",
192+
BundlePropertyConfig.REF_ID: None, # no reference to this ID
193+
},
192194
"handlers": {
193195
BundleProperty.DESC: "event-handlers for the inference / evaluation logic.",
194196
BundleProperty.REQUIRED: False,

monai/bundle/workflows.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def _check_optional_id(self, name: str, property: dict) -> bool:
371371
# no ID of reference config item, skipping check for this optional property
372372
return True
373373
# check validation `validator` and `interval` properties as the handler index of ValidationHandler is unknown
374+
ref: str | None = None
374375
if name in ("evaluator", "val_interval"):
375376
if f"train{ID_SEP_KEY}handlers" in self.parser:
376377
for h in self.parser[f"train{ID_SEP_KEY}handlers"]:

monai/utils/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ class BundlePropertyConfig(StrEnum):
671671
additional bundle property fields for config based bundle workflow:
672672
`ID` is the config item ID of the property.
673673
`REF_ID` is the ID of config item which is supposed to refer to this property.
674+
For properties that do not have `REF_ID`, `None` should be set.
674675
this field is only useful to check the optional property ID.
675676
"""
676677

0 commit comments

Comments
 (0)