-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix serialization and caching (#298)
Due to continuing serialization problems that were thought to be related with caching, #277 deactivated core test caching and #294 was prepared to do the same for the full test environment. This PR reactivates caching and instead refactors the class layout of `SKLearnClusteringRecommender` in an attempt to fix the root cause. Mysteriously, the top-level import of `sklearn.mixture.GaussianMixture` seems to cause trouble. While the reason is still unclear, turning it into a lazy import (which will also become handy later when making `scikit-learn` an optional dependency) seems to resolve the problem. On a side note: deactivating slots for the recommenders solves the problem as well, which suggests that the root cause could be related to classes not being properly garbage collected (since `attrs` needs to create new classes when slots are activated), which could also explain that `GaussianMixtureClusteringRecommender` seemed to have improperly overridden methods after deserialization (for example, the `__repr__` of a created Gaussian mixture recommender correctly pointed to its own class before serialization but to the `__repr__` of `SKLearnClusteringRecommender` after serialization – but weirdly only when executed in `tox`).
- Loading branch information
Showing
4 changed files
with
41 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters