How to use the fvcore.common.file_io.PathManager.exists function in fvcore

To help you get started, we’ve selected a few fvcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebookresearch / fvcore / tests / test_file_io.py View on Github external
def test_exists(self):
        self.assertTrue(PathManager.exists(self._tmpfile))
        fake_path = os.path.join(self._tmpdir, uuid.uuid4().hex)
        self.assertFalse(PathManager.exists(fake_path))
github facebookresearch / fvcore / tests / test_file_io.py View on Github external
def test_rm(self):
        with open(os.path.join(self._tmpdir, "test_rm.txt"), "w") as f:
            rm_file = f.name
            f.write(self._tmpfile_contents)
            f.flush()
        self.assertTrue(PathManager.exists(rm_file))
        self.assertTrue(PathManager.isfile(rm_file))
        PathManager.rm(rm_file)
        self.assertFalse(PathManager.exists(rm_file))
        self.assertFalse(PathManager.isfile(rm_file))
github facebookresearch / fvcore / tests / test_file_io.py View on Github external
def test_mkdirs(self):
        new_dir_path = os.path.join(self._tmpdir, "new", "tmp", "dir")
        self.assertFalse(PathManager.exists(new_dir_path))
        PathManager.mkdirs(new_dir_path)
        self.assertTrue(PathManager.exists(new_dir_path))
github facebookresearch / fvcore / tests / test_file_io.py View on Github external
def test_exists(self):
        self.assertTrue(PathManager.exists(self._tmpfile))
        fake_path = os.path.join(self._tmpdir, uuid.uuid4().hex)
        self.assertFalse(PathManager.exists(fake_path))
github facebookresearch / fvcore / tests / test_file_io.py View on Github external
def test_mkdirs(self):
        new_dir_path = os.path.join(self._tmpdir, "new", "tmp", "dir")
        self.assertFalse(PathManager.exists(new_dir_path))
        PathManager.mkdirs(new_dir_path)
        self.assertTrue(PathManager.exists(new_dir_path))
github facebookresearch / fvcore / fvcore / common / checkpoint.py View on Github external
def has_checkpoint(self):
        """
        Returns:
            bool: whether a checkpoint exists in the target directory.
        """
        save_file = os.path.join(self.save_dir, "last_checkpoint")
        return PathManager.exists(save_file)
github pytorch / translate / pytorch_translate / data / utils.py View on Github external
def validate_corpus_exists(
    corpus: pytorch_translate_data.ParallelCorpusConfig, split: str, is_npz: bool = True
):
    """
    Makes sure that the files in the `corpus` are valid files. `split` is used
    for logging.
    """
    if is_npz:
        if not PathManager.exists(corpus.source.data_file):
            raise ValueError(f"{corpus.source.data_file} for {split} not found!")
        if not PathManager.exists(corpus.target.data_file):
            raise ValueError(f"{corpus.target.data_file} for {split} not found!")
    else:
        if not IndexedDataset.exists(corpus.source.data_file):
            raise ValueError(f"{corpus.source.data_file} for {split} not found!")
        if not IndexedDataset.exists(corpus.target.data_file):
            raise ValueError(f"{corpus.target.data_file} for {split} not found!")