Commit 5d40e6b8 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[commands] Implement push command with dependency handling

All push command have the same implementation. Therefore
move it here as a central command. This implementation
will also handle asset dependency upload.
parent 9eef21fa
......@@ -36,6 +36,7 @@
import click
import types
from .scripts import main_cli
from .decorators import raise_on_error
from . import common
......@@ -251,6 +252,54 @@ def diff_impl(ctx, name):
)
@click.argument("names", nargs=-1)
@click.option(
"--force", help="Performs operation regardless of conflicts", is_flag=True
)
@click.option(
"--dry-run",
help="Doesn't really perform the task, just " "comments what would do",
is_flag=True,
)
@click.pass_context
@raise_on_error
def push_impl(ctx, names, force, dry_run):
"""Uploads asset to the server
Example:
$ beat algorithms push --dry-run yyy
"""
config = ctx.meta["config"]
asset_info = ctx.meta["asset_info"]
mappings = ctx.meta.get("mappings", {})
if asset_info.get_dependencies is not None:
for name in names:
dependencies = asset_info.get_dependencies(ctx, name)
for dependency_type, dependency_list in dependencies.items():
push_cmd = main_cli.main.get_command(ctx, dependency_type).get_command(
ctx, "push"
)
ctx.meta["asset_info"] = push_cmd.asset_info
status = ctx.invoke(push_cmd, names=dependency_list)
if status != 0:
return status
with common.make_webapi(config) as webapi:
return common.push(
webapi=webapi,
prefix=config.path,
asset_type=asset_info.asset_type,
names=names,
fields=asset_info.push_fields,
mappings=mappings,
force=force,
dry_run=dry_run,
indentation=0,
)
CMD_TABLE = {
"list": list_impl,
"path": path_impl,
......@@ -263,6 +312,7 @@ CMD_TABLE = {
"rm": rm_impl,
"rm_local": rm_local_impl,
"diff": diff_impl,
"push": push_impl,
}
......
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