aind-data-schema icon indicating copy to clipboard operation
aind-data-schema copied to clipboard

Consider changing the default deserialization `extra` mode to `allow`

Open bruno-f-cruz opened this issue 5 months ago • 1 comments

Is your feature request related to a problem? Please describe. This is something that we have informally discussed before but I keep bumping into it, so might as well have an issue for reference.

The current deserialization mode of the base class AindModel forbids extra fields. This behavior makes it really hard to inherit and modify base classes by composition and deserializing back to the base class.

https://github.com/AllenNeuralDynamics/aind-data-schema/blob/a9655585ef37cdff2eb11ebc752ed78866b08164/src/aind_data_schema/base.py#L49

This behavior can be super useful when downcasting / upcasting. For example: https://github.com/AllenNeuralDynamics/aind-metadata-mapper/issues/151

and prevents lossy data ingestion:

https://github.com/AllenNeuralDynamics/aind-data-schema/issues/788#issuecomment-2156662579

Describe the solution you'd like Change the extra mode to allow

Describe alternatives you've considered Change the extra mode to ignore. It wouldn't allow for lossless up/downcasting but at least wouldn't throw errors

Additional context Either of these solutions would remove the automatic validation of properties at runtime. This may be important to get rid of typos.

bruno-f-cruz avatar Sep 25 '24 15:09 bruno-f-cruz