Skip to content
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

DM-40303: Fix pydantic v2 warnings #874

Merged
merged 16 commits into from
Aug 5, 2023
Merged

DM-40303: Fix pydantic v2 warnings #874

merged 16 commits into from
Aug 5, 2023

Conversation

timj
Copy link
Member

@timj timj commented Aug 4, 2023

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Patch coverage: 66.24% and project coverage change: -0.10% ⚠️

Comparison is base (fc214b3) 87.82% compared to head (247b81f) 87.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #874      +/-   ##
==========================================
- Coverage   87.82%   87.72%   -0.10%     
==========================================
  Files         274      274              
  Lines       36052    36096      +44     
  Branches     7543     7549       +6     
==========================================
+ Hits        31662    31665       +3     
- Misses       3223     3259      +36     
- Partials     1167     1172       +5     
Files Changed Coverage Δ
python/lsst/daf/butler/registries/remote.py 80.40% <ø> (ø)
python/lsst/daf/butler/script/queryDatasets.py 89.55% <ø> (ø)
tests/test_cliCmdAssociate.py 100.00% <ø> (ø)
tests/test_cliCmdConfigDump.py 99.11% <0.00%> (ø)
tests/test_cliCmdConfigValidate.py 96.77% <0.00%> (ø)
python/lsst/daf/butler/_compat.py 29.41% <23.07%> (-4.52%) ⬇️
python/lsst/daf/butler/core/datasets/ref.py 80.09% <37.50%> (-3.56%) ⬇️
python/lsst/daf/butler/core/serverModels.py 73.60% <45.00%> (-5.35%) ⬇️
python/lsst/daf/butler/registry/obscore/_config.py 91.11% <55.55%> (-8.89%) ⬇️
python/lsst/daf/butler/core/dimensions/_records.py 83.85% <60.00%> (+0.20%) ⬆️
... and 31 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timj timj force-pushed the tickets/DM-40303 branch 3 times, most recently from e258571 to 87a62cb Compare August 4, 2023 16:24
@timj timj marked this pull request as ready for review August 4, 2023 17:40
Copy link
Contributor

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a couple of minor comments.

python/lsst/daf/butler/core/datasets/ref.py Outdated Show resolved Hide resolved
@@ -1064,7 +1064,7 @@ def transfer_from(
# ask the receiving datastore to copy it when it doesn't exist
# so we have to filter again based on what the source datastore
# understands.
known_to_source = source_child.knows_these([ref for ref in refs])
known_to_source = source_child.knows_these(list(refs))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure you need list here, knows_these says it takes Iterable, and refs is Iterable here too. I think this code already assumes that you can iterate many times over refs, which is probably not true for Iterable in general.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was forcing it to a list originally so that we could go through it multiple times, which probably means the annotation is wrong. Should it be Sequence?

Copy link
Contributor

@andy-slac andy-slac Aug 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can keep Iterable but then make sure that code can handle single-pass iterables. This code in chainedDatastore cannot, it calls set(refs) few lines above. fileDatastore also doing similar thing in knows_these. Or alternatively we should use Sequence everywhere.

python/lsst/daf/butler/formatters/file.py Outdated Show resolved Hide resolved
Now use a single model validator that checks everything because
we are checking multiple keys.
Only v2 models and v1 models with the compatibility class
support model_dump_json().
The pydantic models that use the v1 compatibility class work
fine with model_validate but there are some v1 models that do
not inherit from that and also some classes like ScarletModelData
that emulate the pydantic v1 methods but are not using pydantic.

Therefore we need to still check parse_obj.
@timj timj merged commit 42f2c38 into main Aug 5, 2023
14 of 16 checks passed
@timj timj deleted the tickets/DM-40303 branch August 5, 2023 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants