def _run_data(self, run, index): formatted = run_util.format_run(run) return { "id": run.id, "shortId": run.short_id, "path": run.path, "operation": formatted["operation"], "opModel": run.opref.model_name, "opName": run.opref.op_name, "started": formatted["started"], "stopped": formatted["stopped"], "time": self._run_duration(run), "label": formatted["label"], "tags": self._format_tags(run.get("tags") or []), "comments": run.get("comments") or [], "status": run.status, "exitStatus": formatted["exit_status"] or None, "command": formatted["command"], "otherAttrs": self._other_attrs(run), "flags": run.get("flags", {}), "scalars": self._run_scalars(run, index), "env": run.get("env", {}), "deps": self._format_deps(run.get("deps", {})), "files": self._format_files(run.iter_files(), run.path), }
def _runs_op(args, ctx, force_deleted, preview_msg, confirm_prompt, no_runs_help, op_callback, default_runs_arg=None, confirm_default=False, runs_callback=None): get_selected = runs_callback or _runs_op_selected selected = get_selected(args, ctx, default_runs_arg, force_deleted) if not selected: _no_selected_runs_exit(no_runs_help) formatted = [run_util.format_run(run) for run in selected] if not args.yes: cli.out(preview_msg) cols = [ "short_index", "operation_with_marked", "started", "status_with_remote", "label" ] cli.table(formatted, cols=cols, indent=2) formatted_confirm_prompt = confirm_prompt.format(count=len(formatted)) if args.yes or cli.confirm(formatted_confirm_prompt, confirm_default): if len(inspect.getargspec(op_callback).args) == 2: op_callback(selected, formatted) else: op_callback(selected)
def _print_matching_runs(runs): formatted = [run_util.format_run(run) for run in runs] cols = [ "index", "operation", "started", "status_with_remote", "label" ] cli.table(formatted, cols=cols, indent=2)
def _try_print_formatted_run_attr(run, attr_name): formatted = run_util.format_run(run) try: val = formatted[attr_name] except KeyError: raise util.TryFailed() else: print(val)
def format_runs(runs): formatted = [] for i, run in enumerate(runs): try: formatted_run = run_util.format_run(run, i + 1) except Exception: log.exception("formatting run in %s", run.path) else: formatted.append(formatted_run) _apply_op_desc(formatted) return formatted
def _list_formatted_runs(runs, args): formatted = [] for i, run in enumerate(runs): try: formatted_run = run_util.format_run(run, i + 1) except Exception: log.exception("formatting run in %s", run.path) else: formatted.append(formatted_run) limited_formatted = _limit_runs(formatted, args) cols = [ "index", "operation_with_marked", "started", "status_with_remote", "label" ] detail = RUN_DETAIL if args.verbose else None cli.table(limited_formatted, cols=cols, detail=detail)
def _print_run_info(run, args): formatted = run_util.format_run(run) out = cli.out for name in RUN_DETAIL: out("%s: %s" % (name, formatted[name])) for name in other_attr_names(run, args.private_attrs): out("%s: %s" % (name, run_util.format_attr(run.get(name)))) out("flags:", nl=False) out(run_util.format_attr(run.get("flags", "")).rstrip()) _maybe_print_proto_flags(run, out) if args.env: out("environment:", nl=False) out(run_util.format_attr(run.get("env", ""))) if args.scalars: out("scalars:") for scalar in _iter_scalars(run): out(" %s" % scalar) if args.deps: out("dependencies:") deps = run.get("deps", {}) for name in sorted(deps): out(" %s:" % name) for path in deps[name]: out(" %s" % path) if args.sourcecode: out("sourcecode:") for path in sorted(run.iter_guild_files("sourcecode")): out(" %s" % path) if args.output: out("output:") for line in run_util.iter_output(run): out(" %s" % line, nl=False) if args.files or args.all_files: out("files:") for path in sorted(run.iter_files(args.all_files, args.follow_links)): if args.files == 1: path = os.path.relpath(path, run.path) out(" %s" % path)
def _format_run_for_publish(run): frun = run_util.format_run(run) if not frun["stopped"]: frun["duration"] = "" return frun
def _format_run(run, cols): fmt = run_util.format_run(run) return [_run_attr(run, name, fmt) for name in cols]
def _skip_needed_matches_info(matching_runs): cli.out("Skipping because the following runs match " "this operation (--needed specified):") formatted = [run_util.format_run(run) for run in matching_runs] cols = ["index", "operation", "started", "status_with_remote", "label"] cli.table(formatted, cols=cols, indent=2)