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

fix: ReferenceMixin._ref weakrefs after deep copy #272

Merged
merged 13 commits into from
Jan 3, 2025
Merged

fix: ReferenceMixin._ref weakrefs after deep copy #272

merged 13 commits into from
Jan 3, 2025

Conversation

tlambert03
Copy link
Owner

fixes #265

@tlambert03 tlambert03 changed the title fix ReferenceMixin._ref weakrefs after deep copy fix: ReferenceMixin._ref weakrefs after deep copy Jan 2, 2025
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.95%. Comparing base (a17bf57) to head (40b7b6c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #272      +/-   ##
==========================================
+ Coverage   86.85%   86.95%   +0.10%     
==========================================
  Files          25       25              
  Lines        1263     1273      +10     
==========================================
+ Hits         1097     1107      +10     
  Misses        166      166              

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

Copy link

codspeed-hq bot commented Jan 2, 2025

CodSpeed Performance Report

Merging #272 will not alter performance

Comparing fix-265 (40b7b6c) with main (a17bf57)

Summary

✅ 9 untouched benchmarks

@tlambert03
Copy link
Owner Author

tlambert03 commented Jan 2, 2025

@erickmartins, heads up: this PR is going to break omero-cli-transfer. specifically it looks like you were "locally fixing" this bug in omero-cli-transfer by calling newplate.annotation_refs.remove(annref) in create_plate_map here: https://github.com/ome/omero-cli-transfer/blob/360b535ec2a5d301388417d8bc84b8788250c1e2/src/generate_omero_objects.py#L339

unfortunately, using .remove() essentially requires that the reference is present in the list... it never should have been in the first place, and now that we also found this issue, we're fixing it here.

you can see how our test of omero-cli-transfer is now failing here:
https://github.com/tlambert03/ome-types/actions/runs/12576599869/job/35052927242?pr=272

I'm afraid you'll have to either do some ome-types version specific logic now, use a try/catch, or check for the presence of that reference before trying to remove it.

@erickmartins
Copy link

Appreciate the heads up! I'm about to go on vacation and might not have time to dig into this before then, but will do as soon as I'm back.

@tlambert03
Copy link
Owner Author

tlambert03 commented Jan 3, 2025

ok, this is working now, but only for pydantic v2. I actually think that deepcopy with pydantic v1 may have had some subtle untested broken issues with already, that this is exposing. I'm skipping that test for now, and will probably just drop support for pydantic v1 altogether in another PR. it's been out for 1.5 years, plenty of time for libraries to update just enough to use the pydantic.v1 import if they want

@tlambert03 tlambert03 merged commit ae694b6 into main Jan 3, 2025
39 checks passed
@tlambert03 tlambert03 deleted the fix-265 branch January 3, 2025 14:31
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.

model_copy doesn't reset ReferenceMixin._ref weakrefs
2 participants