From 182b4676d8373bcc97acd515cda2eafc4d6a2739 Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Tue, 13 Jun 2023 12:20:18 +0800 Subject: [PATCH 1/2] Update properties Signed-off-by: Yiheng Wang --- monai/bundle/properties.py | 22 ++++++++++++---------- monai/bundle/workflows.py | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/monai/bundle/properties.py b/monai/bundle/properties.py index 744b961c16..16ecf77268 100644 --- a/monai/bundle/properties.py +++ b/monai/bundle/properties.py @@ -58,16 +58,17 @@ BundleProperty.REQUIRED: True, BundlePropertyConfig.ID: f"train{ID_SEP_KEY}dataset", }, - "train_dataset_data": { - BundleProperty.DESC: "data source for the training dataset.", - BundleProperty.REQUIRED: True, - BundlePropertyConfig.ID: f"train{ID_SEP_KEY}dataset{ID_SEP_KEY}data", - }, "train_inferer": { BundleProperty.DESC: "MONAI Inferer object to execute the model computation in training.", BundleProperty.REQUIRED: True, BundlePropertyConfig.ID: f"train{ID_SEP_KEY}inferer", }, + "train_dataset_data": { + BundleProperty.DESC: "data source for the training dataset.", + BundleProperty.REQUIRED: False, + BundlePropertyConfig.ID: f"train{ID_SEP_KEY}dataset{ID_SEP_KEY}data", + BundlePropertyConfig.REF_ID: None, # no reference to this ID + }, "train_handlers": { BundleProperty.DESC: "event-handlers for the training logic.", BundleProperty.REQUIRED: False, @@ -169,11 +170,6 @@ BundleProperty.REQUIRED: True, BundlePropertyConfig.ID: "dataset", }, - "dataset_data": { - BundleProperty.DESC: "data source for the inference / evaluation dataset.", - BundleProperty.REQUIRED: True, - BundlePropertyConfig.ID: f"dataset{ID_SEP_KEY}data", - }, "evaluator": { BundleProperty.DESC: "inference / evaluation workflow engine.", BundleProperty.REQUIRED: True, @@ -189,6 +185,12 @@ BundleProperty.REQUIRED: True, BundlePropertyConfig.ID: "inferer", }, + "dataset_data": { + BundleProperty.DESC: "data source for the inference / evaluation dataset.", + BundleProperty.REQUIRED: False, + BundlePropertyConfig.ID: f"dataset{ID_SEP_KEY}data", + BundlePropertyConfig.REF_ID: None, # no reference to this ID + }, "handlers": { BundleProperty.DESC: "event-handlers for the inference / evaluation logic.", BundleProperty.REQUIRED: False, diff --git a/monai/bundle/workflows.py b/monai/bundle/workflows.py index 3d80055674..6bd966592e 100644 --- a/monai/bundle/workflows.py +++ b/monai/bundle/workflows.py @@ -371,6 +371,7 @@ def _check_optional_id(self, name: str, property: dict) -> bool: # no ID of reference config item, skipping check for this optional property return True # check validation `validator` and `interval` properties as the handler index of ValidationHandler is unknown + ref: str | None = None if name in ("evaluator", "val_interval"): if f"train{ID_SEP_KEY}handlers" in self.parser: for h in self.parser[f"train{ID_SEP_KEY}handlers"]: From de093987e3b0964fece4d7058fdccaf33b7ac77d Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Tue, 13 Jun 2023 16:29:22 +0800 Subject: [PATCH 2/2] update docstring Signed-off-by: Yiheng Wang --- monai/utils/enums.py | 1 + 1 file changed, 1 insertion(+) diff --git a/monai/utils/enums.py b/monai/utils/enums.py index 25c747ed90..572cd9293d 100644 --- a/monai/utils/enums.py +++ b/monai/utils/enums.py @@ -671,6 +671,7 @@ class BundlePropertyConfig(StrEnum): additional bundle property fields for config based bundle workflow: `ID` is the config item ID of the property. `REF_ID` is the ID of config item which is supposed to refer to this property. + For properties that do not have `REF_ID`, `None` should be set. this field is only useful to check the optional property ID. """