Commit 59bbe7e7 authored by Flavio TARSETTI's avatar Flavio TARSETTI

Merge branch '66_fix_monitor_command' into 'master'

Fix experiment monitor command

Closes #66

See merge request !89
parents 6237ba29 9c954944
Pipeline #38182 passed with stages
in 5 minutes and 4 seconds
......@@ -61,6 +61,8 @@ from beat.core.hash import hashDataset
from . import common
from . import commands
from .webapi import WebAPIError
from .plotters import plot_impl as plotters_plot
from .plotters import pull_impl as plotters_pull
......@@ -983,22 +985,22 @@ class ExperimentMonitor(threading.Thread):
0 if first_run else self.interval.total_seconds()
):
status, answer = webapi.get(
"/api/v1/experiments/{}/?fields={}".format(self.name, fields)
)
if status != six.moves.http_client.OK:
try:
answer = webapi.get(
"/api/v1/experiments/{}/?fields={}".format(self.name, fields)
)
except WebAPIError as error:
logger.error(
"failed to get current state of {} on `{}', reason: {}".format(
self.name,
webapi.platform,
six.moves.http_client.responses[status],
error,
)
)
self.stop_event.set()
self.queue.put({"error": status})
self.queue.put({"error": error})
else:
data = simplejson.loads(answer)
self.queue.put(data)
self.queue.put(answer)
if first_run:
first_run = False
......@@ -1137,16 +1139,17 @@ def monitor(ctx, name):
if not killed:
line += 1
pad.timeout(-1)
pad.addstr(
line,
0,
textwrap.shorten("Experiment done, press any key to leave", width=width),
curses.A_BOLD,
)
pad.move(line, 0)
pad.refresh(pad_height - height, 0, 0, 0, height - 1, width - 1)
pad.getkey()
if pad:
pad.timeout(-1)
pad.addstr(
line,
0,
textwrap.shorten("Experiment done, press any key to leave", width=width),
curses.A_BOLD,
)
pad.move(line, 0)
pad.refresh(pad_height - height, 0, 0, 0, height - 1, width - 1)
pad.getkey()
curses.echo()
curses.nocbreak()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment