Iāve attempted to implement a JSON serialization format, but Iām facing some difficulties when trying to serialize the Relay Prelude and get it back. Iām not sure what might be going on, but the main point of the matter is that preserving reference equality where Relay expects it is fairly tricky, so it would take a fair bit of validation to make sure that this serialization is correct. (Iām still not completely sure of what is going wrong here, incidentally.) The implementation was also fairly large (~700 lines), though much of that was boilerplate. Fixed, see below editsā¦ Iāll post the serializer when I have tests ready and we can decide if thatās preferable to pickle
.
If we are very intent on having this JSON format rather than pickle
, would anyone be interested in discussing how it should be implemented or trying to figure out what issues are arising with the Relay Prelude?
Edit: @driazati, do you think we might be able to cryptographically sign off on our Pickle files somehow to ensure potentially malicious ones canāt be inserted? Iād be willing to explore other options related to pickle
, as itās seeming like developing another serializer will be a nontrivial task.
Edit 2: I got a new idea for a simpler approach to JSON serialization (just cache all types and exprs by their pointer value and use that to determine reference equality) and Iāll see if that works instead.
Edit 3: The simpler approach is still encountering the same odd problem when trying to serialize the Prelude. I have no clue why this shouldnāt work, since it is tracking reference equality for every part of the AST. Happy to provide code for debugging this, but itās strange and makes me think the pickle
option is the better one
Edit 4: I think I may have found the issue. It turns out the contents of attrs
could be arbitrary TVM objectsā¦