@@ -91,11 +91,19 @@ def __init__(
9191
9292 if meta_file is not None :
9393 if isinstance (meta_file , str ) and not os .path .isfile (meta_file ):
94- raise FileNotFoundError (f"Cannot find the metadata config file: { meta_file } ." )
94+ logger .error (
95+ f"Cannot find the metadata config file: { meta_file } . "
96+ "Please see: https://docs.monai.io/en/stable/mb_specification.html"
97+ )
98+ meta_file = None
9599 if isinstance (meta_file , list ):
96100 for f in meta_file :
97101 if not os .path .isfile (f ):
98- raise FileNotFoundError (f"Cannot find the metadata config file: { f } ." )
102+ logger .error (
103+ f"Cannot find the metadata config file: { f } . "
104+ "Please see: https://docs.monai.io/en/stable/mb_specification.html"
105+ )
106+ meta_file = None
99107
100108 self .meta_file = meta_file
101109
@@ -258,22 +266,23 @@ def __init__(
258266 ** override : Any ,
259267 ) -> None :
260268 workflow_type = workflow if workflow is not None else workflow_type
261- super ().__init__ (workflow_type = workflow_type )
262269 if config_file is not None :
263270 _config_files = ensure_tuple (config_file )
264- self . config_root_path = Path (_config_files [0 ]).parent
271+ config_root_path = Path (_config_files [0 ]).parent
265272 for _config_file in _config_files :
266273 _config_file = Path (_config_file )
267- if _config_file .parent != self . config_root_path :
274+ if _config_file .parent != config_root_path :
268275 logger .warn (
269- f"Not all config files are in { self . config_root_path } . If logging_file and meta_file are"
270- f"not specified, { self . config_root_path } will be used as the default config root directory."
276+ f"Not all config files are in { config_root_path } . If logging_file and meta_file are"
277+ f"not specified, { config_root_path } will be used as the default config root directory."
271278 )
272279 if not _config_file .is_file ():
273280 raise FileNotFoundError (f"Cannot find the config file: { _config_file } ." )
274281 else :
275- self .config_root_path = Path ("configs" )
276-
282+ config_root_path = Path ("configs" )
283+ meta_file = str (config_root_path / "metadata.json" ) if meta_file is None else meta_file
284+ super ().__init__ (workflow_type = workflow_type , meta_file = meta_file )
285+ self .config_root_path = config_root_path
277286 logging_file = str (self .config_root_path / "logging.conf" ) if logging_file is None else logging_file
278287 if logging_file is not None :
279288 if not os .path .isfile (logging_file ):
@@ -287,21 +296,8 @@ def __init__(
287296
288297 self .parser = ConfigParser ()
289298 self .parser .read_config (f = config_file )
290- meta_file = str (self .config_root_path / "metadata.json" ) if meta_file is None else meta_file
291- if isinstance (meta_file , str ) and not os .path .isfile (meta_file ):
292- logger .error (
293- f"Cannot find the metadata config file: { meta_file } . "
294- "Please see: https://docs.monai.io/en/stable/mb_specification.html"
295- )
296- elif isinstance (meta_file , list ):
297- for f in meta_file :
298- if not os .path .isfile (f ):
299- logger .error (
300- f"Cannot find the metadata config file: { f } . "
301- "Please see: https://docs.monai.io/en/stable/mb_specification.html"
302- )
303- else :
304- self .parser .read_meta (f = meta_file )
299+ if self .meta_file is not None :
300+ self .parser .read_meta (f = self .meta_file )
305301
306302 # the rest key-values in the _args are to override config content
307303 self .parser .update (pairs = override )
0 commit comments