Repository: Project-MONAI/MONAI
File: monai/bundle/scripts.py (Python)

Code before:
        config_file=None,
        meta_file="configs/metadata.json",
        init_id="initialize",
        run_id="run",
        final_id="finalize",
        logging_file="configs/logging.conf",
        tracking=None,
    )
    workflow = ConfigWorkflow(
        config_file=config_file_,
        meta_file=meta_file_,
        logging_file=logging_file_,
        init_id=init_id_,
        run_id=run_id_,
        final_id=final_id_,
        tracking=tracking_,
        **_args,
    )
    workflow.initialize()
    workflow.run()
    workflow.finalize()


def run_workflow(workflow: str | BundleWorkflow | None = None, args_file: str | None = None, **kwargs: Any) -> None:
    """
    Specify `bundle workflow` to run monai bundle components and workflows.

    Typical usage examples:

    .. code-block:: bash

        # Execute this module as a CLI entry with default ConfigWorkflow:
        python -m monai.bundle run_workflow --meta_file <meta path> --config_file <config path>

        # Set the workflow to other customized BundleWorkflow subclass:
        python -m monai.bundle run_workflow --workflow CustomizedWorkflow ...

    Args:
        workflow: specified bundle workflow name, should be a string or class, default to "ConfigWorkflow".
        args_file: a JSON or YAML file to provide default values for this API.
            so that the command line inputs can be simplified.
        kwargs: arguments to instantiate the workflow class.

    """

    _args = _update_args(args=args_file, workflow=workflow, **kwargs)
    _log_input_summary(tag="run", args=_args)
    (workflow_name,) = _pop_args(_args, workflow=ConfigWorkflow)  # the default workflow name is "ConfigWorkflow"
    if isinstance(workflow_name, str):
        workflow_class, has_built_in = optional_import("monai.bundle", name=f"{workflow_name}")  # search built-in
        if not has_built_in:

Review comment (suggestion):
We should elaborate a little more here on what customised workflow classes would be and how they would operate. What's required here is to create a subclass of `BundleWorkflow` then pass it in or mention it by name, which you can on the command line. We should just state the user needs to provide that subclass and be available to import, the documentation for how to do that is elsewhere.

Code after:
        config_file=None,
        meta_file="configs/metadata.json",
        init_id="initialize",
        run_id="run",
        final_id="finalize",
        logging_file="configs/logging.conf",
        tracking=None,
    )
    workflow = ConfigWorkflow(
        config_file=config_file_,
        meta_file=meta_file_,
        logging_file=logging_file_,
        init_id=init_id_,
        run_id=run_id_,
        final_id=final_id_,
        tracking=tracking_,
        **_args,
    )
    workflow.initialize()
    workflow.run()
    workflow.finalize()


def run_workflow(workflow: str | BundleWorkflow | None = None, args_file: str | None = None, **kwargs: Any) -> None:
    """
    Specify `bundle workflow` to run monai bundle components and workflows.
    The workflow should be suclass of `BundleWorkflow` and be available to import.
    It can be MONAI existing bundle workflows or user customized workflows.

    Typical usage examples:

    .. code-block:: bash

        # Execute this module as a CLI entry with default ConfigWorkflow:
        python -m monai.bundle run_workflow --meta_file <meta path> --config_file <config path>

        # Set the workflow to other customized BundleWorkflow subclass:
        python -m monai.bundle run_workflow --workflow CustomizedWorkflow ...

    Args:
        workflow: specified bundle workflow name, should be a string or class, default to "ConfigWorkflow".
        args_file: a JSON or YAML file to provide default values for this API.
            so that the command line inputs can be simplified.
        kwargs: arguments to instantiate the workflow class.

    """

    _args = _update_args(args=args_file, workflow=workflow, **kwargs)
    _log_input_summary(tag="run", args=_args)
    (workflow_name,) = _pop_args(_args, workflow=ConfigWorkflow)  # the default workflow name is "ConfigWorkflow"
    if isinstance(workflow_name, str):