Skip to content

Commit

Permalink
#582: Fix logger calls with f strings
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Jan 23, 2025
1 parent 241de7f commit 1c6be24
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lbaf/Utils/lbsJSONTaskLister.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __process_files(self):
_, data = reader._load_vt_file(rank)
phases = data.get("phases", [])
if not phases:
self.__logger.warning("No phases found for rank %s", str(rank))
self.__logger.warning(f"No phases found for rank {rank}")
continue

last_phase = phases[-1]
Expand All @@ -82,12 +82,12 @@ def __process_files(self):
iteration_tasks = [task["entity"].get("seq_id", task["entity"].get("id")) for task in last_lb_iteration.get("tasks", [])]
tasks[rank] = iteration_tasks
else:
self.__logger.warning("No lb_iterations found in the last phase of rank %s", str(rank))
self.__logger.warning(f"No lb_iterations found in the last phase of rank {rank}")
else:
phase_tasks = [task["entity"].get("seq_id", task["entity"].get("id")) for task in last_phase.get("tasks", [])]
tasks[rank] = phase_tasks
except (json.JSONDecodeError, KeyError, ValueError, IndexError) as e:
self.__logger.error("Error processing rank %s: %s", str(rank), e)
self.__logger.error(f"Error processing rank {rank}: {e}")
return

return tasks
Expand All @@ -109,17 +109,17 @@ def run(self):
self.__logger = get_logger()

Check warning on line 109 in src/lbaf/Utils/lbsJSONTaskLister.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Attribute '__logger' defined outside __init__ (attribute-defined-outside-init)

if not os.path.isdir(self.__directory):
self.__logger.error("Directory not found: %s", self.__directory)
self.__logger.error(f"Directory not found: {self.__directory}")
return

tasks = self.__process_files()

try:
with open(self.__output_file, 'w') as file:

Check warning on line 118 in src/lbaf/Utils/lbsJSONTaskLister.py

View workflow job for this annotation

GitHub Actions / code-quality (ubuntu-latest, 3.8)

Using open without explicitly specifying an encoding (unspecified-encoding)
yaml.safe_dump(tasks, file)
self.__logger.info("Tasks successfully written to %s", self.__output_file)
self.__logger.info(f"Tasks successfully written to {self.__output_file}")
except IOError as e:
self.__logger.error("Error writing to %s: %s", self.__output_file, e)
self.__logger.error(f"Error writing to {self.__output_file}: {e}")
return

if __name__ == "__main__":
Expand Down

0 comments on commit 1c6be24

Please sign in to comment.