misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
cb09648ba1
commit
9d19fb8e7a
@ -57,7 +57,7 @@ if __name__ == '__main__':
|
|||||||
elif args.do_manual:
|
elif args.do_manual:
|
||||||
logging.info("entering manual mode ...")
|
logging.info("entering manual mode ...")
|
||||||
|
|
||||||
agent.last_session.parse(args.skip_session)
|
agent.last_session.parse(agent.view(), args.skip_session)
|
||||||
if not args.skip_session:
|
if not args.skip_session:
|
||||||
logging.info(
|
logging.info(
|
||||||
"the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % (
|
"the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % (
|
||||||
|
@ -167,12 +167,14 @@ class LastSession(object):
|
|||||||
self.duration_human = ', '.join(self.duration_human)
|
self.duration_human = ', '.join(self.duration_human)
|
||||||
self.avg_reward /= (self.epochs if self.epochs else 1)
|
self.avg_reward /= (self.epochs if self.epochs else 1)
|
||||||
|
|
||||||
def parse(self, skip=False):
|
def parse(self, ui, skip=False):
|
||||||
if skip:
|
if skip:
|
||||||
logging.debug("skipping parsing of the last session logs ...")
|
logging.debug("skipping parsing of the last session logs ...")
|
||||||
else:
|
else:
|
||||||
logging.debug("reading last session logs ...")
|
logging.debug("reading last session logs ...")
|
||||||
|
|
||||||
|
ui.on_reading_logs()
|
||||||
|
|
||||||
lines = []
|
lines = []
|
||||||
|
|
||||||
if os.path.exists(self.path):
|
if os.path.exists(self.path):
|
||||||
@ -184,11 +186,18 @@ class LastSession(object):
|
|||||||
lines.append(line)
|
lines.append(line)
|
||||||
if LastSession.START_TOKEN in line:
|
if LastSession.START_TOKEN in line:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
lines_so_far = len(lines)
|
||||||
|
if lines_so_far % 100 == 0:
|
||||||
|
ui.on_reading_logs(lines_so_far)
|
||||||
|
|
||||||
lines.reverse()
|
lines.reverse()
|
||||||
|
|
||||||
if len(lines) == 0:
|
if len(lines) == 0:
|
||||||
lines.append("Initial Session");
|
lines.append("Initial Session");
|
||||||
|
|
||||||
|
ui.on_reading_logs()
|
||||||
|
|
||||||
self.last_session = lines
|
self.last_session = lines
|
||||||
self.last_session_id = hashlib.md5(lines[0].encode()).hexdigest()
|
self.last_session_id = hashlib.md5(lines[0].encode()).hexdigest()
|
||||||
self.last_saved_session_id = self._get_last_saved_session_id()
|
self.last_saved_session_id = self._get_last_saved_session_id()
|
||||||
|
@ -233,6 +233,11 @@ class View(object):
|
|||||||
self.set('status', self._voice.on_free_channel(channel))
|
self.set('status', self._voice.on_free_channel(channel))
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def on_reading_logs(self, lines_so_far=0):
|
||||||
|
self.set('face', faces.SMART)
|
||||||
|
self.set('status', self._voice.on_reading_logs(lines_so_far))
|
||||||
|
self.update()
|
||||||
|
|
||||||
def wait(self, secs, sleeping=True):
|
def wait(self, secs, sleeping=True):
|
||||||
was_normal = self.is_normal()
|
was_normal = self.is_normal()
|
||||||
part = secs / 10.0
|
part = secs / 10.0
|
||||||
|
@ -43,6 +43,12 @@ class Voice:
|
|||||||
def on_free_channel(self, channel):
|
def on_free_channel(self, channel):
|
||||||
return self._('Hey, channel {channel} is free! Your AP will say thanks.').format(channel=channel)
|
return self._('Hey, channel {channel} is free! Your AP will say thanks.').format(channel=channel)
|
||||||
|
|
||||||
|
def on_reading_logs(self, lines_so_far=0):
|
||||||
|
if lines_so_far == 0:
|
||||||
|
return self._('Reading last session logs ...')
|
||||||
|
else:
|
||||||
|
return self._('Read {lines_so_far} log lines so far ...').format(lines_so_far=lines_so_far)
|
||||||
|
|
||||||
def on_bored(self):
|
def on_bored(self):
|
||||||
return random.choice([
|
return random.choice([
|
||||||
self._('I\'m bored ...'),
|
self._('I\'m bored ...'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user