Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable redirection of all loggers by configuring a FileHandler within the bundle #8142

Merged
merged 8 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions monai/bundle/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,6 @@ def create_workflow(

"""
_args = update_kwargs(args=args_file, workflow_name=workflow_name, config_file=config_file, **kwargs)
_log_input_summary(tag="run", args=_args)
(workflow_name, config_file) = _pop_args(
_args, workflow_name=ConfigWorkflow, config_file=None
) # the default workflow name is "ConfigWorkflow"
Expand All @@ -1969,7 +1968,7 @@ def create_workflow(
workflow_ = workflow_class(**_args)

workflow_.initialize()

_log_input_summary(tag="run", args=_args)
ericspod marked this conversation as resolved.
Show resolved Hide resolved
return workflow_


Expand Down
2 changes: 1 addition & 1 deletion monai/bundle/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def __init__(
else:
raise FileNotFoundError(f"Cannot find the logging config file: {logging_file}.")
else:
logger.info(f"Setting logging properties based on config: {logging_file}.")
fileConfig(str(logging_file), disable_existing_loggers=False)
logger.info(f"Setting logging properties based on config: {logging_file}.")
ericspod marked this conversation as resolved.
Show resolved Hide resolved

self.parser = ConfigParser()
self.parser.read_config(f=config_file)
Expand Down
2 changes: 1 addition & 1 deletion monai/handlers/stats_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
output_transform: Callable = lambda x: x[0],
global_epoch_transform: Callable = lambda x: x,
state_attributes: Sequence[str] | None = None,
name: str | None = "StatsHandler",
name: str | None = "monai.handlers.StatsHandler",
ericspod marked this conversation as resolved.
Show resolved Hide resolved
tag_name: str = DEFAULT_TAG,
key_var_format: str = DEFAULT_KEY_VAL_FORMAT,
) -> None:
Expand Down
6 changes: 3 additions & 3 deletions monai/networks/trt_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(self, plan_path, logger=None):
logger: optional logger object
"""
self.plan_path = plan_path
self.logger = logger or get_logger("trt_compile")
self.logger = logger or get_logger("monai.networks.trt_compiler")
self.logger.info(f"Loading TensorRT engine: {self.plan_path}")
self.engine = engine_from_bytes(bytes_from_path(self.plan_path))
self.tensors = OrderedDict()
Expand Down Expand Up @@ -288,7 +288,7 @@ def __init__(
self.fallback = fallback
self.disabled = False

self.logger = logger or get_logger("trt_compile")
self.logger = logger or get_logger("monai.networks.trt_compiler")

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

return model
2 changes: 1 addition & 1 deletion monai/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ def run_cmd(cmd_list: list[str], **kwargs: Any) -> subprocess.CompletedProcess:
if kwargs.pop("run_cmd_verbose", False):
import monai

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