MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / __init__

Method __init__

monai/bundle/workflows.py:405–464  ·  view source on GitHub ↗
(
        self,
        config_file: str | Sequence[str],
        meta_file: str | Sequence[str] | None = None,
        logging_file: str | bool | None = None,
        init_id: str = "initialize",
        run_id: str = "run",
        final_id: str = "finalize",
        tracking: str | dict | None = None,
        workflow_type: str | None = "train",
        properties_path: PathLike | None = None,
        **override: Any,
    )

Source from the content-addressed store, hash-verified

403 """
404
405 def __init__(
406 self,
407 config_file: str | Sequence[str],
408 meta_file: str | Sequence[str] | None = None,
409 logging_file: str | bool | None = None,
410 init_id: str = "initialize",
411 run_id: str = "run",
412 final_id: str = "finalize",
413 tracking: str | dict | None = None,
414 workflow_type: str | None = "train",
415 properties_path: PathLike | None = None,
416 **override: Any,
417 ) -> None:
418 if config_file is not None:
419 _config_files = ensure_tuple(config_file)
420 config_root_path = Path(_config_files[0]).parent
421 for _config_file in _config_files:
422 _config_file = Path(_config_file)
423 if _config_file.parent != config_root_path:
424 logger.warning(
425 f"Not all config files are in {config_root_path}. If logging_file and meta_file are"
426 f"not specified, {config_root_path} will be used as the default config root directory."
427 )
428 if not _config_file.is_file():
429 raise FileNotFoundError(f"Cannot find the config file: {_config_file}.")
430 else:
431 config_root_path = Path("configs")
432 meta_file = str(config_root_path / "metadata.json") if meta_file is None else meta_file
433 super().__init__(workflow_type=workflow_type, meta_file=meta_file, properties_path=properties_path)
434 self.config_root_path = config_root_path
435 logging_file = str(self.config_root_path / "logging.conf") if logging_file is None else logging_file
436 if logging_file is False:
437 logger.warning(f"Logging file is set to {logging_file}, skipping logging.")
438 else:
439 if not os.path.isfile(logging_file):
440 if logging_file == str(self.config_root_path / "logging.conf"):
441 logger.warning(f"Default logging file in {logging_file} does not exist, skipping logging.")
442 else:
443 raise FileNotFoundError(f"Cannot find the logging config file: {logging_file}.")
444 else:
445 fileConfig(str(logging_file), disable_existing_loggers=False)
446 logger.info(f"Setting logging properties based on config: {logging_file}.")
447
448 self.parser = ConfigParser()
449 self.parser.read_config(f=config_file)
450 if self.meta_file is not None:
451 self.parser.read_meta(f=self.meta_file)
452 # the rest key-values in the _args are to override config content
453 self.parser.update(pairs=override)
454 self.init_id = init_id
455 self.run_id = run_id
456 self.final_id = final_id
457 # set tracking configs for experiment management
458 if tracking is not None:
459 if isinstance(tracking, str) and tracking in DEFAULT_EXP_MGMT_SETTINGS:
460 settings_ = DEFAULT_EXP_MGMT_SETTINGS[tracking]
461 else:
462 settings_ = ConfigParser.load_config_files(tracking)

Callers

nothing calls this directly

Calls 9

patch_bundle_trackingMethod · 0.95
ensure_tupleFunction · 0.90
ConfigParserClass · 0.90
infoMethod · 0.80
read_configMethod · 0.80
read_metaMethod · 0.80
load_config_filesMethod · 0.80
__init__Method · 0.45
updateMethod · 0.45

Tested by

no test coverage detected