def test_base_path(self, paths, base_path): filepaths = _file_utils.flatten_file_trees(paths) expected_paths = set( os.path.relpath(path, base_path) for path in filepaths) dataset = verta.dataset.Path(paths, base_path) assert set(dataset.list_paths()) == expected_paths
def test_flatten_file_trees(self, in_tempdir): filepaths = { "README.md", "data/train.csv", "data/test.csv", "script.py", "utils/data/clean.py", "utils/misc/misc.py", } paths = ["README.md", "data", "script.py", "utils"] # create files for filepath in filepaths: filepath = pathlib2.Path(filepath) filepath.parent.mkdir(parents=True, exist_ok=True) filepath.touch() assert _file_utils.flatten_file_trees(paths) == filepaths