Exemplo n.º 1
0
 def _pull_run(self, run, delete):
     src_path = "{}/runs/{}/".format(self.guild_home, run.id)
     src = ssh_util.format_rsync_host_path(self.host, src_path, self.user)
     dest = os.path.join(var.runs_dir(), run.id + "/")
     cmd = ["rsync"] + self._pull_rsync_opts(delete) + [src, dest]
     cmd.extend(
         ssh_util.rsync_ssh_opts(remote_util.config_path(self.private_key),
                                 self.connect_timeout, self.port))
     log.info("Copying %s", run.id)
     log.debug("rsync cmd: %r", cmd)
     subprocess.check_call(cmd)
     remote_util.set_remote_lock(run, self.name)
Exemplo n.º 2
0
 def _init_trial_run(self, run_dir=None):
     assert isinstance(self.flags, dict), self.flags
     run_dir = run_dir or os.path.join(var.runs_dir(), self.run_id)
     run = runlib.Run(self.run_id, run_dir)
     if run.get("batch") != self.batch.batch_run.id:
         util.copytree(self.batch.proto_run.path, run_dir)
         for name, val in self.attrs.items():
             run.write_attr(name, val)
         run.write_attr("initialized", runlib.timestamp())
         run.write_attr("flags", self.flags)
         run.write_attr("batch", self.batch.batch_run.id)
     return run
Exemplo n.º 3
0
def set_remote_lock(remote_run, remote_name, runs_dir=None):
    runs_dir = runs_dir or var.runs_dir()
    local_run_dir = os.path.join(runs_dir, remote_run.id)
    lock_file = os.path.join(local_run_dir, ".guild", "LOCK")
    remote_lock_file = os.path.join(local_run_dir, ".guild", "LOCK.remote")
    util.ensure_deleted(lock_file)
    util.ensure_deleted(remote_lock_file)
    if remote_run.status == "running":
        with open(remote_lock_file, "w") as f:
            f.write(remote_name)
    elif remote_run.status == "terminated":
        with open(lock_file, "w") as f:
            f.write("0")
Exemplo n.º 4
0
 def _file_type_info(self, path):
     typeDesc, icon, iconTooltip, viewer = self._base_file_type_info(path)
     if os.path.islink(path):
         target = os.path.realpath(path)
         link_type = "directory" if os.path.isdir(target) else "file"
         if target.startswith(var.runs_dir()):
             typeDesc = "Link to operation output"
         elif target.startswith(var.cache_dir()):
             typeDesc = "Link to resource {}".format(link_type)
         else:
             typeDesc = "Link"
         icon = "folder-move" if link_type == "directory" else "file-send"
         iconTooltip = "Link"
     return typeDesc, icon, iconTooltip, viewer
Exemplo 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 = run_util.format_operation(run, nowarn=True)
         return operation, run.short_id
Exemplo n.º 6
0
def _trial_name(run):
    if util.compare_paths(os.path.dirname(run.dir), var.runs_dir()):
        return os.path.basename(run.dir)
    else:
        return "in %s" % run.dir
Exemplo n.º 7
0
def _runs_root_for_args(args, force_deleted):
    archive = getattr(args, "archive", None)
    if archive:
        return archive
    deleted = force_deleted or getattr(args, "deleted", False)
    return var.runs_dir(deleted=deleted)
Exemplo n.º 8
0
 def __init__(self):
     super(RunFiles, self).__init__({"/files": var.runs_dir()})
Exemplo n.º 9
0
def _init_run():
    run_id = runlib.mkid()
    run_dir = os.path.join(var.runs_dir(), run_id)
    run = runlib.Run(run_id, run_dir)
    run.init_skel()
    return run
Exemplo n.º 10
0
def _run_desc_for_restart(run):
    rel_to_runs_dir = os.path.relpath(run.path, var.runs_dir())
    if rel_to_runs_dir == run.id:
        return run.id
    return "run in %s" % run.path
Exemplo n.º 11
0
def _local_run_dir(remote_run, runs_dir=None):
    runs_dir = runs_dir or var.runs_dir()
    return os.path.join(runs_dir, remote_run.id)
Exemplo n.º 12
0
def _run_action_run_desc(run):
    rel_to_runs_dir = os.path.relpath(run.path, var.runs_dir())
    if rel_to_runs_dir == run.id:
        return run.id
    return "run in %s" % run.path
Exemplo n.º 13
0
def _runs_root_for_args(args, force_deleted):
    deleted = force_deleted or getattr(args, "deleted", False)
    return var.runs_dir(deleted=deleted)