-
Notifications
You must be signed in to change notification settings - Fork 55
Pydantic v2 #2433
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
base: develop
Are you sure you want to change the base?
Pydantic v2 #2433
Conversation
0a529f4
to
a7e7a49
Compare
348a931
to
5ecc9f9
Compare
It seems like fundamentally there's just a few things that change? Maybe I'm missing something important/tricky. Could you explain if there's anything like that, and what changes going forward? Also very important - we will certainly need to update the backend python code too and might need to update denormalizer, metadata api, and who knows what else. |
Yes the biggest changes are related to custom types and serialization, everything else is relatively straightforward. I'll write something up. |
93ce359
to
dd10b26
Compare
dd0cd2b
to
38d502a
Compare
ea3b4cb
to
29234a6
Compare
6d3f88a
to
2967f74
Compare
0a72b9c
to
715c758
Compare
82e8615
to
abaf39d
Compare
This is ready for initial review. |
@@ -24,6 +24,7 @@ | |||
|
|||
# Store an example of every minor release simulation to test updater in the future | |||
SIM_DIR = "tests/sims" | |||
SIM_STATIC = SIM.to_static() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason we test with sim static? might be worth a comment for future reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right yeah it's because i fixed (i think?) the equality check (Tidy3dBaseModel.__eq__
). so when you compare a model with and without tracers, then they will not compare equal. i think this behavior is correct?
basically if we run these tests with SIM
instead of SIM_STATIC
, then we get the following failures:
FAILED tests/test_components/test_IO.py::test_simulation_load_export_hdf5 - AssertionError: original and loaded simulations are not the same
FAILED tests/test_components/test_IO.py::test_simulation_load_export_hdf5_explicit - AssertionError: original and loaded simulations are not the same
FAILED tests/test_components/test_IO.py::test_simulation_load_export - AssertionError: original and loaded from hdf5 simulations are not the same
FAILED tests/test_components/test_IO.py::test_simulation_load_export_hdf5_gz - AssertionError: original and loaded simulations are not the same
FAILED tests/test_components/test_IO.py::test_simulation_load_export_hdf5_gz_explicit - AssertionError: original and loaded simulations are not the same
c4e9567
to
d2c816f
Compare
add somefiles replacing v1 more replacements copy methods and ordering of basemodel update get_submodels_by_hash basemodel done (except for docs) basemodel and modespec done slowly but surely.. progress next batch going going getting started on medium more refactoring new structure for medium.py add medium why it no work fix medium upgrade material library most of it first pass add pydantic-settings fixes to validators, mutable assignment, ...: remove skip_if_fields_missing cleaning up types & type serializaton fix printing and serialization of autograd types more type serialization updates Fix traced ndarray serialization fix equality check in basemodel fix some v1 leftovers fix some tests fix equality check sim_data tests passing make serializer more robust and another fix for equality comparison fix warn if none validators Check for pydantic v2 ValidationErrors Canonicalize coordinate handling of unstructured datasets Simulation data tests passing material library tests passing fix bad name fix material libray -> library lotsa fixes, tests_web & test_package passing fix remaining web test warnings everything importable for doctests rebase, wip fix mutation safer ndarray coercion and expressions fix working on post init validation fix multiphysics medium attribute lookup remove test script from vcs doctests passing fix NedeljkovicSorefMashanovich fix non-component tests fix tracer serialization remove unnecessary to_static call the smallest changes really do take the longest all of test_IO passing fix caching and copy update docstring for __init_subclass__ passing: IO, base, beam, boundaries, custom, eme, field_projection, geometry, log passing: grid, grid_spec, heat, heat_charge, layerrefinement, lumped_element, medium passing: meshgenerate, microwave, mode passing: monitor, packaging, parameter_perturbation, perturbation_medium, scene, sidewall passing: expressions passing: smatrix, array_factor, design, dispersion_fitter, microwave, mode_solver wip: adjoint & invdes passing: source, structure, time_modulation passing: types add helpers to filter model fields add tests for new basemodel helpers small fixes wip: autograd fix waveguide passing: autograd rebase fixes no more post-init validators fix dataarray json schema rework array constraints wip: adjoint ruff chore(github): improve script to determine test scope (#2510) * chore(github): add script to determine whether a PR was already approved This step results in a full test suite run if an already approved PR receives changes to prevent breaking the main branch. * cancel parallel triggers of the remote tests * fix group assignment * add python version to group assignment fix bug when inserting snapping points near sim min boundary fix contains check for lumped element, which was too strict (#2511) fix[web]: use dedicated endpoint for `web.delete_old()` Upgrade ruff 0.5.5 -> 0.11.11 Run `ruff check . --fix` Run `ruff format .` Move test-specifc `ruff.toml` to `per-file-ignores` Sort test imports Import `Literal` from `typing` Force `from __future__ import annotations` import Rewrite `dict()` as literal (2x faster) Disallow function calls in default arguments Be intentional about exception context Upgrade all (compatible) generics to built-in types Sort `__all__` blocks Enable `RUF` ruleset Prefer tuple unpacking over concatenation Forbid implicit optional No explicit string concatenation Remove unnecessary `pass` statements Remove unnecessary parantheses on raised exceptions Disallow relative imports from parent modules Remove unused import aliases Add lint rule comments Revert "Disallow function calls in default arguments" This reverts commit 12a0a6a. Fix some stragglers Updated ruff version in workflow Lint `data/` dirs rebase fixes sentinel pattern for function calls in default arguments rebase fixes
135b262
to
0afc42d
Compare
Code Coverage Summary
Diff against develop
Results for commit: 0afc42d Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Changed Files Coverage
Results for commit: 0afc42d Minimum allowed coverage is ♻️ This comment has been updated with latest results |
No description provided.