Ejemplo n.º 1
0
def _format_run_detail(run, index):
    lines = [
        "Id: %s" % run.id,
        "Operation: %s" % op_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)
Ejemplo n.º 2
0
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, op_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"])
Ejemplo n.º 3
0
 def _row_for_print_run(run, flags, labels, status):
     row = {"opspec": op_util.format_op_desc(run)}
     if flags:
         flags_desc = " ".join([
             "%s=%s" % (name, op_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
Ejemplo n.º 4
0
 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": op_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),
     }
Ejemplo n.º 5
0
 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 = op_util.format_op_desc(run, nowarn=True)
         return operation, run.short_id
Ejemplo n.º 6
0
def format_run(run, index=None):
    status = run.status
    operation = op_util.format_op_desc(run)
    marked = bool(run.get("marked"))
    return {
        "id": run.id,
        "index": _format_run_index(run, index),
        "short_index": _format_run_index(run),
        "model": run.opref.model_name,
        "op_name": run.opref.op_name,
        "operation": operation,
        "operation_with_marked": _op_with_marked(operation, marked),
        "pkg": run.opref.pkg_name,
        "status": status,
        "status_with_remote": _status_with_remote(status, run.remote),
        "marked": _format_val(marked),
        "label": _format_label(run.get("label") or ""),
        "pid": run.pid or "",
        "started": util.format_timestamp(run.get("started")),
        "stopped": util.format_timestamp(run.get("stopped")),
        "run_dir": util.format_dir(run.path),
        "command": _format_command(run.get("cmd", "")),
        "exit_status": _exit_status(run)
    }
Ejemplo n.º 7
0
 def f(run):
     op_desc = op_util.format_op_desc(run, nowarn=True)
     return any((ref in op_desc for ref in op_refs))
Ejemplo n.º 8
0
 def _format_dep(run, paths):
     return {
         "run": run.short_id,
         "operation": op_util.format_op_desc(run, nowarn=True),
         "paths": paths
     }