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: push_to_huggingface parsing of UUIDs #3231

Merged

Conversation

alvarobartt
Copy link
Member

Description

Due to the recent constraint for the FeedbackRecord.user_ids to be UUIDs instead of strs, the conversion to dict() was failing, as the UUIDs are not JSON-serializable, which was leading to some issues when trying to add the example record to the DatasetCard via the dict() conversion.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested

  • Re-run unit tests to pass when generating the DatasetCard for FeedbackDatasets

Checklist

  • I have merged the original branch into my forked branch
  • I added relevant documentation
  • follows the style guidelines of this project
  • I did a self-review of my code
  • I made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added relevant notes to the CHANGELOG.md file (See https://keepachangelog.com/)

Due to the recent addition of the UUID values for the `FeedbackRecord.user_id`, with `dict` the `UUID` type is kept, so we need to convert it to `JSON` as `UUID` is not json-serializable
Copy link
Member

@gabrielmbmb gabrielmbmb left a comment

Choose a reason for hiding this comment

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

Hey Alvaro, LGTM for now :) maybe we could think to add a custom type like StrUUID https://docs.pydantic.dev/latest/usage/types/#classes-with-__get_validators__, so when calling .dict() we get an str instead of a UUID.

Using json.loads(model.json()) makes the trick, but it's a bit inefficient as we're serializing/deserializing the whole model.

@gabrielmbmb gabrielmbmb merged commit b68278d into fix/format-as-datasets-no-responses Jun 20, 2023
@gabrielmbmb gabrielmbmb deleted the fix/push-to-huggingface-uuid branch June 20, 2023 10:14
@alvarobartt
Copy link
Member Author

Hey Alvaro, LGTM for now :) maybe we could think to add a custom type like StrUUID https://docs.pydantic.dev/latest/usage/types/#classes-with-__get_validators__, so when calling .dict() we get an str instead of a UUID.

Using json.loads(model.json()) makes the trick, but it's a bit inefficient as we're serializing/deserializing the whole model.

Yes, I agree with this, I'll tackle next release, this was a patch proposed by @frascuchon but since it's just the UUIDs and the datetimes, and we're not pushing datetimes the solution above or a custom encoder would do the work! Thanks

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.

2 participants