Commit 78f064d9 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[experiments] Add start/cancel/reset commands

As their name suggests, these commands will allow
to interact with the platform regarding the
execution of experiments.
parent 2b2eeb3b
......@@ -39,6 +39,7 @@ import logging
import glob
import click
import simplejson
import six
from beat.core.experiment import Experiment
from beat.core.execution import DockerExecutor
......@@ -835,3 +836,56 @@ def plot(ctx, names, force, remote, show, output_folder):
{},
output_folder,
)
@experiments.command()
@click.argument("name", nargs=1)
@click.pass_context
def start(ctx, name):
"""Start an experiment on the platform"""
config = ctx.meta.get("config")
with common.make_webapi(config) as webapi:
status, _ = 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]
)
)
@experiments.command()
@click.argument("name", nargs=1)
@click.pass_context
def cancel(ctx, name):
"""Cancel an experiment on the platform"""
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]
)
)
@experiments.command()
@click.argument("name", nargs=1)
@click.pass_context
def reset(ctx, name):
"""Cancel 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]
)
)
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