misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
Simone Margaritelli
2019-10-30 14:25:21 +01:00
parent cb09648ba1
commit 9d19fb8e7a
4 changed files with 22 additions and 2 deletions

View File

@ -167,12 +167,14 @@ class LastSession(object):
self.duration_human = ', '.join(self.duration_human)
self.avg_reward /= (self.epochs if self.epochs else 1)
def parse(self, skip=False):
def parse(self, ui, skip=False):
if skip:
logging.debug("skipping parsing of the last session logs ...")
else:
logging.debug("reading last session logs ...")
ui.on_reading_logs()
lines = []
if os.path.exists(self.path):
@ -184,11 +186,18 @@ class LastSession(object):
lines.append(line)
if LastSession.START_TOKEN in line:
break
lines_so_far = len(lines)
if lines_so_far % 100 == 0:
ui.on_reading_logs(lines_so_far)
lines.reverse()
if len(lines) == 0:
lines.append("Initial Session");
ui.on_reading_logs()
self.last_session = lines
self.last_session_id = hashlib.md5(lines[0].encode()).hexdigest()
self.last_saved_session_id = self._get_last_saved_session_id()