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 bug in AutoSlots deepcopy #3412

Merged
merged 7 commits into from
Nov 12, 2024
Merged

Conversation

jsiirola
Copy link
Member

Fixes # .

Summary/Motivation:

This resolves an issue where AutoSlots was recording the temporary dict used to hold the class __dict__ in the memo (and then threw away the temporary dict). This was causing the deepcopy to corrupt the model in certain situations (IDAES models - but only on Windows with certain environments).

The fix is to remove the temporary dict from the memo.

This PR also updates the ConfigBase / ConfigDict __getstate__/__setstate__ to avoid creating temporary tuples.

Changes proposed in this PR:

  • Do not record the temporary __dict__ dict in the deepcopy memo
  • Do not create temporary tuples when serializing ConfigBase / ConfigDict objects

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

pyomo/common/autoslots.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.66%. Comparing base (364e7f1) to head (e7bf41c).
Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3412   +/-   ##
=======================================
  Coverage   88.66%   88.66%           
=======================================
  Files         879      879           
  Lines      100374   100381    +7     
=======================================
+ Hits        88999    89007    +8     
+ Misses      11375    11374    -1     
Flag Coverage Δ
linux 86.12% <100.00%> (+<0.01%) ⬆️
osx 76.11% <100.00%> (+<0.01%) ⬆️
other 86.61% <100.00%> (+<0.01%) ⬆️
win 84.46% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mrmundt mrmundt merged commit af99289 into Pyomo:main Nov 12, 2024
33 checks passed
@jsiirola jsiirola deleted the autoslots-deepcopy-fix branch November 15, 2024 03:21
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.

3 participants