Repository: Project-MONAI/MONAI

Issue:
Add default meta/logging file inputs on bundle run function
This feature request comes from:
https://github.com/Project-MONAI/model-zoo/issues/319


Discussion:

Resolving patch:
diff --git a/monai/bundle/scripts.py b/monai/bundle/scripts.py
--- a/monai/bundle/scripts.py
+++ b/monai/bundle/scripts.py
@@ -617,7 +617,7 @@ def run(
     **override: Any,
 ) -> list:
     """
-    Specify `meta_file` and `config_file` to run monai bundle components and workflows.
+    Specify `config_file` to run monai bundle components and workflows.
 
     Typical usage examples:
 
@@ -642,10 +642,12 @@ def run(
     Args:
         runner_id: ID name of the expected config expression to run, can also be a list of IDs to run in order.
         meta_file: filepath of the metadata file, if it is a list of file paths, the content of them will be merged.
+            Default to "configs/metadata.json", which is commonly used for bundles in MONAI model zoo.
         config_file: filepath of the config file, if `None`, must be provided in `args_file`.
             if it is a list of file paths, the content of them will be merged.
-        logging_file: config file for `logging` module in the program, default to `None`. for more details:
+        logging_file: config file for `logging` module in the program. for more details:
             https://docs.python.org/3/library/logging.config.html#logging.config.fileConfig.
+            Default to "configs/logging.conf", which is commonly used for bundles in MONAI model zoo.
         tracking: enable the experiment tracking feature at runtime with optionally configurable and extensible.
             if "mlflow", will add `MLFlowHandler` to the parsed bundle with default logging settings,
             if other string, treat it as file path to load the logging settings, if `dict`,
@@ -719,18 +721,30 @@ def run(
         warnings.warn("`config_file` not provided for 'monai.bundle run'.")
     _log_input_summary(tag="run", args=_args)
     config_file_, meta_file_, runner_id_, logging_file_, tracking_ = _pop_args(
-        _args, config_file=None, meta_file=None, runner_id="", logging_file=None, tracking=None
+        _args,
+        config_file=None,
+        meta_file="configs/metadata.json",
+        runner_id="",
+        logging_file="configs/logging.conf",
+        tracking=None,
     )
     if logging_file_ is not None:
         if not os.path.exists(logging_file_):
-            raise FileNotFoundError(f"can't find the logging config file: {logging_file_}.")
-        logger.info(f"set logging properties based on config: {logging_file_}.")
-        fileConfig(logging_file_, disable_existing_loggers=False)
+            if logging_file_ == "configs/logging.conf":
+                warnings.warn("default logging file in 'configs/logging.conf' not exists, skip logging.")
+            else:
+                raise FileNotFoundError(f"can't find the logging config file: {logging_file_}.")
+        else:
+            logger.info(f"set logging properties based on config: {logging_file_}.")
+            fileConfig(logging_file_, disable_existing_loggers=False)
 
     parser = ConfigParser()
     parser.read_config(f=config_file_)
     if meta_file_ is not None:
-        parser.read_meta(f=meta_file_)
+        if not os.path.exists(meta_file_):
+            warnings.warn("default meta file in 'configs/metadata.json' not exists.")
+        else:
+            parser.read_meta(f=meta_file_)
 
     # the rest key-values in the _args are to override config content
     parser.update(pairs=_args)


Test patch: