Fix UnpicklingError for qlib contrib handlers (Alpha158)#2143
Open
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix UnpicklingError for qlib contrib handlers (Alpha158)#2143universeplayer wants to merge 1 commit intomicrosoft:mainfrom
universeplayer wants to merge 1 commit intomicrosoft:mainfrom
Conversation
…lization The RestrictedUnpickler introduced in microsoft#2099 whitelisted only a few specific qlib classes (DataHandler, DataHandlerLP, StaticDataLoader) but missed many others such as Alpha158, Alpha360, and various contrib handlers/models. This caused UnpicklingError during rolling train when task definitions containing these class references were deserialized from MongoDB. Instead of maintaining an ever-growing list of individual qlib classes, add "qlib" as a trusted module prefix alongside "pandas" and "numpy". All qlib internal classes are safe to deserialize within qlib's own restricted unpickler since they are part of the framework itself. The three individual qlib entries in SAFE_PICKLE_CLASSES are removed as they are now redundant. Fixes microsoft#2130 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root Cause
PR #2099 introduced RestrictedUnpickler but only whitelisted three specific qlib classes. Many contrib classes like Alpha158, Alpha360, etc. were missing, causing UnpicklingError during rolling train.
Fix
Add qlib to TRUSTED_MODULE_PREFIXES (alongside pandas and numpy). This ensures all qlib internal classes are trusted for deserialization while still blocking arbitrary external classes.
Test plan
Fixes #2130