-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: make sure data is json serializable #4269
Conversation
- Moved the `recursive_serialize_or_str` function from `schema.py` to a new `serialize.py` module for better modularity and reusability. - Updated imports in `data.py`, `artifact.py`, and `schema.py` to reflect the new location of the `recursive_serialize_or_str` function. - Enhanced the `recursive_serialize_or_str` function to handle `datetime` objects by converting them to ISO format.
This looks good. Should we also update the DateTime objects in message.py ? The current update may not cause issues, but should the datetime in the message also be converted to ISO format? |
Tested this PR with the error that I had in PR #4258 (By merging both changes in a new branch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return str(obj) | ||
except Exception: # noqa: BLE001 | ||
logger.debug(f"Cannot serialize object {obj}") | ||
return str(obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious the downstream effects of this. Is this currently used for serializing an object for caching?
This pull request includes two commits. The first commit enhances the data serialization process by adding recursive handling in the
to_json
method. This allows for better handling ofdatetime
objects by converting them to ISO format. The second commit refactors therecursive_serialize_or_str
function into a separate module calledserialize.py
. This improves modularity and reusability of the code. The function is moved fromschema.py
to the new module, and the imports indata.py
,artifact.py
, andschema.py
are updated accordingly.