class_docstr: Specification for the config-based bundle workflow.
  Standardized the `initialize`, `run`, `finalize` behavior in a config-based training, evaluation, or inference.
  Before `run`, we add bundle root directory to Python search directories automatically.
  For more information: https://docs.monai.io/en/latest/mb_specification.html.
  
  Args:
      config_file: filepath of the config file, if this is a list of file paths, their contents will be merged in order.
      meta_file: filepath of the metadata file, if this is a list of file paths, their contents will be merged in order.
          If None, default to "configs/metadata.json", which is commonly used for bundles in MONAI model zoo.
      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.
          If None, default to "configs/logging.conf", which is commonly used for bundles in MONAI model zoo.
      init_id: ID name of the expected config expression to initialize before running, default to "initialize".
          allow a config to have no `initialize` logic and the ID.
      run_id: ID name of the expected config expression to run, default to "run".
          to run the config, the target config must contain this ID.
      final_id: ID name of the expected config expression to finalize after running, default to "finalize".
          allow a config to have no `finalize` logic and the ID.
      tracking: if not None, enable the experiment tracking at runtime with optionally configurable and extensible.
          if "mlflow", will add `MLFlowHandler` to the parsed bundle with default tracking settings,
          if other string, treat it as file path to load the tracking settings.
          if `dict`, treat it as tracking settings.
          will patch the target config content with `tracking handlers` and the top-level items of `configs`.
          for detailed usage examples, please check the tutorial:
          https://github.com/Project-MONAI/tutorials/blob/main/experiment_management/bundle_integrate_mlflow.ipynb.
      workflow_type: specifies the workflow type: "train" or "training" for a training workflow,
          or "infer", "inference", "eval", "evaluation" for a inference workflow,
          other unsupported string will raise a ValueError.
          default to `None` for common workflow.
      workflow: specifies the workflow type: "train" or "training" for a training workflow,
          or "infer", "inference", "eval", "evaluation" for a inference workflow,
          other unsupported string will raise a ValueError.
          default to `None` for common workflow.
      override: id-value pairs to override or add the corresponding config content.
          e.g. ``--net#input_chns 42``, ``--net %/data/other.json#net_arg``
class_docstr_tok: ["Specification","for","the","config-based","bundle","workflow",".","Standardized","the","`","initialize","`",",","`","run","`",",","`","finalize","`","behavior","in","a","config-based","training",",","evaluation",",","or","inference",".","Before","`","run","`",",","we","add","bundle","root","directory","to","Python","search","directories","automatically",".","For","more","information",":","https",":","\/\/docs.monai.io\/en\/latest\/mb_specification.html",".","Args",":","config_file",":","filepath","of","the","config","file",",","if","this","is","a","list","of","file","paths",",","their","contents","will","be","merged","in","order",".","meta_file",":","filepath","of","the","metadata","file",",","if","this","is","a","list","of","file","paths",",","their","contents","will","be","merged","in","order",".","If","None",",","default","to","``","configs\/metadata.json","''",",","which","is","commonly","used","for","bundles","in","MONAI","model","zoo",".","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",".","If","None",",","default","to","``","configs\/logging.conf","''",",","which","is","commonly","used","for","bundles","in","MONAI","model","zoo",".","init_id",":","ID","name","of","the","expected","config","expression","to","initialize","before","running",",","default","to","``","initialize","''",".","allow","a","config","to","have","no","`","initialize","`","logic","and","the","ID",".","run_id",":","ID","name","of","the","expected","config","expression","to","run",",","default","to","``","run","''",".","to","run","the","config",",","the","target","config","must","contain","this","ID",".","final_id",":","ID","name","of","the","expected","config","expression","to","finalize","after","running",",","default","to","``","finalize","''",".","allow","a","config","to","have","no","`","finalize","`","logic","and","the","ID",".","tracking",":","if","not","None",",","enable","the","experiment","tracking","at","runtime","with","optionally","configurable","and","extensible",".","if","``","mlflow","''",",","will","add","`","MLFlowHandler","`","to","the","parsed","bundle","with","default","tracking","settings",",","if","other","string",",","treat","it","as","file","path","to","load","the","tracking","settings",".","if","`","dict","`",",","treat","it","as","tracking","settings",".","will","patch","the","target","config","content","with","`","tracking","handlers","`","and","the","top-level","items","of","`","configs","`",".","for","detailed","usage","examples",",","please","check","the","tutorial",":","https",":","\/\/github.com\/Project-MONAI\/tutorials\/blob\/main\/experiment_management\/bundle_integrate_mlflow.ipynb",".","workflow_type",":","specifies","the","workflow","type",":","``","train","''","or","``","training","''","for","a","training","workflow",",","or","``","infer","''",",","``","inference","''",",","``","eval","''",",","``","evaluation","''","for","a","inference","workflow",",","other","unsupported","string","will","raise","a","ValueError",".","default","to","`","None","`","for","common","workflow",".","workflow",":","specifies","the","workflow","type",":","``","train","''","or","``","training","''","for","a","training","workflow",",","or","``","infer","''",",","``","inference","''",",","``","eval","''",",","``","evaluation","''","for","a","inference","workflow",",","other","unsupported","string","will","raise","a","ValueError",".","default","to","`","None","`","for","common","workflow",".","override",":","id-value","pairs","to","override","or","add","the","corresponding","config","content",".","e.g",".","``","--","net","#","input_chns","42","``",",","``","--","net","%","\/data\/other.json","#","net_arg","``"]
docstr: Patch the loaded bundle config with a new handler logic to enable experiment tracking features.
  
  Args:
      parser: loaded config content to patch the handler.
      settings: settings for the experiment tracking, should follow the pattern of default settings.
docstr_tok: ["Patch","the","loaded","bundle","config","with","a","new","handler","logic","to","enable","experiment","tracking","features",".","Args",":","parser",":","loaded","config","content","to","patch","the","handler",".","settings",":","settings","for","the","experiment","tracking",",","should","follow","the","pattern","of","default","settings","."]
code: def patch_bundle_tracking(
      parser: ConfigParser, settings: dict
  ) -> None:
      """
      Patch the loaded bundle config with a new handler logic to enable experiment tracking features.
  
      Args:
          parser: loaded config content to patch the handler.
          settings: settings for the experiment tracking, should follow the pattern of default settings.
  
      """
      for k, v in settings["configs"].items():
          if k in settings["handlers_id"]:
              engine = parser.get(settings["handlers_id"][k]["id"])
              if engine is not None:
                  handlers = parser.get(
                      settings["handlers_id"][k]["handlers"]
                  )
                  if handlers is None:
                      engine[
                          "train_handlers"
                          if k == "trainer"
                          else "val_handlers"
                      ] = [v]
                  else:
                      handlers.append(v)
          elif k not in parser:
              parser[k] = v
      # save the executed config into file
      default_name = f"config_{time.strftime('%Y%m%d_%H%M%S')}.json"
      filepath = parser.get("execute_config", None)
      if filepath is None:
          if "output_dir" not in parser:
              # if no "output_dir" in the bundle config, default to "<bundle root>/eval"
              parser[
                  "output_dir"
              ] = f"{EXPR_KEY}{ID_REF_KEY}bundle_root + '/eval'"
          # experiment management tools can refer to this config item to track the config info
          parser["execute_config"] = (
              parser["output_dir"] + f" + '/{default_name}'"
          )
          filepath = os.path.join(
              parser.get_parsed_content("output_dir"), default_name
          )
      Path(filepath).parent.mkdir(parents=True, exist_ok=True)
      parser.export_config_file(parser.get(), filepath)
  
imports: from __future__ import annotations
  import os
  import sys
  import time
  from abc import ABC, abstractmethod
  from copy import copy
  from logging.config import fileConfig
  from pathlib import Path
  from typing import Any, Sequence
  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.utils import BundleProperty, BundlePropertyConfig, deprecated_arg, deprecated_arg_default, ensure_tuple
label_desc: Use image node_id 12 for calling the ConfigWorkflow obj's underlying member method code with example usage: obj.patch_bundle_tracking(parser, settings) without return types