def _format_run_detail(run, index): lines = [ "Id: %s" % run.id, "Operation: %s" % run_util.format_op_desc(run), "Status: %s" % run.status, "Started: %s" % util.format_timestamp(run.get("started")), "Stopped: %s" % util.format_timestamp(run.get("stopped")), "Label: %s" % (run.get("label") or ""), ] flags = run.get("flags") if flags: lines.append("Flags:") for name, val in sorted(flags.items()): val = val if val is not None else "" lines.append(" {}: {}".format(name, val)) scalars = list(index.run_scalars(run)) if scalars: lines.append("Scalars:") for s in scalars: prefix = s["prefix"] if prefix: lines.append(" %s#%s" % (s["prefix"], s["tag"])) else: lines.append(" %s" % s["tag"]) return "\n".join(lines)
def _print_scalars(args): runs = runs_impl.runs_for_args(args) index = indexlib.RunIndex() index.refresh(runs, ["scalar"]) for run in runs: cli.out("[%s] %s" % (run.short_id, run_util.format_op_desc(run))) for s in index.run_scalars(run): cli.out(" %s" % run_util.run_scalar_key(s))
def _row_for_print_run(run, flags, labels, status): row = {"opspec": run_util.format_op_desc(run)} if flags: flag_vals = run.get("flags") or {} flags_desc = " ".join(op_util.flag_assigns(flag_vals, quote=True)) row["flags"] = flags_desc if labels: row["label"] = run.get("label", "") if status: row["status"] = run.status return row
def _print_scalars(args): runs = runs_impl.runs_for_args(args) index = indexlib.RunIndex() index.refresh(runs, ["scalar"]) for run in runs: cli.out("[%s] %s" % (run.short_id, run_util.format_op_desc(run))) for s in index.run_scalars(run): prefix = s["prefix"] if prefix: cli.out(" %s#%s" % (s["prefix"], s["tag"])) else: cli.out(" %s" % s["tag"])
def _row_for_print_run(run, flags, labels, status): row = {"opspec": run_util.format_op_desc(run)} if flags: flags_desc = " ".join([ "%s=%s" % (name, run_util.format_flag_val(val)) for name, val in sorted(run.get("flags").items()) ]) row["flags"] = flags_desc if labels: row["label"] = run.get("label", "") if status: row["status"] = run.status return row
def _run_data(self, run): opref = run.opref started = run.get("started") stopped = run.get("stopped") status = run.status return { "id": run.id, "run": run.short_id, "model": opref.model_name, "operation": run_util.format_op_desc(run), "op": opref.op_name, "started": util.format_timestamp(started), "stopped": util.format_timestamp(stopped), "status": status, "time": self._duration(status, started, stopped), }
def _op_source_info(self, path): if not os.path.islink(path): return None, None path = os.path.realpath(path) runs_dir = var.runs_dir() if not path.startswith(runs_dir): return None, None subdir = path[len(runs_dir)+1:] parts = subdir.split(os.path.sep, 1) try: run = self._run_for_id(parts[0]) except LookupError: return "%s (deleted)" % parts[0][:8], None else: operation = run_util.format_op_desc(run, nowarn=True) return operation, run.short_id
def f(run): op_desc = run_util.format_op_desc(run, nowarn=True) return any((ref in op_desc for ref in op_refs))
def _format_dep(run, paths): return { "run": run.short_id, "operation": run_util.format_op_desc(run, nowarn=True), "paths": paths }