p2p-ld / nwb-linkml

Translating NWB schema language to linkml
https://nwb-linkml.readthedocs.io
GNU General Public License v3.0
4 stars 1 forks source link

recursion error on json dumping #15

Open sneakers-the-rat opened 1 month ago

sneakers-the-rat commented 1 month ago

Think we're gonna have to serialize each of the items independently and stitch them together.

Pydantic doesn't like models that reference each other, even when they have json serializations that handle that - the mere presence of a repeated object ID causes the json serialization to choke in a way that can be sometimes rescued by a model_serializer(mode="wrap") but other times doing so causes the next dump attempt to fail.

Some of these are actually cyclical recursion errors, some of them (like object ID columns, which never reference other objects) are getting independent cyclical errors (not the errors of the parent class which may have already been seen, an additional error) may be related to: https://github.com/pydantic/pydantic/issues/9670

We could just.... load objects twice. there isn't really a reason to only load a single object except that it simplifies writing if eg. incompatible edits are made to the attributes of the referenced object (the array should be fine, since it refers tot he same underlying hdf5 dataset)

sneakers-the-rat commented 1 month ago

ex here https://github.com/p2p-ld/nwb-linkml/tree/numpydantic-dump