stencila/hub

Active job runtime calculation can be incorrect

alex-ketch opened this issue · 0 comments

There seems to be an issue with the job.runtime_seconds calculation which causes the progress bar for file conversions to immediately jump to 100%.

hub/manager/jobs/models.py

Lines 870 to 884 in c8bb8dd

@cached_property
def runtime_seconds(self) -> Optional[float]:
"""
Get the runtime in seconds.
"""
if self.runtime is not None:
return self.runtime
elif self.is_active and self.began:
return (timezone.now() - self.began).seconds
elif self.ended and self.began:
return (self.ended - self.began).seconds
else:
return None

In trying to debug locally, I noticed that the timezones were different between the now and began timestamps.
Screenshot 2021-03-10 at 15 52 52