def create_file_symlink(file1, file2): """ Simply create the symlinks for a given file1 to file2. Useful during model checkpointing to symlinks to the latest successful checkpoint. """ try: if PathManager.exists(file2): PathManager.rm(file2) PathManager.symlink(file1, file2) except Exception as e: logging.info(f"Could NOT create symlink. Error: {e}")
def test_symlink(self) -> None: _symlink = self._tmpfile + "_symlink" # pyre-ignore assert PathManager.symlink(self._tmpfile, _symlink) # pyre-ignore with PathManager.open(_symlink) as f: self.assertEqual(f.read(), self._tmpfile_contents) assert os.readlink(_symlink) == self._tmpfile os.remove(_symlink)