-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix type signatures to be compatible with pydantic 2.9 #1053
Conversation
The final 2 failures I am not sure what is going on as I am not familiar what the tests and what they should be testing for. Perhaps someone can take a look? Some files that I didn't touch are failing linting on my side: |
The bug seems related with using Here's a minimal example that reproduces the problem: from aind_data_schema.core.procedures import ViralMaterial, IontophoresisInjection
viral_material = ViralMaterial.model_construct()
ionto_inj = IontophoresisInjection.model_construct(injection_materials=[viral_material])
ionto_inj.model_dump() |
I'm looking at this now and while I understand what the tests are supposed to do I think you're right the issue might be coming from the use of model_construct all over the place? But fixing that would probably mean instantiating valid objects which seems like a pain as well. I'll look into pulling some valid objects from existing metadata perhaps. |
Yep, as i said before (#1033), relying on model_construct is probably not the best practice to follow, especially when combined with tagged unions. Tagged unions rely on a lot of behind-the-scenes validation that is skipped during model_construct, making their output somewhat brittle. Regardless, the current PR should still be merged since it fixes other flagged bugs. |
Yes but there are still tests failing if I force pydantic to 2.9, so I'm trying to track those down |
Looping @mekhlakapoor and @jtyoung84 here, can you help me understand what this test is doing and why it uses model_construct? Does this actually need to build a full Metadata object just to check whether injection_materials is missing?:
If this is just testing whether injection_materials is missing, can I just replace it with a test that does
Or even simpler just do the The use of |
This reverts commit 2f81eda.
Attempted to close #1050. However, the remaining error is really hard to fix at this point without major refactors to the unittest code base.