Skip to content

Commit 8807a05

Browse files
fineguyThe TensorFlow Datasets Authors
authored andcommitted
Fix huggingface_utils.to_huggingface_name.
PiperOrigin-RevId: 704654760
1 parent 31dccc7 commit 8807a05

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tensorflow_datasets/core/utils/huggingface_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ def to_huggingface_name(tfds_dataset_name: str) -> str:
139139
DatasetNotFoundError: If the TFDS dataset name doesn't correspond to any
140140
existing Huggingface dataset.
141141
"""
142-
for hf_dataset_name in huggingface_hub.list_datasets():
142+
for hf_dataset_info in huggingface_hub.list_datasets():
143143
if (
144-
conversion_utils.to_tfds_name(hf_dataset_name)
144+
conversion_utils.to_tfds_name(hf_dataset_info.id)
145145
== tfds_dataset_name.lower()
146146
):
147-
return hf_dataset_name
147+
return hf_dataset_info.id
148148
raise registered.DatasetNotFoundError(
149149
f'"{tfds_dataset_name}" is not listed in Huggingface datasets.'
150150
)

tensorflow_datasets/core/utils/huggingface_utils_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ def test_convert_hf_features(hf_features, tfds_features):
113113
@pytest.fixture(name='mock_list_datasets')
114114
def _list_datasets(monkeypatch):
115115
def mock_list_datasets():
116-
return ['mnist', 'bigscience/P3', 'x', 'x/Y-z', 'fashion_mnist']
116+
return [
117+
huggingface_hub.DatasetInfo(id=name)
118+
for name in ('mnist', 'bigscience/P3', 'x', 'x/Y-z', 'fashion_mnist')
119+
]
117120

118121
monkeypatch.setattr(huggingface_hub, 'list_datasets', mock_list_datasets)
119122

0 commit comments

Comments
 (0)