Commit e4e0ce00 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[experiments] Add status command

This allows to get the JSON data about the current
state of execution of an experiment.
parent 78f064d9
......@@ -878,14 +878,52 @@ def cancel(ctx, name):
@click.argument("name", nargs=1)
@click.pass_context
def reset(ctx, name):
"""Cancel an experiment on the platform"""
"""Reset an experiment on the platform"""
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]
)
)
@experiments.command()
@click.argument("name", nargs=1)
@click.pass_context
def status(ctx, name):
"""Shows the current status of a running experiment"""
config = ctx.meta.get("config")
with common.make_webapi(config) as webapi:
fields = ",".join(
[
"status",
"blocks_status",
"done",
"errors",
"execution_info",
"execution_order",
"results",
"started",
"display_start_date",
"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 reset {} on `{}', reason: {}".format(
"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))
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