Repository navigation
fix(memory): make ActionStep.dict() JSON-serializable when observations_images is present - #2732
Closed
teddiesloco wants to merge 1 commit into
Closed
teddiesloco wants to merge 1 commit into
teddiesloco wants to merge 1 commit into
Conversation
Closes huggingface#2725 by replacing raw non-serializable bytes with base64 PNG strings so ActionStep.dict() remains JSON-serializable.
Member
|
Thank you for this pull request. Under our contribution guidelines, a pull request needs to link an issue that a maintainer has assigned to its author before we review it. Assignment is how we decide what gets worked on and by whom, and it keeps the review queue at a size we can actually handle. This PR links #2725, which is not assigned to you, so I am closing the PR for now. If we decide we want this change and assign it to you, comment here and we will reopen this PR as it is: please do not open a new one. Closing it is not a judgement on the code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Resolves #2725.
Currently,
ActionStep.dict()convertsself.observations_imagesusingimage.tobytes(), returning raw Pythonbytesobjects. This causesjson.dumps(step.dict())to raiseTypeError: Object of type bytes is not JSON serializable.This PR:
encode_image_base64(image)soobservations_imagesis serialized to base64 strings, matching the serialization format elsewhere in the library.test_action_step_dictintests/test_memory.pyto verify thatjson.dumps(action_step_dict)succeeds.Testing
pytest tests/test_memory.py- 12 passed.