Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'yliu/bundle' into bundle"
Browse files Browse the repository at this point in the history
This reverts commit e941dde, reversing
changes made to 5aa4f38.
  • Loading branch information
KumoLiu committed Mar 26, 2024
1 parent e941dde commit 06d9a34
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 140 deletions.
10 changes: 4 additions & 6 deletions monai/bundle/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
from pathlib import Path
from typing import Any, Sequence

from monai.config import PathLike
from monai.apps.utils import get_logger
from monai.bundle.config_parser import ConfigParser
from monai.bundle.properties import InferProperties, MetaProperties, TrainProperties
from monai.bundle.utils import DEFAULT_EXP_MGMT_SETTINGS, EXPR_KEY, ID_REF_KEY, ID_SEP_KEY
from monai.config import PathLike
from monai.utils import BundleProperty, BundlePropertyConfig, deprecated_arg, deprecated_arg_default, ensure_tuple

__all__ = ["BundleWorkflow", "ConfigWorkflow"]
Expand Down Expand Up @@ -62,9 +62,7 @@ class BundleWorkflow(ABC):
new_name="workflow_type",
msg_suffix="please use `workflow_type` instead.",
)
def __init__(
self, workflow_type: str | None = None, workflow: str | None = None, properties_path: PathLike | None = None
):
def __init__(self, workflow_type: str | None = None, workflow: str | None = None, properties_path: PathLike | None = None):
workflow_type = workflow if workflow is not None else workflow_type
if workflow_type is None and properties_path is None:
self.properties = copy(MetaProperties)
Expand All @@ -78,10 +76,10 @@ def __init__(
self.properties = json.load(json_file)
self.workflow_type = None
return
if workflow_type.lower() in self.supported_train_type: # type: ignore[union-attr]
if workflow_type.lower() in self.supported_train_type:
self.properties = {**TrainProperties, **MetaProperties}
self.workflow_type = "train"
elif workflow_type.lower() in self.supported_infer_type: # type: ignore[union-attr]
elif workflow_type.lower() in self.supported_infer_type:
self.properties = {**InferProperties, **MetaProperties}
self.workflow_type = "infer"
else:
Expand Down
10 changes: 2 additions & 8 deletions tests/test_bundle_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@

TEST_CASE_2 = [os.path.join(os.path.dirname(__file__), "testing_data", "inference.yaml")]

TEST_CASE_3 = [
os.path.join(os.path.dirname(__file__), "testing_data", "config_fl_train.json"),
os.path.join(os.path.dirname(__file__), "testing_data", "fl_train_properties.json"),
]
TEST_CASE_3 = [os.path.join(os.path.dirname(__file__), "testing_data", "config_fl_train.json")]


class TestBundleWorkflow(unittest.TestCase):
Expand Down Expand Up @@ -104,11 +101,10 @@ def test_inference_config(self, config_file):
logging_file=os.path.join(os.path.dirname(__file__), "testing_data", "logging.conf"),
**override,
)
inferer.add_property(name="inferer", required=True, config_id="inferer")
self._test_inferer(inferer)

@parameterized.expand([TEST_CASE_3])
def test_train_config(self, config_file, properties_path):
def test_train_config(self, config_file):
# test standard MONAI model-zoo config workflow
trainer = ConfigWorkflow(
workflow_type="train",
Expand All @@ -117,7 +113,6 @@ def test_train_config(self, config_file, properties_path):
init_id="initialize",
run_id="run",
final_id="finalize",
properties_path=properties_path,
)
# should initialize before parsing any bundle content
trainer.initialize()
Expand Down Expand Up @@ -149,7 +144,6 @@ def test_train_config(self, config_file, properties_path):
def test_non_config(self):
# test user defined python style workflow
inferer = NonConfigWorkflow(self.filename, self.data_dir)
inferer.add_property(name="inferer", required=True)
self._test_inferer(inferer)


Expand Down
126 changes: 0 additions & 126 deletions tests/testing_data/fl_train_properties.json

This file was deleted.

0 comments on commit 06d9a34

Please sign in to comment.