Skip to content

Commit

Permalink
better logs
Browse files Browse the repository at this point in the history
  • Loading branch information
miili committed Sep 13, 2023
1 parent b4ad55b commit 61f6242
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lassie/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,15 @@ async def start(self, force_rundir: bool = False) -> None:
batch.clean_traces()

if batch.is_empty():
logger.warning("batch is empty")
logger.warning("empty batch %s", batch.log_str())
continue

if batch.duration < 2 * self._window_padding:
logger.warning("batch duration is too short")
logger.warning(
"duration of batch %s too short %s",
batch.log_str(),
batch.duration,
)
continue

search_block = SearchTraces(
Expand Down Expand Up @@ -270,11 +274,9 @@ async def start(self, force_rundir: bool = False) -> None:
else:
percent_processed = 0.0
logger.info(
"%s%% processed - batch %d/%s - %s in %s",
"%s%% processed - batch %s in %s",
f"{percent_processed:.1f}" if percent_processed else "??",
batch.i_batch + 1,
str(batch.n_batches or "?"),
batch.start_time,
batch.log_str(),
processing_time,
)
if batch.n_batches:
Expand Down
4 changes: 4 additions & 0 deletions lassie/waveforms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def clean_traces(self) -> None:
logger.warning("skipping empty or bad trace: %s", ".".join(tr.nslc_id))
self.traces.remove(tr)

def log_str(self) -> str:
"""Log the batch."""
return f"{self.i_batch}/{self.n_batches or '?'} {self.start_time}"


class WaveformProvider(BaseModel):
provider: Literal["WaveformProvider"] = "WaveformProvider"
Expand Down

0 comments on commit 61f6242

Please sign in to comment.