Ejemplo n.º 1
0
def _print_staged_dir_instructions(run):
    cmd_args = run.get("cmd") or []
    cmd = " ".join([util.shlex_quote(arg) for arg in cmd_args])
    cli.out("{op} staged in '{dir}'\n"
            "To start the operation, use "
            "\"(cd '{dir}' && source .guild/ENV && {cmd})\"".format(
                op=run_util.format_operation(run), dir=run.dir, cmd=cmd))
Ejemplo n.º 2
0
def _log_start_trial(run, stage):
    log.info(
        "%s trial %s: %s (%s)",
        "Running" if not stage else "Staging",
        _trial_name(run),
        run_util.format_operation(run),
        _trial_flags_desc(run),
    )
Ejemplo n.º 3
0
def ac_operation(ctx, incomplete, **_kw):
    from guild import run_util

    if ctx.params.get("remote"):
        return []
    runs = _ac_runs_for_ctx(ctx)
    ops = set([run_util.format_operation(run, nowarn=True) for run in runs])
    return sorted([op for op in ops if op.startswith(incomplete)])
Ejemplo n.º 4
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, run_util.format_operation(run, nowarn=True)))
        for s in index.run_scalars(run):
            key, step, val = (run_util.run_scalar_key(s), s["last_step"], s["last_val"])
            cli.out("  %s: %f (step %i)" % (key, val, step))
Ejemplo n.º 5
0
def _completed_op_filter(proto_run):
    assert proto_run

    proto_opspec = run_util.format_operation(proto_run, nowarn=True)

    def f(run):
        run_opspec = run_util.format_operation(run, nowarn=True)
        return run.status == "completed" and run_opspec == proto_opspec

    return f
Ejemplo n.º 6
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 = run_util.format_operation(run, nowarn=True)
         return operation, run.short_id
Ejemplo n.º 7
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": run_util.format_operation(run),
         "from": run_util.format_pkg_name(run),
         "op": opref.op_name,
         "sourcecode": util.short_digest(run.get("sourcecode_digest")),
         "started": util.format_timestamp(started),
         "stopped": util.format_timestamp(stopped),
         "status": status,
         "time": self._duration(status, started, stopped),
     }
Ejemplo n.º 8
0
def _format_run_detail(run, index):
    lines = [
        "Id: %s" % run.id,
        "Operation: %s" % run_util.format_operation(run),
        "From: %s" % run_util.format_pkg_name(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:
            lines.append("  %s" % run_util.run_scalar_key(s))
    return "\n".join(lines)
Ejemplo n.º 9
0
def _hparam_session_name(run):
    operation = run_util.format_operation(run)
    return "%s %s" % (run.short_id, operation)
Ejemplo n.º 10
0
 def f(run):
     op = run_util.format_operation(run, nowarn=True)
     pkg = run_util.format_pkg_name(run)
     full_op = "%s/%s" % (pkg, op)
     return any((ref in full_op for ref in op_refs))
Ejemplo n.º 11
0
 def _format_dep(run, paths):
     return {
         "run": run.short_id,
         "operation": run_util.format_operation(run, nowarn=True),
         "paths": paths
     }
Ejemplo n.º 12
0
 def f(run):
     run_opspec = run_util.format_operation(run, nowarn=True)
     return run.status == "completed" and run_opspec == proto_opspec
Ejemplo n.º 13
0
 def f(run):
     opspec = run_util.format_operation(run, nowarn=True)
     return any((ref in opspec for ref in op_refs))
Ejemplo n.º 14
0
def _print_stage_pending_instructions(run):
    cli.out("{op} staged as {run_id}\n"
            "To start the operation, use 'guild run --start {run_id}'".format(
                op=run_util.format_operation(run), run_id=run.id))
Ejemplo n.º 15
0
 def f(run):
     opspec = run_util.format_operation(run, nowarn=True)
     return any((_compare_op(ref, opspec) for ref in op_refs))