Skip to content

Commit

Permalink
Handle missing card data values
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 638959328
  • Loading branch information
tomvdw authored and The TensorFlow Datasets Authors committed May 31, 2024
1 parent 465d709 commit 6bd6e8b
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,14 @@ def _get_license(self) -> str | None:
repo_id, token = self._hf_repo_id, self._hf_hub_token
dataset_info = huggingface_hub.dataset_info(repo_id, token=token)
# Second heuristic: check the card data.
if 'license' in dataset_info.card_data:
return dataset_info.card_data['license']
if dataset_info.card_data:
if card_data_license := dataset_info.card_data.get('license'):
return card_data_license
# Third heuristic: check the tags.
for tag in dataset_info.tags:
if tag.startswith('license:'):
return tag[len('license:') :]
if dataset_info.tags:
for tag in dataset_info.tags:
if tag.startswith('license:'):
return tag.removeprefix('license:')
return None


Expand Down

0 comments on commit 6bd6e8b

Please sign in to comment.