Skip to content
Snippets Groups Projects
Commit 389504fa authored by lukas leufen's avatar lukas leufen
Browse files

changed time tracker representation to hh:mm:ss

parent 1dfeaaed
No related branches found
No related tags found
2 merge requests!24include recent development,!20not distributed training
Pipeline #27162 passed
...@@ -13,6 +13,7 @@ import numpy as np ...@@ -13,6 +13,7 @@ import numpy as np
import os import os
import time import time
import socket import socket
import datetime as dt
def to_list(arg): def to_list(arg):
...@@ -116,7 +117,8 @@ class TimeTracking(object): ...@@ -116,7 +117,8 @@ class TimeTracking(object):
return time.time() - self.start return time.time() - self.start
def __repr__(self): def __repr__(self):
return f"{round(self._duration(), 2)}s" # return f"{round(self._duration(), 2)}s"
return f"{dt.timedelta(seconds=math.ceil(self._duration()))} (hh:mm:ss)"
def run(self): def run(self):
self._start() self._start()
......
...@@ -117,7 +117,7 @@ class TestTimeTracking: ...@@ -117,7 +117,7 @@ class TestTimeTracking:
t = TimeTracking() t = TimeTracking()
t._end() t._end()
duration = t._duration() duration = t._duration()
assert t.__repr__().rstrip() == f"{round(duration, 2)}s".rstrip() assert t.__repr__().rstrip() == f"{dt.timedelta(seconds=math.ceil(duration))} (hh:mm:ss)".rstrip()
def test_run(self): def test_run(self):
t = TimeTracking(start=False) t = TimeTracking(start=False)
......
...@@ -16,7 +16,8 @@ class TestRunEnvironment: ...@@ -16,7 +16,8 @@ class TestRunEnvironment:
caplog.set_level(logging.INFO) caplog.set_level(logging.INFO)
with RunEnvironment() as r: with RunEnvironment() as r:
r.do_stuff(0.1) r.do_stuff(0.1)
assert caplog.record_tuples[-1] == ('root', 20, PyTestRegex(r"RunEnvironment finished after \d+\.\d+s")) expression = PyTestRegex(r"RunEnvironment finished after \d+:\d+:\d+ \(hh:mm:ss\)")
assert caplog.record_tuples[-1] == ('root', 20, expression)
def test_init(self, caplog): def test_init(self, caplog):
caplog.set_level(logging.INFO) caplog.set_level(logging.INFO)
...@@ -28,4 +29,5 @@ class TestRunEnvironment: ...@@ -28,4 +29,5 @@ class TestRunEnvironment:
r = RunEnvironment() r = RunEnvironment()
r.do_stuff(0.2) r.do_stuff(0.2)
del r del r
assert caplog.record_tuples[-1] == ('root', 20, PyTestRegex(r"RunEnvironment finished after \d+\.\d+s")) expression = PyTestRegex(r"RunEnvironment finished after \d+:\d+:\d+ \(hh:mm:ss\)")
assert caplog.record_tuples[-1] == ('root', 20, expression)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment