Skip to content

Commit 90173c9

Browse files
Enable redirection of all loggers by configuring a FileHandler within the bundle (#8142)
Fix Project-MONAI/model-zoo#658, part of #7513 ### Description Enable redirection of all loggers by configuring a FileHandler within the bundle ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a6f8f68 commit 90173c9

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

monai/bundle/scripts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,6 @@ def create_workflow(
19451945
19461946
"""
19471947
_args = update_kwargs(args=args_file, workflow_name=workflow_name, config_file=config_file, **kwargs)
1948-
_log_input_summary(tag="run", args=_args)
19491948
(workflow_name, config_file) = _pop_args(
19501949
_args, workflow_name=ConfigWorkflow, config_file=None
19511950
) # the default workflow name is "ConfigWorkflow"
@@ -1969,7 +1968,7 @@ def create_workflow(
19691968
workflow_ = workflow_class(**_args)
19701969

19711970
workflow_.initialize()
1972-
1971+
_log_input_summary(tag="run", args=_args)
19731972
return workflow_
19741973

19751974

monai/bundle/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ def __init__(
316316
else:
317317
raise FileNotFoundError(f"Cannot find the logging config file: {logging_file}.")
318318
else:
319-
logger.info(f"Setting logging properties based on config: {logging_file}.")
320319
fileConfig(str(logging_file), disable_existing_loggers=False)
320+
logger.info(f"Setting logging properties based on config: {logging_file}.")
321321

322322
self.parser = ConfigParser()
323323
self.parser.read_config(f=config_file)

monai/handlers/stats_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(
7474
output_transform: Callable = lambda x: x[0],
7575
global_epoch_transform: Callable = lambda x: x,
7676
state_attributes: Sequence[str] | None = None,
77-
name: str | None = "StatsHandler",
77+
name: str | None = "monai.handlers.StatsHandler",
7878
tag_name: str = DEFAULT_TAG,
7979
key_var_format: str = DEFAULT_KEY_VAL_FORMAT,
8080
) -> None:

monai/networks/trt_compiler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(self, plan_path, logger=None):
115115
logger: optional logger object
116116
"""
117117
self.plan_path = plan_path
118-
self.logger = logger or get_logger("trt_compile")
118+
self.logger = logger or get_logger("monai.networks.trt_compiler")
119119
self.logger.info(f"Loading TensorRT engine: {self.plan_path}")
120120
self.engine = engine_from_bytes(bytes_from_path(self.plan_path))
121121
self.tensors = OrderedDict()
@@ -288,7 +288,7 @@ def __init__(
288288
self.fallback = fallback
289289
self.disabled = False
290290

291-
self.logger = logger or get_logger("trt_compile")
291+
self.logger = logger or get_logger("monai.networks.trt_compiler")
292292

293293
# Normally we read input_names from forward() but can be overridden
294294
if input_names is None:
@@ -563,7 +563,7 @@ def find_sub(parent, submodule):
563563
else:
564564
wrap(model, base_path)
565565
else:
566-
logger = logger or get_logger("trt_compile")
566+
logger = logger or get_logger("monai.networks.trt_compiler")
567567
logger.warning("TensorRT and/or polygraphy packages are not available! trt_compile() has no effect.")
568568

569569
return model

monai/utils/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ def run_cmd(cmd_list: list[str], **kwargs: Any) -> subprocess.CompletedProcess:
887887
if kwargs.pop("run_cmd_verbose", False):
888888
import monai
889889

890-
monai.apps.utils.get_logger("run_cmd").info(f"{cmd_list}") # type: ignore[attr-defined]
890+
monai.apps.utils.get_logger("monai.utils.run_cmd").info(f"{cmd_list}") # type: ignore[attr-defined]
891891
try:
892892
return subprocess.run(cmd_list, **kwargs)
893893
except subprocess.CalledProcessError as e:

0 commit comments

Comments
 (0)