Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Catch TypeError when parsing card data from ModelInfo #1821

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Nov 13, 2023

Fix #1817.

The problem was that for models with a corrupted model-index in their data card (i.e. created before we added the check server-side), the error was not caught if a TypeError is raised. We were only ignoring KeyError. This PR fixes this and adds a regression test.

Thanks @ademait for reporting!

Note: this is a regression introduced by #1788. Once this is merged, I'll ship a hot-fix release as it was working correctly in v0.18.0 (since server data was not parsed into a Python object).


EDIT: I also fixed 2 CardData-related tests that were broken due to server-side update.
EDIT 2: also switched from logger.warnings to warning.warn in repocard module for consistency with the rest of the library

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 13, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @Wauplin

@Wauplin
Copy link
Contributor Author

Wauplin commented Nov 13, 2023

Thanks for the review @LysandreJik !

@Wauplin Wauplin merged commit 2dab69f into main Nov 13, 2023
@Wauplin Wauplin deleted the 1817-fix-type-error-when-loading-model-card-data branch November 13, 2023 16:00
Wauplin added a commit that referenced this pull request Nov 13, 2023
* [FIX] Catch TypeError when parsing card data from ModelInfo

* fix tests

* fix test
Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm from a quick glance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: string indices must be integers when iterating over models from list_models
4 participants