예제 #1
0
def _runs_cmd_args(
    operations=None,
    labels=None,
    running=False,
    completed=False,
    error=False,
    terminated=False,
    pending=False,
    staged=False,
    unlabeled=None,
    marked=False,
    unmarked=False,
    started=None,
    digest=None,
):
    return click_util.Args(
        ops=operations,
        labels=labels,
        running=running,
        completed=completed,
        error=error,
        terminated=terminated,
        pending=pending,
        staged=staged,
        unlabeled=unlabeled,
        marked=marked,
        unmarked=unmarked,
        started=started,
        digest=digest,
    )
예제 #2
0
def package(
    dist_dir=None,
    upload=False,
    upload_test=False,
    repo=None,
    sign=False,
    identity=None,
    user=None,
    password=None,
    skip_existing=False,
    comment=None,
    cwd=".",
    guild_home=None,
):
    from guild import click_util
    from guild.commands import package_impl

    args = click_util.Args(
        dist_dir=dist_dir,
        upload=upload,
        upload_test=upload_test,
        repo=repo,
        sign=sign,
        identity=identity,
        user=user,
        password=password,
        skip_existing=skip_existing,
        comment=comment,
    )
    with Env(cwd, guild_home):
        package_impl.main(args)
예제 #3
0
    def delete_runs(self, **opts):
        if not self._deleted_runs_dir and not opts.get("permanent"):
            raise remotelib.OperationNotSupported(
                "remote '%s' does not support non permanent deletes\n"
                "Use the '--permanent' with this command and try again." % self.name
            )
        args = click_util.Args(archive=self._runs_dir, remote=None, **opts)
        self._sync_runs_meta()
        if args.permanent:
            preview = cmd_impl_support.format_warn(
                "WARNING: You are about to permanently delete "
                "the following runs on %s:" % self.name
            )
            confirm = "Permanently delete these runs?"
        else:
            preview = "You are about to delete the following runs on %s:" % self.name
            confirm = "Delete these runs?"
        no_runs_help = "Nothing to delete."

        def delete_f(selected):
            self._delete_runs(selected, args.permanent)
            self._sync_runs_meta(force=True)

        try:
            runs_impl.runs_op(
                args,
                None,
                preview,
                confirm,
                no_runs_help,
                delete_f,
                confirm_default=not args.permanent,
            )
        except SystemExit as e:
            raise self._fix_system_exit_msg_for_remote(e, ["runs rm", "runs delete"])
예제 #4
0
    def purge_runs(self, **opts):
        if not self._deleted_runs_dir:
            raise remotelib.OperationNotSupported()
        self._sync_runs_meta()
        args = click_util.Args(archive=self._deleted_runs_dir, remote=None, **opts)
        preview = (
            "WARNING: You are about to permanently delete "
            "the following runs on %s:" % self.name
        )
        confirm = "Permanently delete these runs?"
        no_runs_help = "Nothing to purge."

        def purge_f(selected):
            self._purge_runs(selected)
            self._sync_runs_meta(force=True)

        try:
            runs_impl.runs_op(
                args,
                None,
                preview,
                confirm,
                no_runs_help,
                purge_f,
                confirm_default=False,
            )
        except SystemExit as e:
            self._fix_system_exit_msg_for_remote(e, ["runs purge"])
예제 #5
0
def publish(
    runs=None,
    dest=None,
    template=None,
    files=False,
    all_files=False,
    include_links=False,
    include_batch=False,
    no_md5=False,
    refresh_index=False,
    cwd=".",
    guild_home=None,
    **kw
):
    from guild import click_util
    from guild.commands import publish_impl

    args = click_util.Args(
        runs=(runs or []),
        dest=dest,
        template=template,
        files=files,
        all_files=all_files,
        include_links=include_links,
        include_batch=include_batch,
        no_md5=no_md5,
        refresh_index=refresh_index,
        yes=True,
    )
    _apply_runs_filters(kw, args)
    _assert_empty_kw(kw, "publish()")
    with Env(cwd, guild_home):
        publish_impl.publish(args, None)
예제 #6
0
파일: s3.py 프로젝트: wingkitlee0/guildai
    def purge_runs(self, **opts):
        self._verify_creds_and_region()
        self._sync_runs_meta()
        args = click_util.Args(**opts)
        args.archive = self._deleted_runs_dir
        preview = ("WARNING: You are about to permanently delete "
                   "the following runs on %s:" % self.name)
        confirm = "Permanently delete these runs?"
        no_runs_help = "Nothing to purge."

        def purge_f(selected):
            self._purge_runs(selected)
            self._new_meta_id()
            self._sync_runs_meta(force=True)

        try:
            runs_impl._runs_op(args,
                               None,
                               False,
                               preview,
                               confirm,
                               no_runs_help,
                               purge_f,
                               confirm_default=False)
        except SystemExit as e:
            self._reraise_system_exit(e, deleted=True)
예제 #7
0
파일: _api.py 프로젝트: ErSKS/guildai
def publish(
        runs=None,
        dest=None,
        template=None,
        files=False,
        all_files=False,
        include_links=False,
        include_batch=False,
        no_md5=False,
        cwd=".",
        guild_home=None):
    from guild import click_util
    from guild.commands import runs_publish
    from guild.commands import runs_impl
    args = list(runs or ()) + ["-y"]
    if dest:
        args.extend(["--dest", dest])
    if template:
        args.extend(["--template", template])
    if files:
        args.append("--files")
    if all_files:
        args.append("--all-files")
    if include_links:
        args.append("--include-links")
    if include_batch:
        args.append("--include-batch")
    if no_md5:
        args.append("--no-md5")
    ctx = runs_publish.publish_runs.make_context("", args)
    args = click_util.Args(**ctx.params)
    with Env(cwd, guild_home):
        return runs_impl.publish(args, ctx)
예제 #8
0
파일: _api.py 프로젝트: ErSKS/guildai
def runs_list(
        ops=None,
        status=None,
        labels=None,
        unlabeled=False,
        all=False,
        deleted=False,
        marked=False,
        unmarked=False,
        cwd=".",
        guild_home=None):
    from guild import click_util
    from guild.commands import runs_impl
    status = status or []
    args = click_util.Args(
        ops=(ops or []),
        labels=(labels or []),
        unlabeled=unlabeled,
        all=all,
        deleted=deleted,
        marked=marked,
        unmarked=unmarked)
    _apply_status_filters(status, args)
    with Env(cwd, guild_home):
        return runs_impl.filtered_runs(args)
예제 #9
0
def runs_label(runs=None,
               set=None,
               append=None,
               prepend=None,
               remove=None,
               clear=False,
               cwd=".",
               guild_home=None,
               **kw):
    from guild import click_util
    from guild.commands import runs_impl
    from guild.commands import runs_label

    args = click_util.Args(
        runs=_run_ids(runs),
        set=set,
        append=append,
        prepend=prepend,
        remove=remove,
        clear=clear,
        remote=False,
        yes=True,
    )
    _apply_runs_filters(kw, args)
    _apply_remote(kw, args)
    _assert_empty_kw(kw, "runs_label()")
    ctx = runs_label.label_runs.make_context("", [])
    with Env(cwd, guild_home):
        runs_impl.label(args, ctx)
예제 #10
0
    def restore_runs(self, **opts):
        if not self._deleted_runs_dir:
            raise remotelib.OperationNotSupported()
        self._sync_runs_meta()
        args = click_util.Args(archive=self._deleted_runs_dir, remote=None, **opts)
        preview = "You are about to restore the following runs on %s:" % self.name
        confirm = "Restore these runs?"
        no_runs_help = "Nothing to restore."

        def restore_f(selected):
            self._restore_runs(selected)
            self._sync_runs_meta(force=True)

        try:
            runs_impl.runs_op(
                args,
                None,
                preview,
                confirm,
                no_runs_help,
                restore_f,
                confirm_default=True,
            )
        except SystemExit as e:
            self._fix_system_exit_msg_for_remote(e, ["runs restore"])
예제 #11
0
def _ac_runs_for_ctx(ctx):
    from guild import config
    from . import runs_impl

    param_args = click_util.Args(**ctx.params)
    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        return runs_impl.filtered_runs(param_args, ctx=ctx)
예제 #12
0
def runs_tag(runs=None,
             add=None,
             remove=None,
             clear=False,
             sync_labels=False,
             cwd=".",
             guild_home=None,
             **kw):
    from guild import click_util
    from guild.commands import runs_impl
    from guild.commands import runs_tag

    args = click_util.Args(
        runs=_run_ids(runs),
        add=_coerce_list(add),
        delete=_coerce_list(remove),
        clear=clear,
        sync_labels=sync_labels,
        remote=False,
        yes=True,
    )
    _apply_runs_filters(kw, args)
    _apply_remote(kw, args)
    _assert_empty_kw(kw, "runs_tag()")
    ctx = runs_tag.tag_runs.make_context("", [])
    with Env(cwd, guild_home):
        runs_impl.tag(args, ctx)
예제 #13
0
파일: s3.py 프로젝트: wangsd01/guildai
 def run_info(self, **opts):
     self._sync_runs_meta()
     args = click_util.Args(**opts)
     args.archive = self._runs_dir
     args.remote = None
     args.private_attrs = False
     runs_impl.run_info(args, None)
예제 #14
0
def compare(
    runs=None,
    cols=None,
    extra_cols=False,
    skip_op_cols=False,
    skip_core=False,
    include_batch=False,
    min_col=None,
    max_col=None,
    limit=None,
    cwd=".",
    guild_home=None,
    **kw
):
    from guild import click_util
    from guild.commands import compare_impl

    args = click_util.Args(
        runs=(runs or []),
        extra_cols=extra_cols,
        cols=cols,
        skip_op_cols=skip_op_cols,
        skip_core=skip_core,
        include_batch=include_batch,
        min_col=min_col,
        max_col=max_col,
        limit=limit,
    )
    _apply_runs_filters(kw, args)
    _assert_empty_kw(kw, "compare()")
    with Env(cwd, guild_home):
        return compare_impl.get_data(args, format_cells=False)
예제 #15
0
파일: s3.py 프로젝트: wangsd01/guildai
    def restore_runs(self, **opts):
        self._sync_runs_meta()
        args = click_util.Args(**opts)
        args.archive = self._deleted_runs_dir
        preview = "You are about to restore the following runs on %s:" % self.name
        confirm = "Restore these runs?"
        no_runs_help = "Nothing to restore."

        def restore_f(selected):
            self._restore_runs(selected)
            self._new_meta_id()
            self._sync_runs_meta(force=True)

        try:
            runs_impl.runs_op(
                args,
                None,
                False,
                preview,
                confirm,
                no_runs_help,
                restore_f,
                confirm_default=True,
            )
        except SystemExit as e:
            self._reraise_system_exit(e, deleted=True)
예제 #16
0
파일: s3.py 프로젝트: wangsd01/guildai
    def delete_runs(self, **opts):
        self._sync_runs_meta()
        args = click_util.Args(**opts)
        args.archive = self._runs_dir
        if args.permanent:
            preview = (
                "WARNING: You are about to permanently delete "
                "the following runs on %s:" % self.name
            )
            confirm = "Permanently delete these runs?"
        else:
            preview = "You are about to delete the following runs on %s:" % self.name
            confirm = "Delete these runs?"
        no_runs_help = "Nothing to delete."

        def delete_f(selected):
            self._delete_runs(selected, args.permanent)
            self._new_meta_id()
            self._sync_runs_meta(force=True)

        try:
            runs_impl.runs_op(
                args,
                None,
                False,
                preview,
                confirm,
                no_runs_help,
                delete_f,
                confirm_default=not args.permanent,
            )
        except SystemExit as e:
            self._reraise_system_exit(e)
예제 #17
0
파일: s3.py 프로젝트: wangsd01/guildai
 def filtered_runs(self, **filters):
     self._sync_runs_meta()
     args = click_util.Args(**filters)
     args.archive = self._runs_dir
     args.remote = None
     args.runs = []
     return runs_impl.runs_for_args(args)
예제 #18
0
def mark(runs, clear=False, cwd=".", guild_home=None, **kw):
    from guild import click_util
    from guild.commands import runs_impl
    args = click_util.Args(runs=(runs or []), clear=clear, yes=True)
    _apply_runs_filters(kw, args)
    _assert_empty_kw(kw, "mark()")
    with Env(cwd, guild_home):
        runs_impl.mark(args)
예제 #19
0
def runs_list(all=False, deleted=False, cwd=".", guild_home=None, **kw):
    from guild import click_util
    from guild.commands import runs_impl
    args = click_util.Args(all=all, deleted=deleted)
    _apply_runs_filters(kw, args)
    _assert_empty_kw(kw, "runs_list()")
    with Env(cwd, guild_home):
        return runs_impl.filtered_runs(args)
예제 #20
0
파일: _api.py 프로젝트: jli206/guildai
def runs_delete(runs=None, cwd=".", guild_home=None):
    from guild import click_util
    from guild.commands import runs_delete
    from guild.commands import runs_impl
    runs = runs or []
    args = runs + ["--yes"]
    ctx = runs_delete.delete_runs.make_context("", args)
    with Env(cwd, guild_home):
        runs_impl.delete_runs(click_util.Args(**ctx.params), ctx)
예제 #21
0
def run(start=None, **kw):
    from .run import run as run_cmd
    if start is not None:
        raise ValueError("start kw not supported, use restart instead")
    ctx = run_cmd.make_context("", [])
    ctx.params.update(kw)
    ctx.params["yes"] = True
    args = click_util.Args(**ctx.params)
    main(args)
예제 #22
0
def _ac_operation(ctx, incomplete, **_kw):
    from guild import cmd_impl_support
    from . import operations_impl

    cmd_impl_support.init_model_path()
    ops = operations_impl.filtered_ops(click_util.Args(**ctx.params))
    return sorted([
        op["fullname"] for op in ops if op["fullname"].startswith(incomplete)
    ])
예제 #23
0
def ac_runs_for_ctx(ctx):
    from guild import config
    from . import runs_impl

    param_args = click_util.Args(**ctx.params)
    if not hasattr(param_args, "runs"):
        param_args.runs = []
    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        return runs_impl.runs_for_args(param_args, ctx=ctx)
예제 #24
0
def _ac_path(ctx, **_kw):
    from . import runs_impl

    open_args = click_util.Args(**ctx.params)
    run = runs_impl.one_run(open_args, ctx)
    if open_args.sourcecode:
        dir_base = run.guild_path("sourcecode")
    else:
        dir_base = run.dir
    return click_util.completion_run_filepath(dir_base)
예제 #25
0
파일: s3.py 프로젝트: wangsd01/guildai
 def list_runs(self, verbose=False, **filters):
     self._sync_runs_meta()
     runs_dir = self._runs_dir_for_filters(**filters)
     if not os.path.exists(runs_dir):
         return
     args = click_util.Args(verbose=verbose, **filters)
     args.archive = runs_dir
     args.deleted = False
     args.remote = None
     args.json = False
     runs_impl.list_runs(args)
예제 #26
0
def runs_delete(runs=None, permanent=False, cwd=".", guild_home=None, **kw):
    from guild import click_util
    from guild.commands import runs_impl

    args = click_util.Args(
        runs=(runs or []), permanent=permanent, remote=False, yes=True
    )
    _apply_runs_filters(kw, args)
    _assert_empty_kw(kw, "runs_delete()")
    with Env(cwd, guild_home):
        runs_impl.delete_runs(args)
예제 #27
0
def ac_run_filepath(ctx, **_kw):
    if ctx.params.get("remote"):
        return []
    args = click_util.Args(**ctx.params)
    run = _one_run(ctx)
    if not run:
        return []
    if getattr(args, "sourcecode", None):
        return click_util.completion_run_filepath(run.guild_path("sourcecode"))
    else:
        return click_util.completion_run_filepath(run.dir)
예제 #28
0
파일: _api.py 프로젝트: jli206/guildai
def mark(run, clear=False, cwd=".", guild_home=None):
    from guild import click_util
    from guild.commands import mark
    from guild.commands import runs_impl
    args = [run, "--yes"]
    if clear:
        args.append("--clear")
    ctx = mark.mark.make_context("", args)
    args = click_util.Args(**ctx.params)
    with Env(cwd, guild_home):
        return runs_impl.mark(args, ctx)
예제 #29
0
파일: ssh.py 프로젝트: ErSKS/guildai
def _build_package(dist_dir):
    log.info("Building package")
    args = click_util.Args(dist_dir=dist_dir,
                           upload=False,
                           sign=False,
                           identity=None,
                           user=None,
                           password=None,
                           skip_existing=False,
                           comment=None)
    package_impl.main(args)
예제 #30
0
def select(run=None, min=None, max=None, cwd=".", guild_home=None, **kw):
    from guild import click_util
    from guild.commands import runs_impl

    args = click_util.Args(run=run, min=min, max=max)
    _apply_runs_filters(kw, args)
    _assert_empty_kw(kw, "select()")
    with Env(cwd, guild_home):
        try:
            return runs_impl.select_run(args)
        except SystemExit as e:
            raise ValueError(e)