11import json
22import logging
33import re
4+ import warnings
45from collections import Counter
56from dataclasses import dataclass , fields
67from pathlib import Path
@@ -219,9 +220,7 @@ class DatasetMetadata:
219220 annotations_creators : List [str ]
220221 language_creators : Union [EmptyList , List [str ]]
221222 language : Union [EmptyList , List [str ]]
222- languages : Union [EmptyList , List [str ]] # deprecated
223223 license : List [str ]
224- licenses : List [str ] # deprecated
225224 multilinguality : List [str ]
226225 pretty_name : str
227226 size_categories : List [str ]
@@ -233,10 +232,19 @@ class DatasetMetadata:
233232 configs : Optional [List [str ]] = None
234233 extra_gated_fields : Optional [Dict ] = None
235234 extra_gated_prompt : Optional [str ] = None
235+ licenses : Optional [Union [EmptyList , List [str ]]] = None # deprecated
236+ languages : Optional [Union [EmptyList , List [str ]]] = None # deprecated
236237
237238 # class attributes
238239 _FIELDS_WITH_DASHES : ClassVar [set ] = {"train_eval_index" } # train-eval-index in the YAML metadata
239240 _ALLOWED_YAML_KEYS : ClassVar [set ] = set () # populated later
241+ _DEPRECATED_YAML_KEYS = ["licenses" , "languages" ]
242+
243+ def __post_init__ (self ):
244+ if self .licenses is not None :
245+ warnings .warning ("The 'licenses' YAML field is deprecated, please use 'license' instead." )
246+ if self .languages is not None :
247+ warnings .warning ("The 'languages' YAML field is deprecated, please use 'language' instead." )
240248
241249 def validate (self ):
242250 validate_metadata_type (metadata_dict = vars (self ))
@@ -272,9 +280,9 @@ def validate(self):
272280 }
273281
274282 exception_msg_dict = dict ()
275- for field , errs in errors .items ():
283+ for yaml_field , errs in errors .items ():
276284 if errs is not None :
277- exception_msg_dict [field ] = errs
285+ exception_msg_dict [yaml_field ] = errs
278286 if len (exception_msg_dict ) > 0 :
279287 raise TypeError (
280288 "Could not validate the metadata, found the following errors:\n "
0 commit comments