Skip to content

Commit

Permalink
Don't override the language if it's already set
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaarsen committed Oct 31, 2023
1 parent a33934a commit 91bda14
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Types of changes
* "Security" in case of vulnerabilities.
-->

## [Unreleased]

### Fixed

- No longer override `language` metadata from the dataset if the language was also set manually via `SpanMarkerModelCardData`.

## [1.4.0]

### Added
Expand Down
17 changes: 9 additions & 8 deletions span_marker/model_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,15 @@ def __post_init__(self):
# We don't want to save "ignore_metadata_errors" in our Model Card
if self.dataset_id:
if is_on_huggingface(self.dataset_id, is_model=False):
# if languages are not set, try to determine the language from the dataset on the Hub
try:
info = dataset_info(self.dataset_id)
except:
pass
else:
if info.cardData:
self.language = info.cardData.get("language", self.language)
if self.language is None:
# if languages are not set, try to determine the language from the dataset on the Hub
try:
info = dataset_info(self.dataset_id)
except:
pass
else:
if info.cardData:
self.language = info.cardData.get("language", self.language)
else:
logger.warning(
f"The provided {self.dataset_id!r} dataset could not be found on the Hugging Face Hub."
Expand Down

0 comments on commit 91bda14

Please sign in to comment.