Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/cleanvision/dataset/fsspec_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def __init__(
self._filepaths = self.__get_filepaths(dataset_path)
else:
assert filepaths is not None
if len(filepaths) != len(set(filepaths)):
raise ValueError(
"Duplicate filepaths found in the provided list, please remove these duplicates."
)
self._filepaths = filepaths
# here we assume all of the provided filepaths are from the same filesystem
self.fs, _ = fsspec.core.url_to_fs(self._filepaths[0], **self.storage_opts)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def test_run_imagelab_given_filepaths(generate_local_dataset, images_per_class):
assert len(imagelab.issues) == images_per_class


def test_raise_error_given_duplicate_filepaths():
filepaths = ["/home/user/file0.jpg", "/home/user/file1.jpg", "/home/user/file0.jpg"]
with pytest.raises(ValueError, match="Duplicate"):
Imagelab(filepaths=filepaths)


def test_s3_dataset(capsys, get_example_s3_filepaths):
imagelab = Imagelab(filepaths=get_example_s3_filepaths, storage_opts={"anon": True})
imagelab.find_issues(
Expand Down