tfds-nightly 4.9.9.dev202508260044__py3-none-any.whl → 4.9.9.dev202508270044__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,83 @@ from tensorflow_datasets.core.utils import croissant_utils
33
33
  def test_get_tfds_dataset_name(croissant_name, croissant_url, tfds_name):
34
34
  metadata = mlc.Metadata(name=croissant_name, url=croissant_url)
35
35
  dataset = mlc.Dataset.from_metadata(metadata)
36
- assert croissant_utils.get_tfds_dataset_name(dataset) == tfds_name
36
+ assert (
37
+ croissant_utils.get_tfds_dataset_name(dataset) == tfds_name
38
+ ), f'Expected TFDS name: {tfds_name}'
39
+
40
+
41
+ @pytest.mark.parametrize(
42
+ 'croissant_name,language,expected_name',
43
+ [
44
+ ({'en': 'English Name', 'fr': 'Nom Français'}, None, 'English Name'),
45
+ (
46
+ {'de': 'Deutscher Name', 'fr': 'Nom Français'},
47
+ None,
48
+ 'Deutscher Name',
49
+ ),
50
+ ({'en': 'English Name', 'fr': 'Nom Français'}, 'fr', 'Nom Français'),
51
+ ('Simple Name', None, 'Simple Name'),
52
+ ],
53
+ )
54
+ def test_get_dataset_name(croissant_name, language, expected_name):
55
+ ctx = mlc.Context(conforms_to='http://mlcommons.org/croissant/1.1')
56
+ metadata = mlc.Metadata(name=croissant_name, ctx=ctx, url=None)
57
+ dataset = mlc.Dataset.from_metadata(metadata)
58
+ assert (
59
+ croissant_utils.get_dataset_name(dataset, language=language)
60
+ == expected_name
61
+ )
62
+
63
+
64
+ def test_get_dataset_name_url_precedence():
65
+ ctx = mlc.Context(conforms_to='http://mlcommons.org/croissant/1.1')
66
+ # Test that URL prefix removal works and takes precedence over name.
67
+ metadata = mlc.Metadata(
68
+ name='Should Be Ignored',
69
+ ctx=ctx,
70
+ url='https://huggingface.co/datasets/user/dataset_name',
71
+ )
72
+ dataset = mlc.Dataset.from_metadata(metadata)
73
+ assert croissant_utils.get_dataset_name(dataset) == 'user/dataset_name'
74
+
75
+ # Test that URL precedence also works when the name is a dict.
76
+ metadata_dict_name = mlc.Metadata(
77
+ name={'en': 'Should Be Ignored'},
78
+ ctx=ctx,
79
+ url='https://huggingface.co/datasets/another/other_dataset',
80
+ )
81
+ dataset_dict_name = mlc.Dataset.from_metadata(metadata_dict_name)
82
+ assert (
83
+ croissant_utils.get_dataset_name(dataset_dict_name)
84
+ == 'another/other_dataset'
85
+ )
86
+
87
+ # Test that non-HuggingFace URLs don't cause name to be ignored.
88
+ metadata_other_url = mlc.Metadata(
89
+ name='Not Ignored',
90
+ ctx=ctx,
91
+ url='https://example.com/dataset',
92
+ )
93
+ dataset_other_url = mlc.Dataset.from_metadata(metadata_other_url)
94
+ assert croissant_utils.get_dataset_name(dataset_other_url) == 'Not Ignored'
95
+
96
+
97
+ def test_get_dataset_multilingual_name_with_language_not_found():
98
+ ctx = mlc.Context(conforms_to='http://mlcommons.org/croissant/1.1')
99
+ metadata_lang_not_found = mlc.Metadata(
100
+ name={'en': 'English Name', 'fr': 'Nom Français'}, ctx=ctx, url=None
101
+ )
102
+ dataset_lang_not_found = mlc.Dataset.from_metadata(metadata_lang_not_found)
103
+ with pytest.raises(ValueError, match='Language de not found'):
104
+ croissant_utils.get_dataset_name(dataset_lang_not_found, language='de')
105
+
106
+
107
+ def test_get_dataset_multilingual_name_with_empty_dict():
108
+ ctx = mlc.Context(conforms_to='http://mlcommons.org/croissant/1.1')
109
+ metadata_empty_dict = mlc.Metadata(name={}, ctx=ctx, url=None)
110
+ dataset_empty_dict = mlc.Dataset.from_metadata(metadata_empty_dict)
111
+ with pytest.raises(ValueError, match='Dataset name dictionary is empty'):
112
+ croissant_utils.get_dataset_name(dataset_empty_dict, language=None)
37
113
 
38
114
 
39
115
  @pytest.mark.parametrize(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tfds-nightly
3
- Version: 4.9.9.dev202508260044
3
+ Version: 4.9.9.dev202508270044
4
4
  Summary: tensorflow/datasets is a library of datasets ready to use with TensorFlow.
5
5
  Home-page: https://github.com/tensorflow/datasets
6
6
  Download-URL: https://github.com/tensorflow/datasets/tags
@@ -246,7 +246,7 @@ tensorflow_datasets/core/utils/colormap.csv,sha256=DDayUU9R19cxhcG3fj4cFwhI46W20
246
246
  tensorflow_datasets/core/utils/conversion_utils.py,sha256=V8kFmJu38op7-8ufZvEn0fLOH8FMkjQebQ1NstIMRYo,6747
247
247
  tensorflow_datasets/core/utils/conversion_utils_test.py,sha256=rP_nbzQWzmZc_GXp3Y6TirwIGJqiQbF-JtY3B1tOuN0,5346
248
248
  tensorflow_datasets/core/utils/croissant_utils.py,sha256=9-_j86KKKkfxgg0aAM1zxlqCdkaC-0p9XzdWjSLmOwk,6265
249
- tensorflow_datasets/core/utils/croissant_utils_test.py,sha256=UdkAVYDTPm1L0zmMESScurV_IMA5K3qAKmL_umeMJZI,4497
249
+ tensorflow_datasets/core/utils/croissant_utils_test.py,sha256=ssIEsdd7BwEPFLwktHu_LXrruWHffVJDme44KqFXglw,7407
250
250
  tensorflow_datasets/core/utils/docs.py,sha256=nRE4d8wxYZav8AcT3dkiY0yplAJBx1hygWxkeKj_V7I,1412
251
251
  tensorflow_datasets/core/utils/dtype_utils.py,sha256=LvDe1hbgQem57RiqXjG9U5Roj8-1KkBMmSYTtgctx2U,3246
252
252
  tensorflow_datasets/core/utils/dtype_utils_test.py,sha256=-Qe2fQzDO5sjS36ZL-dY9w0tNrJXokIoSRFEQCv5dQA,3259
@@ -2471,10 +2471,10 @@ tensorflow_datasets/vision_language/wit/wit_test.py,sha256=PXS8DMNW-MDrT2p5oy4Ic
2471
2471
  tensorflow_datasets/vision_language/wit_kaggle/__init__.py,sha256=vGwSGeM8WE4Q-l0-eEE1sBojmk6YT0l1OO60AWa4Q40,719
2472
2472
  tensorflow_datasets/vision_language/wit_kaggle/wit_kaggle.py,sha256=q-vX_FBzIwsFxL4sY9vuyQ3UQD2PLM4yhUR4U6l-qao,16903
2473
2473
  tensorflow_datasets/vision_language/wit_kaggle/wit_kaggle_test.py,sha256=ZymHT1NkmD-pUnh3BmM3_g30c5afsWYnmqDD9dVyDSA,1778
2474
- tfds_nightly-4.9.9.dev202508260044.dist-info/licenses/AUTHORS,sha256=nvBG4WwfgjuOu1oZkuQKw9kg7X6rve679ObS-YDDmXg,309
2475
- tfds_nightly-4.9.9.dev202508260044.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2476
- tfds_nightly-4.9.9.dev202508260044.dist-info/METADATA,sha256=OlIMhl94mKrf1q3B2umMYXvVuSZqZtNXZfwqnqGm3-0,11291
2477
- tfds_nightly-4.9.9.dev202508260044.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2478
- tfds_nightly-4.9.9.dev202508260044.dist-info/entry_points.txt,sha256=eHEL7nF5y1uCY2FgkuYIdE062epJXlAQTSdq89px4p4,73
2479
- tfds_nightly-4.9.9.dev202508260044.dist-info/top_level.txt,sha256=bAevmk9209s_oxVZVlN6hSDIVS423qrMQvmcWSvW4do,20
2480
- tfds_nightly-4.9.9.dev202508260044.dist-info/RECORD,,
2474
+ tfds_nightly-4.9.9.dev202508270044.dist-info/licenses/AUTHORS,sha256=nvBG4WwfgjuOu1oZkuQKw9kg7X6rve679ObS-YDDmXg,309
2475
+ tfds_nightly-4.9.9.dev202508270044.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2476
+ tfds_nightly-4.9.9.dev202508270044.dist-info/METADATA,sha256=tGKucOVOtUXVaj5IMH587tEOr7bsbmyYfwRmsuQYkMU,11291
2477
+ tfds_nightly-4.9.9.dev202508270044.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
2478
+ tfds_nightly-4.9.9.dev202508270044.dist-info/entry_points.txt,sha256=eHEL7nF5y1uCY2FgkuYIdE062epJXlAQTSdq89px4p4,73
2479
+ tfds_nightly-4.9.9.dev202508270044.dist-info/top_level.txt,sha256=bAevmk9209s_oxVZVlN6hSDIVS423qrMQvmcWSvW4do,20
2480
+ tfds_nightly-4.9.9.dev202508270044.dist-info/RECORD,,