Skip to content

Fix pydantic validate and pickle for tagged union #207

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

Merged
merged 11 commits into from
Aug 19, 2024

Conversation

denghz
Copy link
Contributor

@denghz denghz commented Jun 19, 2024

#206 pydantic validate issue

#208 pickle issue

@denghz denghz changed the title Fix pydantic validate for Option and pickle for tagged union Fix pydantic validate and pickle for tagged union Jun 19, 2024
@denghz
Copy link
Contributor Author

denghz commented Aug 13, 2024

@dbrattli I wanted to check in this PR. Could you let me know when it can be merged? If there are any concerns or further testing needed, please let me know.

@@ -38,13 +38,23 @@ def tagged_union(
items will be compared as the tuple (index, value)
eq: If True, the __eq__ method will be generated.
"""
# Performance can be improved if it is a issue in another day
Copy link
Owner

Choose a reason for hiding this comment

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

What do you mean by this comment? Assigning two methods are not a performance issue. Is it the all of the transform function you are talking about? Please explain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean the __getstate__ and __setstate__ function. Sorry for putting it at wrong place.
These could be slightly more performant if we generated the code instead of iterating over fields dynamically, which is the approach I am using in my other projects

Suggested change
# Performance can be improved if it is a issue in another day

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it is actually not really a performance issue here and the comment can be removed.

Copy link
Owner

Choose a reason for hiding this comment

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

@denghz Can we remove this line from the PR? I'm unsure why you added it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@dbrattli
Copy link
Owner

@denghz Sorry for the delay. I've been busy lately. Let's work together to get this merged.

@dbrattli
Copy link
Owner

FYI: I'm ready to merge this when conflicts are resolved, and we have removed that new comment in tagged_union.py.

@denghz
Copy link
Contributor Author

denghz commented Aug 17, 2024

Thanks I will do it today. Also I am fixing another bug about model_dump_json and will try to finish it this weekend.

@@ -38,13 +38,23 @@ def tagged_union(
items will be compared as the tuple (index, value)
eq: If True, the __eq__ method will be generated.
"""
# Performance can be improved if it is a issue in another day
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean the __getstate__ and __setstate__ function. Sorry for putting it at wrong place.
These could be slightly more performant if we generated the code instead of iterating over fields dynamically, which is the approach I am using in my other projects

Suggested change
# Performance can be improved if it is a issue in another day

@@ -38,13 +38,23 @@ def tagged_union(
items will be compared as the tuple (index, value)
eq: If True, the __eq__ method will be generated.
"""
# Performance can be improved if it is a issue in another day
Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it is actually not really a performance issue here and the comment can be removed.

@@ -38,13 +38,23 @@ def tagged_union(
items will be compared as the tuple (index, value)
eq: If True, the __eq__ method will be generated.
"""
# Performance can be improved if it is a issue in another day
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@denghz
Copy link
Contributor Author

denghz commented Aug 18, 2024

FYI: I'm ready to merge this when conflicts are resolved, and we have removed that new comment in tagged_union.py.

I have removed the comment

Copy link
Owner

@dbrattli dbrattli left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@dbrattli dbrattli merged commit 7a92a9d into dbrattli:main Aug 19, 2024
3 checks passed
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.

3 participants