fix: cache filtered instruments during grouped loads#2237
Open
he-yufeng wants to merge 1 commit into
Open
Conversation
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.
Description
QlibDataLoader.load()now resolvesfilter_pipeonce before grouped field loading starts, then reuses the filtered instruments for each field group. Directload_group_df()calls keep the old behavior by resolving instruments at that entry point.A regression test covers grouped loading with two field groups and verifies that
D.instruments(..., filter_pipe=...)is called once whileD.features(...)is still called per group.Motivation and Context
Fixes #2236.
The previous grouped path delegated every group to
load_group_df()with the original market name, so each group re-ran the same dynamic instrument filter pipeline. With multiplefields_groups, that multiplies filter work even though the filtered instrument set is identical for the load request.How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.Targeted checks run locally:
python -m py_compile qlib\data\dataset\loader.py tests\data_mid_layer_tests\test_dataloader.pygit diff --checkD.instrumentscall plus two groupedD.featurescallsI also attempted the targeted pytest:
python -m pytest tests\data_mid_layer_tests\test_dataloader.py::TestDataLoader::test_group_loader_applies_filter_pipe_once -qThat is blocked in my Windows checkout before test collection because the local Cython extension is not built:
Building the extension with
python setup.py build_ext --inplacealso fails locally because this Windows environment cannot find the Windows SDKio.hheader while compilingrolling.cpp.Screenshots of Test Results (if appropriate):
Types of changes