Exemplo n.º 1
0
def _init_tfevent_link(tfevent_src, tfevent_link, run, state):
    link_dir = os.path.dirname(tfevent_link)
    util.ensure_dir(link_dir)
    if state.log_hparams:
        _init_hparam_session(run, link_dir, state)
    log.debug("Creating link from '%s' to '%s'", tfevent_src, tfevent_link)
    util.symlink(tfevent_src, tfevent_link)
Exemplo n.º 2
0
def _symlink(source_path, link):
    assert os.path.isabs(link), link
    if os.path.exists(link):
        log.warning("%s already exists, skipping link", link)
        return
    util.ensure_dir(os.path.dirname(link))
    log.debug("resolving source %s as link %s", source_path, link)
    util.symlink(source_path, link)
Exemplo n.º 3
0
def _link_to_source(source_path, link):
    assert os.path.isabs(link), link
    source_path = util.strip_trailing_sep(source_path)
    if os.path.lexists(link) or os.path.exists(link):
        log.warning("%s already exists, skipping link", link)
        return
    util.ensure_dir(os.path.dirname(link))
    log.debug("resolving source %s as link %s", source_path, link)
    source_rel_path = _source_rel_path(source_path, link)
    util.symlink(source_rel_path, link)
Exemplo n.º 4
0
 def _refresh_run_link(self, link, run_dir):
     to_delete = [
         os.path.relpath(p, link) for p in self._iter_tfevent_paths(link)
     ]
     for tfevent_path in self._iter_tfevent_paths(run_dir):
         tfevent_relpath = os.path.relpath(tfevent_path, run_dir)
         util.remove(tfevent_relpath, to_delete)
         tfevent_link = os.path.join(link, tfevent_relpath)
         if not os.path.exists(tfevent_link):
             log.debug("Creating link %s", tfevent_link)
             util.ensure_dir(os.path.dirname(tfevent_link))
             util.symlink(tfevent_path, tfevent_link)
     for path in to_delete:
         tfevent_link = os.path.join(link, path)
         log.debug("Removing %s", tfevent_link)
         os.remove(tfevent_link)
Exemplo n.º 5
0
def _link_to_source(source_path, link, replace_existing=False):
    assert os.path.isabs(link), link
    source_path = util.strip_trailing_sep(source_path)
    if os.path.lexists(link) or os.path.exists(link):
        if not replace_existing:
            log.warning("%s already exists, skipping link", link)
            return
        log.debug("deleting existing source link %s", link)
        util.safe_rmtree(link)
    util.ensure_dir(os.path.dirname(link))
    log.debug("resolving source %s as link %s", source_path, link)
    source_rel_path = _source_rel_path(source_path, link)
    try:
        util.symlink(source_rel_path, link)
    except OSError as e:
        _handle_source_link_error(e)
Exemplo n.º 6
0
def _link_guild_dir(src, link):
    if os.path.lexists(link):
        link_target = os.path.realpath(link)
        if not util.compare_paths(src, link_target):
            log.warning(
                "Guild directory %s exists (links to %s), "
                "skipping link to Guild home %s",
                link,
                link_target,
                src,
            )
        return
    elif os.path.exists(link):
        log.warning(
            "Guild directory %s exists, skipping link to Guild home %s", link,
            src)
        return
    util.ensure_dir(os.path.dirname(link))
    util.symlink(src, link)
Exemplo n.º 7
0
 def _create_run_link(link, run_dir):
     log.debug("Linking %s to %s", link, run_dir)
     util.symlink(run_dir, link)
Exemplo n.º 8
0
def _init_tfevent_link(tfevent_src, tfevent_link, run, state):
    link_dir = os.path.dirname(tfevent_link)
    util.ensure_dir(link_dir)
    if state.log_hparams:
        _init_hparam_session(run, link_dir, state)
    util.symlink(tfevent_src, tfevent_link)
Exemplo n.º 9
0
def _ensure_run_file_link(src, link, link_dir):
    if not os.path.exists(link):
        log.debug("Creating link from '%s' to '%s'", src, link)
        util.ensure_dir(link_dir)
        util.symlink(src, link)