Skip to content

Bundle: No check if logging config file exists. #5233

@holgerroth

Description

@holgerroth

if logging_file_ is not None:

Running from outside bundle directory gives a cryptic error. There should be a check and error message if the given file doesn't exits.

command: torchrun --standalone --nnodes=1 --nproc_per_node=2 -m monai.bundle run training --meta_file configs/metadata.json --config_file "['configs/train.json','configs/multi_gpu_train.json']" --logging_file configs/logging.conf

Error:

2022-09-30 00:20:10,616 - INFO - set logging properties based on config: configs/logging.conf.
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/opt/conda/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/monai/monai/bundle/__main__.py", line 19, in <module>
    fire.Fire()
  File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 141, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 466, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "/opt/conda/lib/python3.8/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "/opt/monai/monai/bundle/scripts.py", line 498, in run
    fileConfig(logging_file_, disable_existing_loggers=False)
  File "/opt/conda/lib/python3.8/logging/config.py", line 71, in fileConfig
    formatters = _create_formatters(cp)
  File "/opt/conda/lib/python3.8/logging/config.py", line 104, in _create_formatters
    flist = cp["formatters"]["keys"]
  File "/opt/conda/lib/python3.8/configparser.py", line 960, in __getitem__
    raise KeyError(key)
KeyError: 'formatters'

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions