Commit 03ac8291 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[experiments] Refactor to use new WebAPI class

parent 53f7b617
......@@ -883,15 +883,9 @@ def start(ctx, name, watch):
config = ctx.meta.get("config")
with common.make_webapi(config) as webapi:
status, _ = webapi.post("/api/v1/experiments/{}/start/".format(name))
webapi.post("/api/v1/experiments/{}/start/".format(name))
if status != six.moves.http_client.OK:
logger.error(
"failed to start {} on `{}', reason: {}".format(
name, webapi.platform, six.moves.http_client.responses[status]
)
)
elif watch:
if watch:
ctx.invoke(monitor, name=name)
......@@ -903,14 +897,7 @@ def cancel(ctx, name):
config = ctx.meta.get("config")
with common.make_webapi(config) as webapi:
status, _ = webapi.post("/api/v1/experiments/{}/cancel/".format(name))
if status != six.moves.http_client.OK:
logger.error(
"failed to cancel {} on `{}', reason: {}".format(
name, webapi.platform, six.moves.http_client.responses[status]
)
)
webapi.post("/api/v1/experiments/{}/cancel/".format(name))
@experiments.command()
......@@ -921,14 +908,7 @@ def reset(ctx, name):
config = ctx.meta.get("config")
with common.make_webapi(config) as webapi:
status, _ = webapi.post("/api/v1/experiments/{}/reset/".format(name))
if status != six.moves.http_client.OK:
logger.error(
"failed to reset {} on `{}', reason: {}".format(
name, webapi.platform, six.moves.http_client.responses[status]
)
)
webapi.post("/api/v1/experiments/{}/reset/".format(name))
@experiments.command()
......@@ -954,18 +934,9 @@ def runstatus(ctx, name):
"display_end_date",
]
)
status, answer = webapi.get(
"/api/v1/experiments/{}/?fields={}".format(name, fields)
)
if status != six.moves.http_client.OK:
logger.error(
"failed to get current state of {} on `{}', reason: {}".format(
name, webapi.platform, six.moves.http_client.responses[status]
)
)
else:
data = simplejson.loads(answer)
print(simplejson.dumps(data, indent=4))
answer = webapi.get("/api/v1/experiments/{}/?fields={}".format(name, fields))
print(simplejson.dumps(answer, indent=4))
# The monitoring implementation has been inspired from
......
Supports Markdown
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