Skip to content

Commit

Permalink
chore: Fix call of logger to properly pass arguments to messages (#1179)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Enhanced logging clarity by updating the log message formatting across
various components, including error handling and module reloading.
  
- **Chores**
- Updated logging statements for consistency and improved context
without impacting functionality in multiple files.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Czaki authored Aug 13, 2024
1 parent 30574f5 commit 30540fe
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package/PartSeg/_roi_analysis/export_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def sleep_with_rate(response: requests.Response):
reset = int(response.headers["X-RateLimit-Reset"])
sleep_time = reset - time.time()
if sleep_time > 0:
logging.info("Sleeping for {sleep_time} seconds", extra={"sleep_time": sleep_time})
logging.info("Sleeping for %(sleep_time) seconds", extra={"sleep_time": sleep_time})
time.sleep(sleep_time)


Expand Down
4 changes: 3 additions & 1 deletion package/PartSeg/common_backend/segmentation_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def run(self):
"""the calculation are done here"""
if self.algorithm.image is None:
# assertion for running algorithm without image
logging.error("No image in class {cls_name}", extra={"cls_name": self.algorithm.__class__})
logging.error(
"No image in class %(cls_name)", extra={"cls_name": self.algorithm.__class__}, stack_info=True
)
return
try:
segment_data = self.algorithm.calculation_run_wrap(self.send_info)
Expand Down
2 changes: 1 addition & 1 deletion package/PartSeg/common_gui/advanced_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, parent=None):

def reload_algorithm_action(self):
"""Function for reload plugins and algorithms"""
msg = "Reloading {mod_name}"
msg = "Reloading %(mod_name)"
for val in register.reload_module_list:
logging.info(msg, extra={"mod_name": val.__name__})
importlib.reload(val)
Expand Down
2 changes: 1 addition & 1 deletion package/PartSegCore/analysis/load_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def load_project_from_tar(tar_file, file_path):
algorithm_parameters=algorithm_dict,
)
logging.warning(
"This project {proj_ver} is from new version of PartSeg: {version} ",
"This project %(proj_ver) is from new version of PartSeg: %(version)",
extra={"version": version, "proj_ver": project_version_info},
)
return ProjectTuple(
Expand Down

0 comments on commit 30540fe

Please sign in to comment.