Skip to content
Open
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
10 changes: 2 additions & 8 deletions src/datasets/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,10 +977,6 @@ def dataset_module_factory(
elif e.response.status_code == 403:
message += f" Visit the dataset page at https://huggingface.co/datasets/{path} to ask for access."
raise DatasetNotFoundError(message) from e
except RevisionNotFoundError as e:
raise DatasetNotFoundError(
f"Revision '{revision}' doesn't exist for dataset '{path}' on the Hub."
) from e
except RepositoryNotFoundError as e:
raise DatasetNotFoundError(f"Dataset '{path}' doesn't exist on the Hub or cannot be accessed.") from e
try:
Expand Down Expand Up @@ -1014,10 +1010,8 @@ def dataset_module_factory(
elif e.response.status_code == 403:
message += f" Visit the dataset page at https://huggingface.co/datasets/{path} to ask for access."
raise DatasetNotFoundError(message) from e
except RevisionNotFoundError as e:
raise DatasetNotFoundError(
f"Revision '{revision}' doesn't exist for dataset '{path}' on the Hub."
) from e
except RevisionNotFoundError as e:
raise DatasetNotFoundError(f"Revision '{revision}' doesn't exist for dataset '{path}' on the Hub.") from e
except Exception as e1:
# All the attempts failed, before raising the error we should check if the module is already cached
try:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,18 @@ def test_load_dataset_from_hub(self):
str(context.exception),
)

@pytest.mark.integration
def test_load_dataset_invalid_revision_with_cache(self):
repo_id = SAMPLE_DATASET_IDENTIFIER2
builder = load_dataset_builder(repo_id, cache_dir=self.cache_dir)
builder.download_and_prepare()
with self.assertRaises(DatasetNotFoundError) as context:
datasets.load_dataset(repo_id, revision="invalid_revision", cache_dir=self.cache_dir)
self.assertIn(
"Revision 'invalid_revision' doesn't exist for dataset",
str(context.exception),
)

def test_load_dataset_namespace(self):
with self.assertRaises(DatasetNotFoundError) as context:
datasets.load_dataset("hf-internal-testing/_dummy")
Expand Down