def _remote_run_cmd(remote_run_dir, opspec, op_flags, label, disable_plugins, gpus, no_gpus, force_flags, needed, stop_after, optimize, optimizer, opt_flags, minimize, maximize, random_seed, max_trials, init_trials): cmd = [ "NO_WARN_RUNDIR=1", "guild", "run", q(opspec), "--run-dir", remote_run_dir, "--pidfile", "%s/.guild/JOB" % remote_run_dir, "--quiet", "--yes", ] if label: cmd.extend(["--label", q(label)]) if disable_plugins: cmd.extend(["--disable_plugins", q(disable_plugins)]) if gpus: cmd.extend(["--gpus", q(gpus)]) if no_gpus: cmd.append("--no-gpus") if force_flags: cmd.append("--force-flags") if needed: cmd.append("--needed") if stop_after: cmd.extend(["--stop-after", stop_after]) if optimize: cmd.append("--optimize") if optimizer: cmd.extend(["--optimizer", optimizer]) for val in opt_flags: cmd.extend(["--opt-flag", val]) if minimize: cmd.extend(["--minimize", minimize]) if maximize: cmd.extend(["--maximize", maximize]) if random_seed is not None: cmd.extend(["--random-seed", random_seed]) if max_trials is not None: cmd.extend(["--max-trials", max_trials]) if init_trials: cmd.append("--init-trials") cmd.extend([q(arg) for arg in op_flags]) return " ".join(cmd)
def _runs_filter_args( ops, labels, unlabeled, running, completed, error, terminated, pending, staged, marked, unmarked, started, digest): args = [] if completed: args.append("-C") if error: args.append("-E") for label in labels: args.extend(["--label", q(label)]) for op in ops: args.extend(["-o", op]) if running: args.append("-R") if terminated: args.append("-T") if pending: args.append("-P") if staged: args.append("-G") if unlabeled: args.append("-u") if marked: args.append("--marked") if unmarked: args.append("--unmarked") if started: args.append(["--started", started]) if digest: args.append(["--digest", digest]) return args
def _watch_run_args(run, ops, pid, labels, unlabeled, marked, unmarked): if pid: # Ignore other opts if pid is specified return ["--pid", pid] args = [] for op in ops: args.extend(["-o", q(op)]) for label in labels: args.extend(["-l", q(label)]) if unlabeled: args.append("-u") if marked: args.append("--marked") if unmarked: args.append("--unmarked") if run: args.append(run) return args
def _label_runs_args(runs, label, clear, yes, **filters): args = _runs_filter_args(**filters) if yes: args.append("-y") if clear: args.append("-c") args.extend(runs) if label: args.append(q(label)) return args
def _stop_runs_args(runs, ops, labels, unlabeled, no_wait, marked, unmarked, yes): args = [] for op in ops: args.extend(["-o", q(op)]) for label in labels: args.extend(["-l", q(label)]) if unlabeled: args.append("-u") if no_wait: args.append("-n") if yes: args.append("-y") if marked: args.append("--marked") if unmarked: args.append("--unmarked") args.extend(runs) return args
def one_run(self, run_id_prefix, attrs): """Returns run matching id prefix as remote.RunProxy with attrs. Currently only supports attrs as ["flags"]. """ assert len(attrs) == 1 and attrs[0] == "flags", attrs cmd_lines = ["set -e"] cmd_lines.extend(self._env_activate_cmd_lines()) cmd_lines.append("guild runs info %s --flags --private-attrs" % q(run_id_prefix)) cmd = "; ".join(cmd_lines) out = self._ssh_output(cmd) return remotelib.RunProxy(self._run_data_from_yaml(out))
def _runs_filter_args( ops, labels, unlabeled, running, completed, error, terminated, pending, staged, marked, unmarked, started, digest, ): args = [] if completed: args.append("--completed") if error: args.append("--error") for label in labels: args.extend(["--label", q(label)]) for op in ops: args.extend(["--operation", op]) if running: args.append("--running") if terminated: args.append("--terminated") if pending: args.append("--pending") if staged: args.append("--staged") if unlabeled: args.append("--unlabled") if marked: args.append("--marked") if unmarked: args.append("--unmarked") if started: args.append(["--started", started]) if digest: args.append(["--digest", digest]) return args
def _as_suffix(self): return " as %s" % q(self.named_as) if self.named_as else ""
def _remote_run_cmd( batch_label, batch_tag, force_flags, force_sourcecode, gpus, init_trials, label, max_trials, maximize, minimize, needed, no_gpus, op_flags, opspec, opt_flags, optimize, optimizer, proto, random_seed, remote_run_dir, stage, start, stop_after, tag, ): cmd = [ "NO_WARN_RUNDIR=1", "guild", "run", "--quiet", "--yes", ] if start: cmd.extend(["--start", remote_run_dir]) else: cmd.extend([q(opspec), "--run-dir", remote_run_dir]) if stage: cmd.append("--stage") else: cmd.extend(["--pidfile", "%s/.guild/JOB" % remote_run_dir]) if proto: cmd.extend(["--proto", proto]) if force_sourcecode: cmd.extend(["--force-sourcecode", force_sourcecode]) if label: cmd.extend(["--label", q(label)]) if tag: cmd.extend(["--tag", q(tag)]) if batch_label: cmd.extend(["--batch-label", q(batch_label)]) if batch_tag: cmd.extend(["--batch-tag", q(batch_tag)]) if gpus: cmd.extend(["--gpus", q(gpus)]) if no_gpus: cmd.append("--no-gpus") if force_flags: cmd.append("--force-flags") if needed: cmd.append("--needed") if stop_after: cmd.extend(["--stop-after", str(stop_after)]) if optimize: cmd.append("--optimize") if optimizer: cmd.extend(["--optimizer", optimizer]) for val in opt_flags: cmd.extend(["--opt-flag", val]) if minimize: cmd.extend(["--minimize", minimize]) if maximize: cmd.extend(["--maximize", maximize]) if random_seed is not None: cmd.extend(["--random-seed", str(random_seed)]) if max_trials is not None: cmd.extend(["--max-trials", str(max_trials)]) if init_trials: cmd.append("--init-trials") cmd.extend([q(arg) for arg in op_flags]) return " ".join(cmd)