From 741c3f78f6f42592ed3cd4a6feebfeb205a62d53 Mon Sep 17 00:00:00 2001 From: booksword Date: Tue, 12 Dec 2023 20:22:32 +0800 Subject: [PATCH] limit cs factors only on linux due to multiprocessing limitation --- README.md | 2 +- qlib/data/data.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21baecf73e..ce2f772f82 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ I will try to merge some non-debateable features/bugfix to the original qlib. Bu # Features | Feature | Description | Status | |--------------------------------|--------------------------------------------------------------------------| -- | -| Cross Sectional Factor | Add cross-sectional factors such as cross-sectional ranking; average etc | Done | +| Cross Sectional Factor | Add cross-sectional factors such as cross-sectional ranking; average etc | Done (Linux only) | | Orthogonalization preprocesser | Add preprocessers to do Schimit and Symetric Orthogonalization | Done | | Support non-adjusted data | Add support for non-adjusted data | Done | | Enhanced plotting I | Use rangebreak to allow Datetime axis in plottings | [Merged](https://github.com/microsoft/qlib/pull/1390) | diff --git a/qlib/data/data.py b/qlib/data/data.py index 09099d1dec..3f6d84dd97 100644 --- a/qlib/data/data.py +++ b/qlib/data/data.py @@ -10,6 +10,7 @@ import bisect import copy import multiprocessing +import platform import queue from collections import deque from typing import List, Optional, Union @@ -662,7 +663,11 @@ def __call__(self): return [self.col_names[this_idx]] + col_names return self.col_names - if len(cs_levels) > 1 and C["joblib_backend"] == "multiprocessing": # pylint: disable=R1702 + if len(cs_levels) > 1: + if C["joblib_backend"] != "multiprocessing": # pylint: disable=R1702 + raise RuntimeError("only multiprocessing backend is supported for cross-section data") + if platform.system() == "Windows": + raise SystemError("Cross-section data not supported due to the limitation of multiprocessing.") get_module_logger("data").info("shared memory created") shared_mgr = multiprocessing.Manager() shared_data_cache = shared_mgr.dict()