Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
42a45e0
Merge pull request #19 from Project-MONAI/master
Nic-Ma Feb 1, 2021
cd16a13
Merge pull request #32 from Project-MONAI/master
Nic-Ma Feb 24, 2021
6f87afd
Merge pull request #180 from Project-MONAI/dev
Nic-Ma Jul 22, 2021
f398298
Merge pull request #214 from Project-MONAI/dev
Nic-Ma Sep 8, 2021
ec463d6
Merge pull request #397 from Project-MONAI/dev
Nic-Ma Apr 4, 2022
ca62306
Merge pull request #429 from Project-MONAI/dev
Nic-Ma Jul 8, 2022
5de9934
Merge pull request #456 from Project-MONAI/dev
Nic-Ma Jan 6, 2023
4b71563
[DLMED] add base class
Nic-Ma Jan 6, 2023
713d220
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 10, 2023
6b63f3e
Merge branch 'Project-MONAI:main' into main
Nic-Ma Jan 11, 2023
b7c7730
Merge pull request #457 from Nic-Ma/main
Nic-Ma Jan 11, 2023
8e744d4
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 11, 2023
b6b68e8
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 13, 2023
d7946ca
[DLMED] add workflow
Nic-Ma Jan 13, 2023
d8288fd
[DLMED] add subclasses
Nic-Ma Jan 13, 2023
e18eb8d
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 17, 2023
288398d
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 17, 2023
200ba01
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 18, 2023
bd639a9
[DLMED] add attributes
Nic-Ma Jan 18, 2023
328a19a
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Jan 31, 2023
675323f
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 2, 2023
85adf84
[DLMED] fix typo
Nic-Ma Feb 2, 2023
2e4148a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 2, 2023
4549b64
[DLMED] complete properties
Nic-Ma Feb 2, 2023
5243a21
[DLMED] complete subclass
Nic-Ma Feb 2, 2023
4e9342c
[DLMED] fix typo
Nic-Ma Feb 2, 2023
c2b109e
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 3, 2023
0967d7c
[DLMED] update script
Nic-Ma Feb 4, 2023
7edd35f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2023
999d226
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 8, 2023
6d0b67a
[DLMED] add Bundle API and fix integration test
Nic-Ma Feb 8, 2023
53a49fd
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 8, 2023
1998b62
[DLMED] restore tests
Nic-Ma Feb 8, 2023
511f74a
[DLMED] fix flake8
Feb 8, 2023
9b4bf4f
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 17, 2023
aae3fa2
[DLMED] totally refactored Workflow, added all the property check logic
Nic-Ma Feb 17, 2023
198be42
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 17, 2023
5213676
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Feb 22, 2023
900bfc7
[DLMED] add unit tests
Nic-Ma Feb 22, 2023
2022fb6
[DLMED] add non-config unit tests
Nic-Ma Feb 22, 2023
ba0eae1
[DLMED] simplify unit tests
Nic-Ma Feb 22, 2023
e9c9952
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Mar 7, 2023
25c5157
[DLMED] adjust to follow dev
Nic-Ma Mar 7, 2023
ac8cd15
[DLMED] totally refactor according to comments
Nic-Ma Mar 7, 2023
f63f56a
[DLMED] restore runner_id
Nic-Ma Mar 7, 2023
a3f9e2b
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Mar 7, 2023
542161d
[DLMED] update according to comments
Nic-Ma Mar 9, 2023
16fb027
[DLMED] use prop_id instead of pid
Nic-Ma Mar 9, 2023
4b7dbff
[DLMED] remove draft code
Nic-Ma Mar 9, 2023
42ff0d8
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Mar 9, 2023
eaa0b36
[DLMED] add init_id and final_id
Nic-Ma Mar 10, 2023
24791c6
[DLMED] reduce exception
Nic-Ma Mar 10, 2023
2d89cbf
[DLMED] add all the properties
Nic-Ma Mar 10, 2023
658dda2
[DLMED] add training test
Nic-Ma Mar 10, 2023
1adfa89
[DLMED] add doc-string and fix all the format
Nic-Ma Mar 10, 2023
f669c85
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Mar 13, 2023
62bd1b7
[DLMED] skip min test
Nic-Ma Mar 13, 2023
86d4909
[DLMED] fix wrong doc format
Nic-Ma Mar 13, 2023
c2fd288
Merge branch 'dev' into 5821-bundle-interface
Nic-Ma Mar 15, 2023
12053ae
[DLMED] simplify experiment tracking example
Nic-Ma Mar 15, 2023
819637c
[DLMED] fix typo
Nic-Ma Mar 15, 2023
1a8dbe3
[DLMED] update DESC
Nic-Ma Mar 15, 2023
2d03553
[DLMED] update to use EXPR_KEY, ID_REF_KEY, ID_SEP_KEY
Nic-Ma Mar 15, 2023
9ba7177
[DLMED] add specification link
Nic-Ma Mar 15, 2023
6747172
[DLMED] update doc
Nic-Ma Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion monai/bundle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from .config_item import ComponentLocator, ConfigComponent, ConfigExpression, ConfigItem, Instantiable
from .config_parser import ConfigParser
from .properties import InferProperties, TrainProperties
from .reference_resolver import ReferenceResolver
from .scripts import (
ckpt_export,
Expand All @@ -22,7 +23,6 @@
get_bundle_versions,
init_bundle,
load,
patch_bundle_tracking,
run,
verify_metadata,
verify_net_in_out,
Expand All @@ -36,3 +36,4 @@
MACRO_KEY,
load_bundle_config,
)
from .workflows import BundleWorkflow, ConfigWorkflow
192 changes: 192 additions & 0 deletions monai/bundle/properties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
The predefined properties for a bundle workflow, other applications can leverage the properties
to interact with the bundle workflow.
Some properties are required and some are optional, optional properties mean: if some component of the
bundle workflow refer to the property, the property must be defined, otherwise, the property can be None.
Every item in this `TrainProperties` or `InferProperties` dictionary is a property,
the key is the property name and the values include:
1. description.
2. whether it's a required property.
3. config item ID name (only applicable when the bundle workflow is defined in config).
4. reference config item ID name (only applicable when the bundle workflow is defined in config).

"""

from __future__ import annotations

from monai.bundle.utils import ID_SEP_KEY
from monai.utils import BundleProperty, BundlePropertyConfig

TrainProperties = {
"bundle_root": {
BundleProperty.DESC: "root path of the bundle.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "bundle_root",
},
"device": {
BundleProperty.DESC: "target device to execute the bundle workflow.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "device",
},
"dataset_dir": {
BundleProperty.DESC: "directory path of the dataset.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "dataset_dir",
},
"trainer": {
BundleProperty.DESC: "training workflow engine.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}trainer",
},
"max_epochs": {
BundleProperty.DESC: "max number of epochs to execute the training.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}trainer{ID_SEP_KEY}max_epochs",
},
"train_dataset": {
BundleProperty.DESC: "PyTorch dataset object for the training logic.",
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_handlers": {
BundleProperty.DESC: "event-handlers for the training logic.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}handlers",
BundlePropertyConfig.REF_ID: f"train{ID_SEP_KEY}trainer{ID_SEP_KEY}train_handlers",
},
"train_preprocessing": {
BundleProperty.DESC: "preprocessing for the training input data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}preprocessing",
BundlePropertyConfig.REF_ID: f"train{ID_SEP_KEY}dataset{ID_SEP_KEY}transform",
},
"train_postprocessing": {
BundleProperty.DESC: "postprocessing for the training model output data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}postprocessing",
BundlePropertyConfig.REF_ID: f"train{ID_SEP_KEY}trainer{ID_SEP_KEY}postprocessing",
},
"train_key_metric": {
BundleProperty.DESC: "key metric to compute on the training data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"train{ID_SEP_KEY}key_metric",
BundlePropertyConfig.REF_ID: f"train{ID_SEP_KEY}trainer{ID_SEP_KEY}key_train_metric",
},
"evaluator": {
BundleProperty.DESC: "validation workflow engine.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}evaluator",
BundlePropertyConfig.REF_ID: "validator", # this REF_ID is the arg name of `ValidationHandler`
},
"val_interval": {
BundleProperty.DESC: "validation interval during the training.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: "val_interval",
BundlePropertyConfig.REF_ID: "interval", # this REF_ID is the arg name of `ValidationHandler`
},
"val_handlers": {
BundleProperty.DESC: "event-handlers for the validation logic.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}handlers",
BundlePropertyConfig.REF_ID: f"validate{ID_SEP_KEY}evaluator{ID_SEP_KEY}val_handlers",
},
"val_dataset": {
BundleProperty.DESC: "PyTorch dataset object for the validation logic.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}dataset",
BundlePropertyConfig.REF_ID: f"validate{ID_SEP_KEY}dataloader{ID_SEP_KEY}dataset",
},
"val_dataset_data": {
BundleProperty.DESC: "data source for the validation dataset.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}dataset{ID_SEP_KEY}data",
BundlePropertyConfig.REF_ID: None, # no reference to this ID
},
"val_inferer": {
BundleProperty.DESC: "MONAI Inferer object to execute the model computation in validation.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}inferer",
BundlePropertyConfig.REF_ID: f"validate{ID_SEP_KEY}evaluator{ID_SEP_KEY}inferer",
},
"val_preprocessing": {
BundleProperty.DESC: "preprocessing for the validation input data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}preprocessing",
BundlePropertyConfig.REF_ID: f"validate{ID_SEP_KEY}dataset{ID_SEP_KEY}transform",
},
"val_postprocessing": {
BundleProperty.DESC: "postprocessing for the validation model output data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}postprocessing",
BundlePropertyConfig.REF_ID: f"validate{ID_SEP_KEY}evaluator{ID_SEP_KEY}postprocessing",
},
"val_key_metric": {
BundleProperty.DESC: "key metric to compute on the validation data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: f"validate{ID_SEP_KEY}key_metric",
BundlePropertyConfig.REF_ID: f"validate{ID_SEP_KEY}evaluator{ID_SEP_KEY}key_val_metric",
},
}


InferProperties = {
"bundle_root": {
BundleProperty.DESC: "root path of the bundle.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "bundle_root",
},
"device": {
BundleProperty.DESC: "target device to execute the bundle workflow.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "device",
},
"network_def": {
BundleProperty.DESC: "network module for the inference.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "network_def",
},
"inferer": {
BundleProperty.DESC: "MONAI Inferer object to execute the model computation in inference.",
BundleProperty.REQUIRED: True,
BundlePropertyConfig.ID: "inferer",
},
"preprocessing": {
BundleProperty.DESC: "preprocessing for the input data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: "preprocessing",
BundlePropertyConfig.REF_ID: f"dataset{ID_SEP_KEY}transform",
},
"postprocessing": {
BundleProperty.DESC: "postprocessing for the model output data.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: "postprocessing",
BundlePropertyConfig.REF_ID: f"evaluator{ID_SEP_KEY}postprocessing",
},
"key_metric": {
BundleProperty.DESC: "the key metric during evaluation.",
BundleProperty.REQUIRED: False,
BundlePropertyConfig.ID: "key_metric",
BundlePropertyConfig.REF_ID: f"evaluator{ID_SEP_KEY}key_val_metric",
},
}
Loading