Skip to content

Migrate to modern Python Logger API #8449

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion monai/apps/auto3dseg/auto_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def set_device_info(
self.device_setting["CUDA_VISIBLE_DEVICES"] = ",".join([str(x) for x in cuda_visible_devices])
self.device_setting["n_devices"] = len(cuda_visible_devices)
else:
logger.warn(f"Wrong format of cuda_visible_devices {cuda_visible_devices}, devices not set")
logger.warning(f"Wrong format of cuda_visible_devices {cuda_visible_devices}, devices not set")

if num_nodes is None:
num_nodes = int(os.environ.get("NUM_NODES", 1))
Expand Down
14 changes: 7 additions & 7 deletions monai/bundle/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def add_property(self, name: str, required: str, desc: str | None = None) -> Non
if self.properties is None:
self.properties = {}
if name in self.properties:
logger.warn(f"property '{name}' already exists in the properties list, overriding it.")
logger.warning(f"property '{name}' already exists in the properties list, overriding it.")
self.properties[name] = {BundleProperty.DESC: desc, BundleProperty.REQUIRED: required}

def check_properties(self) -> list[str] | None:
Expand Down Expand Up @@ -421,7 +421,7 @@ def __init__(
for _config_file in _config_files:
_config_file = Path(_config_file)
if _config_file.parent != config_root_path:
logger.warn(
logger.warning(
f"Not all config files are in {config_root_path}. If logging_file and meta_file are"
f"not specified, {config_root_path} will be used as the default config root directory."
)
Expand All @@ -434,11 +434,11 @@ def __init__(
self.config_root_path = config_root_path
logging_file = str(self.config_root_path / "logging.conf") if logging_file is None else logging_file
if logging_file is False:
logger.warn(f"Logging file is set to {logging_file}, skipping logging.")
logger.warning(f"Logging file is set to {logging_file}, skipping logging.")
else:
if not os.path.isfile(logging_file):
if logging_file == str(self.config_root_path / "logging.conf"):
logger.warn(f"Default logging file in {logging_file} does not exist, skipping logging.")
logger.warning(f"Default logging file in {logging_file} does not exist, skipping logging.")
else:
raise FileNotFoundError(f"Cannot find the logging config file: {logging_file}.")
else:
Expand Down Expand Up @@ -503,17 +503,17 @@ def check_properties(self) -> list[str] | None:
"""
ret = super().check_properties()
if self.properties is None:
logger.warn("No available properties had been set, skipping check.")
logger.warning("No available properties had been set, skipping check.")
return None
if ret:
logger.warn(f"Loaded bundle does not contain the following required properties: {ret}")
logger.warning(f"Loaded bundle does not contain the following required properties: {ret}")
# also check whether the optional properties use correct ID name if existing
wrong_props = []
for n, p in self.properties.items():
if not p.get(BundleProperty.REQUIRED, False) and not self._check_optional_id(name=n, property=p):
wrong_props.append(n)
if wrong_props:
logger.warn(f"Loaded bundle defines the following optional properties with wrong ID: {wrong_props}")
logger.warning(f"Loaded bundle defines the following optional properties with wrong ID: {wrong_props}")
if ret is not None:
ret.extend(wrong_props)
return ret
Expand Down
Loading