Skip to content

Commit

Permalink
Merge pull request #286 from thegridelectric/dev
Browse files Browse the repository at this point in the history
Logging: Problems objects adds type of each problem if str(problem) returns nothing; added some logging around reindexing and reuploading
  • Loading branch information
anschweitzer authored Jan 14, 2025
2 parents 307c57a + 68d1cbd commit b41064a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pip==24.0
nox==2024.4.15
nox-poetry==1.0.3
poetry==1.8.3
poetry==1.8.5
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gridworks-proactor"
version = "1.1.3"
version = "1.1.4"
description = "Gridworks Proactor"
authors = ["Jessica Millar <[email protected]>"]
license = "MIT"
Expand Down
12 changes: 9 additions & 3 deletions src/gwproactor/links/reuploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ def process_ack_for_reupload(self, ack_id: str) -> list[str]:
if was_reuploading and not self.reuploading():
path_dbg |= 0x00000008
self.stats.complete_reupload()
self._logger.comm_event(
f"Reupload completed. Total started: {self.stats.reupload_counts.started} "
f"completed: {self.stats.reupload_counts.completed}."
)
if self._logger.path_enabled:
ack_logger.log_ack(path_dbg)
return reupload_now
Expand Down Expand Up @@ -196,15 +200,17 @@ def __str__(self) -> str:
def _log_start_reupload(
self, num_pending_events: int, num_reupload_now: int
) -> None:
if self._logger.general_enabled:
if self._logger.comm_event_enabled:
if self.reuploading():
state_str = f"{self.num_reupload_pending} reupload events pending."
else:
state_str = "reupload complete."
self._logger.info(
self._logger.comm_event(
f"start_reupload: sent {num_reupload_now} events. " # noqa: G004
f"{state_str} "
f"Total events in reupload: {num_pending_events}."
f"Total events in reupload: {num_pending_events}. "
f"Reuploads started: {self.stats.reupload_counts.started} "
f"completed: {self.stats.reupload_counts.completed}."
)
if self._logger.path_enabled:
self._logger.path(self.get_str(num_events=5))
2 changes: 2 additions & 0 deletions src/gwproactor/proactor_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def __init__(
self._logger = ProactorLogger(**settings.logging.qualified_logger_names())
self._stats = self.make_stats()
self._event_persister = self.make_event_persister(settings)
self._logger.lifecycle(f"Proactor {self._name} reindexing events")
reindex_result = self._event_persister.reindex()
self._logger.lifecycle(f"Proactor {self._name} reindexing complete")
if reindex_result.is_err():
self._reindex_problems = reindex_result.err()
self._logger.error("ERROR in event persister reindex():")
Expand Down
5 changes: 4 additions & 1 deletion src/gwproactor/problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def __str__(self) -> str:
if lst:
s += f"\n{attr_name.capitalize()}:\n"
for i, entry in enumerate(lst):
s += f" {i:2d}: {entry}\n"
entry_str = str(entry)
if not entry_str:
entry_str = entry.__class__.__name__
s += f" {i:2d}: {entry_str}\n"
return s
return ""

Expand Down

0 comments on commit b41064a

Please sign in to comment.