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] Fix unpickling domains: do not pickle indices (which can cause problems) #6317

Merged
merged 5 commits into from
Jan 27, 2023

Conversation

markotoplak
Copy link
Member

@markotoplak markotoplak commented Jan 26, 2023

Issue

Fixes #6206, where the domain could not be unpickled if data included something based on SharedComputeValue (that redefined __hash__) and was further preprocessed before learning (thus only scikit-based learners failed but TreeLearner did not).

Unpickling dictionaries that include objects that redefine __hash__ as keys is sometimes problematic (when said objects do not have __dict__ filled-in yet in but are used as keys in a restored dictionary).

See the following for a problem description. https://petrounias.org/articles/2014/09/16/pickling-python-collections-with-non-built-in-type-keys-and-cycles/

Description of changes

Orange's Domain includes _indices for name-based or var-based indexing. That is a dictionary with Variables as keys, and these can cause problems during unpickling. Because _indices can be recreated, I decided not to pickle it and therefore managed to avoid this specific problem.

This will makes new pickled domain incompatible with older Orange versions.

Includes
  • Code changes
  • Tests
  • Documentation

@markotoplak markotoplak changed the title [FIX] Fix unpickling domains in some cases [FIX] Fix unpickling domains: do not pickle indices that can cause problems Jan 26, 2023
@markotoplak
Copy link
Member Author

To see the problems, just run the new test_all_models_work_after_unpickling_pca without the actual fix.

@markotoplak markotoplak changed the title [FIX] Fix unpickling domains: do not pickle indices that can cause problems [FIX] Fix unpickling domains: do not pickle indices (which can cause problems) Jan 26, 2023
Unpickling dictionaries that include objects that redefine __hash__
as keys is sometimes problematic (when said objects do not have __dict__
filled-in yet in but are used as  keys in a restored dictionary).
@codecov
Copy link

codecov bot commented Jan 26, 2023

Codecov Report

Merging #6317 (ccaacb7) into master (a25a9d2) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6317   +/-   ##
=======================================
  Coverage   87.48%   87.48%           
=======================================
  Files         316      316           
  Lines       67968    67986   +18     
=======================================
+ Hits        59459    59478   +19     
+ Misses       8509     8508    -1     

@janezd janezd self-assigned this Jan 27, 2023
The previous skipping did not work.
@markotoplak
Copy link
Member Author

@janezd, falling -latest tests are independent of this PR.

@janezd
Copy link
Contributor

janezd commented Jan 27, 2023

@janezd, falling -latest tests are independent of this PR.

Ah, you've seen nothing yet. Wait for lazy signals!

@janezd
Copy link
Contributor

janezd commented Jan 27, 2023

@janezd, falling -latest tests are independent of this PR.

Should be fixed in #6320.

@janezd janezd merged commit 3d8ae07 into biolab:master Jan 27, 2023
@janezd
Copy link
Contributor

janezd commented Jan 27, 2023

Fixes #6202

You meant #6206, right?

@markotoplak markotoplak deleted the fix-unpickling-domains branch March 21, 2023 15:52
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.

exception with Load Model widget
2 participants