Commit 58b6641d authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[experiments] Port to AssetCommand and implent dependency handling for push

parent 76283061
......@@ -63,9 +63,13 @@ from . import commands
from .plotters import plot_impl as plotters_plot
from .plotters import pull_impl as plotters_pull
from .decorators import raise_on_error
from .click_helper import AliasedGroup
from .click_helper import MutuallyExclusiveOption
from .click_helper import AssetCommand
from .click_helper import AssetInfo
logger = logging.getLogger(__name__)
......@@ -705,18 +709,39 @@ def plot_impl(
return status
def get_dependencies(ctx, asset_name):
prefix = ctx.meta["config"].path
exp = Experiment(prefix, asset_name)
dependencies = {"toolchains": []}
algorithms = list(exp.algorithms.keys())
if algorithms:
dependencies["algorithms"] = algorithms
# databases are not considered as dependencies as they can't be uploaded.
return dependencies
class ExperimentCommand(AssetCommand):
asset_info = AssetInfo(
diff_fields=["declaration", "description"],
push_fields=["name", "declaration", "toolchain", "description"],
def experiments(ctx):
"""experiments commands"""
ctx.meta["asset_type"] = "experiment"
ctx.meta["diff_fields"] = ["declaration", "description"]
CMD_LIST = ["list", "path", "edit", "check", "status", "fork", "rm", "diff"]
CMD_LIST = ["list", "path", "edit", "check", "status", "fork", "rm", "diff", "push"]
commands.initialise_asset_commands(experiments, CMD_LIST)
commands.initialise_asset_commands(experiments, CMD_LIST, ExperimentCommand)
......@@ -796,39 +821,6 @@ def pull(ctx, names, force):
return pull_impl(webapi, config.path, names, force, 0, {})
@click.argument("names", nargs=-1)
"--force", help="Performs operation regardless of conflicts", is_flag=True
help="Doesn't really perform the task, just " "comments what would do",
def push(ctx, names, force, dry_run):
"""Uploads experiments to the server.
$ beat experiments push --dry-run yyy
config = ctx.meta.get("config")
with common.make_webapi(config) as webapi:
return common.push(
["name", "declaration", "toolchain", "description"],
@click.argument("names", nargs=-1)
......@@ -66,6 +66,9 @@ class TestOnlineExperiments(core.OnlineAssetTestCase):
object_map = {
"pull": "user/user/single/1/single",
"diff": "user/user/single/1/single",
"push": "user/user/unknown/1/unknown",
"push": "user/user/unknown/1/unknown",
"not_owner_push": "other_user/other_user/somechain/1/someexp",
def _modify_asset(self, asset_name):
......@@ -98,18 +101,6 @@ class TestOnlineExperiments(core.OnlineAssetTestCase):, 0, outputs)
def test_push_and_delete(self):
obj = "user/user/double_triangle/1/double_triangle"
obj2 = "user/user/double_triangle/1/different"
self.test_fork(obj, obj2)
# now push the fork and then delete it remotely
exit_code, outputs ="push", obj2, prefix=tmp_prefix), 0, outputs)
exit_code, outputs ="rm", "--remote", obj2, prefix=tmp_prefix), 0, outputs)
def test_draw(self):
obj = "user/user/double_triangle/1/double_triangle"
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