コード例 #1
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
def _set_tags_preview(args):
    lines = ["You are about to modify tags for the following runs:"]
    if args.sync_labels:
        lines.append(
            cmd_impl_support.format_warn(
                "Labels are updated to reflect the latest tags."))
    else:
        lines.append(
            cmd_impl_support.format_warn(
                "Labels are not updated - use --sync-labels to "
                "apply changes run labels."))
    return "\n".join(lines)
コード例 #2
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"])
コード例 #3
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
def _scalar_info(run, args):
    try:
        return _scalar_info_(run, args)
    except Exception as e:
        if log.getEffectiveLevel() <= logging.DEBUG:
            log.exception("get scalars")
        return cmd_impl_support.format_warn("ERROR: %s" % e)
コード例 #4
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
def _stop_runs(args, ctx):
    preview = cmd_impl_support.format_warn(
        "You are about to stop the following runs:")
    confirm = "Stop {count} run(s)?"
    no_runs_help = "Nothing to stop."
    if not args.runs:
        args.status_running = True

    def stop_f(selected):
        for run in selected:
            _stop_run(run, args.no_wait)

    def select_runs_f(args, ctx, default_runs_arg):
        runs = runs_op_selected(args, ctx, default_runs_arg)
        return [run for run in runs if not run.remote]

    runs_op(
        args,
        ctx,
        preview,
        confirm,
        no_runs_help,
        stop_f,
        None,
        False,
        select_runs_f,
    )
コード例 #5
0
def stop(args):
    remote = remote_support.remote_for_args(args)
    prompt = "You are about to STOP %s" % remote.name
    stop_details = remote.stop_details()
    if stop_details:
        prompt += "\n" + stop_details
    else:
        prompt += "\nThis action may result in permanent loss of data."
    prompt = cmd_impl_support.format_warn(prompt)
    _remote_op(remote.stop, prompt, False, args)
コード例 #6
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
def _purge_runs(args, ctx):
    preview = cmd_impl_support.format_warn(
        "WARNING: You are about to permanently delete the following runs:")
    confirm = "Permanently delete {count} run(s)?"
    no_runs_help = "Nothing to purge."

    def purge(selected):
        var.purge_runs(selected)
        cli.out("Permanently deleted %i run(s)" % len(selected), err=True)

    runs_op(args.copy(deleted=True), ctx, preview, confirm, no_runs_help,
            purge)
コード例 #7
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
 def import_f(selected):
     if args.copy_resources and not args.yes:
         cli.out(
             cmd_impl_support.format_warn(
                 "WARNING: You specified --copy-resources, which will "
                 "copy resources used by each run."),
             err=True,
         )
         if not cli.confirm("Really copy resources exported runs?"):
             raise SystemExit(exit_code.ABORTED)
     try:
         imported = run_util.import_runs(
             selected,
             move=args.move,
             copy_resources=args.copy_resources,
         )
     except run_util.RunsImportError as e:
         cli.error(e.args[0])
     cli.out("Imported %i run(s) from %s" % (len(imported), args.archive),
             err=True)
コード例 #8
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
def _delete_runs(args, ctx):
    if args.permanent:
        preview = cmd_impl_support.format_warn(
            "WARNING: You are about to permanently delete the following runs:")
        confirm = "Permanently delete {count} run(s)?"
    else:
        preview = "You are about to delete the following runs:"
        confirm = "Delete {count} run(s)?"
    no_runs_help = "Nothing to delete."

    def delete(selected):
        stoppable = [
            run for run in selected
            if run.status == "running" and not run.remote
        ]
        if stoppable and not args.yes:
            cli.out(
                cmd_impl_support.format_warn(
                    "WARNING: One or more runs are still running "
                    "and will be stopped before being deleted."),
                err=True,
            )
            if not cli.confirm("Really delete these runs?"):
                raise SystemExit(exit_code.ABORTED)
        for run in stoppable:
            _stop_run(run, no_wait=True)
        var.delete_runs(selected, args.permanent)
        if args.permanent:
            cli.out("Permanently deleted %i run(s)" % len(selected), err=True)
        else:
            cli.out("Deleted %i run(s)" % len(selected), err=True)

    runs_op(
        args,
        ctx,
        preview,
        confirm,
        no_runs_help,
        delete,
        confirm_default=not args.permanent,
    )
コード例 #9
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
 def delete(selected):
     stoppable = [
         run for run in selected
         if run.status == "running" and not run.remote
     ]
     if stoppable and not args.yes:
         cli.out(
             cmd_impl_support.format_warn(
                 "WARNING: One or more runs are still running "
                 "and will be stopped before being deleted."),
             err=True,
         )
         if not cli.confirm("Really delete these runs?"):
             raise SystemExit(exit_code.ABORTED)
     for run in stoppable:
         _stop_run(run, no_wait=True)
     var.delete_runs(selected, args.permanent)
     if args.permanent:
         cli.out("Permanently deleted %i run(s)" % len(selected), err=True)
     else:
         cli.out("Deleted %i run(s)" % len(selected), err=True)
コード例 #10
0
ファイル: runs_impl.py プロジェクト: hkennyv/guildai
def _clear_comments(args, ctx):
    preview = cmd_impl_support.format_warn(
        "WARNING: You are about to delete ALL comments from the following runs:"
    )
    confirm = "Continue?"
    no_runs = "No runs to modify."

    def clear_comments(selected):
        for run in selected:
            run.del_attr("comments")
        cli.out("Deleted all comments for %i run(s)" % len(selected), err=True)

    runs_op(
        args,
        ctx,
        preview,
        confirm,
        no_runs,
        clear_comments,
        LATEST_RUN_ARG,
    )