@@ -636,7 +636,7 @@ def run(
636636 args_file: a JSON or YAML file to provide default values for `runner_id`, `meta_file`,
637637 `config_file`, `logging`, and override pairs. so that the command line inputs can be simplified.
638638 override: id-value pairs to override or add the corresponding config content.
639- e.g. ``--net#input_chns 42``.
639+ e.g. ``--net#input_chns 42``, ``--net %/data/other.json#net_arg`` .
640640
641641 """
642642
@@ -664,7 +664,8 @@ def run(
664664 logging_file = "configs/logging.conf" ,
665665 tracking = None ,
666666 )
667- workflow = ConfigWorkflow (
667+ run_workflow (
668+ workflow = ConfigWorkflow ,
668669 config_file = config_file_ ,
669670 meta_file = meta_file_ ,
670671 logging_file = logging_file_ ,
@@ -674,9 +675,6 @@ def run(
674675 tracking = tracking_ ,
675676 ** _args ,
676677 )
677- workflow .initialize ()
678- workflow .run ()
679- workflow .finalize ()
680678
681679
682680def run_workflow (workflow : str | BundleWorkflow | None = None , args_file : str | None = None , ** kwargs : Any ) -> None :
@@ -688,23 +686,10 @@ def run_workflow(workflow: str | BundleWorkflow | None = None, args_file: str |
688686 .. code-block:: bash
689687
690688 # Execute this module as a CLI entry with default ConfigWorkflow:
691- python -m monai.bundle run --meta_file <meta path> --config_file <config path>
692-
693- # Override config values at runtime by specifying the component id and its new value:
694- python -m monai.bundle run --net#input_chns 1 ...
695-
696- # Override config values with another config file `/path/to/another.json`:
697- python -m monai.bundle run --net %/path/to/another.json ...
698-
699- # Override config values with part content of another config file:
700- python -m monai.bundle run --net %/data/other.json#net_arg ...
701-
702- # Set default args of `run` in a JSON / YAML file, help to record and simplify the command line.
703- # Other args still can override the default args at runtime:
704- python -m monai.bundle run --args_file "/workspace/data/args.json" --config_file <config path>
689+ python -m monai.bundle run_workflow --meta_file <meta path> --config_file <config path>
705690
706691 # Set the workflow to other customized BundleWorkflow subclass:
707- python -m monai.bundle run --workflow CustomizedWorkflow ...
692+ python -m monai.bundle run_workflow --workflow CustomizedWorkflow ...
708693
709694 Args:
710695 workflow: specified bundle workflow name, should be a string or class, default to "ConfigWorkflow".
@@ -722,11 +707,11 @@ def run_workflow(workflow: str | BundleWorkflow | None = None, args_file: str |
722707 if not has_built_in :
723708 workflow_class = locate (f"{ workflow_name } " ) # search dotted path
724709 if workflow_class is None :
725- raise ValueError (f"can not locate specified workflow class: { workflow_name } ." )
710+ raise ValueError (f"cannot locate specified workflow class: { workflow_name } ." )
726711 elif issubclass (workflow_name , BundleWorkflow ):
727712 workflow_class = workflow_name
728713 else :
729- raise ValueError (f"`workflow` must be the bundle workflow class name, but got: { workflow_name } ." )
714+ raise ValueError (f"argument `workflow` must be the bundle workflow class name or type, got: { workflow_name } ." )
730715
731716 workflow_ = workflow_class (** _args )
732717 workflow_ .initialize ()
0 commit comments