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

Do not remove None values in RepoCardData serialization #2626

Merged
merged 2 commits into from
Oct 22, 2024

Conversation

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Oct 22, 2024

More details in huggingface/datasets#7243 (comment) and especially huggingface/datasets#7243 (comment).

When serializing repo cards metadata, we are currently removing any none values from any dictionary, set, list or tuple. This is done since the module has been introduced in #940 and never caused problems until huggingface/datasets#7243 was reported. I do find automatically removing None values inside values to be pretty clunky as it is values set by the user and not default ones.

This PR updates this behavior to remove only top-level None values, i.e. values that are None by default and that therefore shouldn't be serialized (as not set by the users themselves). The _remove_none helper is still kept to remove None values from the model-index (where it's rightfully necessary), but that's all.

⚠️ this is a breaking change. In practice, I don't expect it to break anything in the wild.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

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

LGTM! ruff formatting tests/test_repocard_data.py + the fixes made in #2621 should make the CI green ✅

@Wauplin
Copy link
Contributor Author

Wauplin commented Oct 22, 2024

Thanks for the quick reviews :)

@Wauplin Wauplin merged commit 40a64c8 into main Oct 22, 2024
18 checks passed
@Wauplin Wauplin deleted the do-not-remove-none-values-in-repocard-serizalization branch October 22, 2024 14:42
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.

change makes sense to me 👍

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.

5 participants