Update snapshot.py to work with MemoryViz 0.9.0 schema#1345
Open
a1-su wants to merge 1 commit into
Open
Conversation
Collaborator
Coverage Report for CI Build 26432811267Coverage decreased (-0.3%) to 90.533%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions4 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
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.
Proposed Changes
This PR updates the
snapshot_to_jsonfunction in thesnapshot.pyfile to handle the changes to the MemoryViz expected JSON input in the 0.9.0 update. More specifically, only two updates needed to be made:.frame/FrameDrawnEntitySchematypes no longer have anidattribute, so that was removed.class/ClassDrawnEntitySchematypes only allow records for thevaluefield, and since we previously were using the.classto represent a Python type, such asint,str, ordict, theirreprcan no longer be used as the valuenameof the entity is thetype(ex.int,str, ordict), while thevalueattribute is left blankScreenshots of your changes (if applicable)
Sample Setup
Old MemoryViz (0.7.0) SVG
Converted JSON Payload
[ { "type": ".frame", "name": "__main__", "id": null, "value": { "number_var": 1, "type_var": 2 } }, { "type": "int", "id": 1, "value": 67 }, { "type": ".class", "name": "class", "id": 2, "value": "<class 'int'>" } ]Updated MemoryViz (0.9.0) SVG
Converted JSON Payload
[ { "type": ".frame", "name": "__main__", "value": { "number_var": 1, "type_var": 2 } }, { "type": "int", "id": 1, "value": 67 }, { "type": ".class", "name": "int", "id": 2, "value": {} } ]Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)
Note that because the stricter limitation on the MemoryViz Typescript schema in
types.ts, we can no longer put just the "name" of a type, such asint,str, ordict(nor the stringclass <'int'>, for example) in thevalueattribute of the.class/ClassDrawnEntitySchemadrawn entityFrom: https://github.com/david-yz-liu/memory-viz/blob/158bd6db990a6a1bc7d87104e819de0a810bee3b/memory-viz/src/types.ts#L112-L122
nameattribute (top-right box of the drawn entity) instead, although this does leave thevalueattribute empty, and thus the corresponding box to be empty (see screenshots for more details)typesshould be kept under the.class/ClassDrawnEntitySchemaentity in MemoryViz, since in Python, types are classes; if we wanted to put something in thevaluepart of the box, we'd have to set it as something like astring/StringDrawnEntitySchemaentity, which could be confusing to users since types are not stringsstringentity instead,strwould confusingly be written in the top-right box and code likex = intandx = "int"would be hard to distinguishI think the coverage is decreasing because the previous
invalid_name_checker.pyupdates, so they should be unrelated to this PR (although I'm not sure why, if there were coverage issues, Coveralls didn't flag the original PR with the changes in the first place)