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: make sure data is json serializable #4269

Merged
merged 3 commits into from
Oct 24, 2024

Conversation

ogabrielluiz
Copy link
Contributor

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 of datetime objects by converting them to ISO format. The second commit refactors the recursive_serialize_or_str function into a separate module called serialize.py. This improves modularity and reusability of the code. The function is moved from schema.py to the new module, and the imports in data.py, artifact.py, and schema.py are updated accordingly.

- 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.
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Oct 24, 2024
@github-actions github-actions bot added bug Something isn't working and removed enhancement New feature or request labels Oct 24, 2024
@edwinjosechittilappilly
Copy link
Collaborator

edwinjosechittilappilly commented Oct 24, 2024

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?
@ogabrielluiz

@edwinjosechittilappilly
Copy link
Collaborator

Screenshot 2024-10-24 at 12 13 37 PM

Tested this PR with the error that I had in PR #4258 (By merging both changes in a new branch)
Still causes the issue.

@edwinjosechittilappilly
Copy link
Collaborator

Screenshot 2024-10-24 at 12 13 37 PM Tested this PR with the error that I had in PR #4258 (By merging both changes in a new branch) Still causes the issue.

made changes in branch #4258 Those errors were from the function change in _process_connection_or_parameters

Ignore the above comment.

Copy link
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly left a comment

Choose a reason for hiding this comment

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

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 24, 2024
@edwinjosechittilappilly edwinjosechittilappilly merged commit 5be41ae into main Oct 24, 2024
28 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the fix-serialization branch October 24, 2024 16:47
return str(obj)
except Exception: # noqa: BLE001
logger.debug(f"Cannot serialize object {obj}")
return str(obj)
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants