diff --git a/petric.py b/petric.py index 725b31b..1ba6843 100755 --- a/petric.py +++ b/petric.py @@ -174,12 +174,14 @@ def __init__(self, seconds=3600, outdir=OUTDIR, transverse_slice=None, coronal_s self.reset() def reset(self): - self.limit = time() + self._seconds self.offset = 0 + self.limit = (now := time()) + self._seconds + self.tb.add_scalar("reset", 0, -1, now) # for relative timing calculation def __call__(self, algo: Algorithm): if (time_excluding_metrics := (now := time()) - self.offset) > self.limit: log.warning("Timeout reached. Stopping algorithm.") + self.tb.add_scalar("reset", 0, algo.iteration, time_excluding_metrics) raise StopIteration for c in self.callbacks: c._time_ = time_excluding_metrics