diff --git a/qlib/config.py b/qlib/config.py index 4e5d62564f..837efe2fb9 100644 --- a/qlib/config.py +++ b/qlib/config.py @@ -17,12 +17,21 @@ import copy import logging import platform -import multiprocessing from pathlib import Path from typing import Callable, Optional, Union from typing import TYPE_CHECKING -from qlib.constant import REG_CN, REG_US, REG_TW +from qlib.constant import ( + REG_CN, + REG_US, + REG_TW, + PROTOCOL_VERSION, + NUM_USABLE_CPU, + DISK_DATASET_CACHE, + SIMPLE_DATASET_CACHE, + DISK_EXPRESSION_CACHE, + DEPENDENCY_REDIS_CACHE, +) if TYPE_CHECKING: from qlib.utils.time import Freq @@ -120,17 +129,6 @@ def register_from_C(config, skip_register=True): C.register() -# pickle.dump protocol version: https://docs.python.org/3/library/pickle.html#data-stream-format -PROTOCOL_VERSION = 4 - -NUM_USABLE_CPU = max(multiprocessing.cpu_count() - 2, 1) - -DISK_DATASET_CACHE = "DiskDatasetCache" -SIMPLE_DATASET_CACHE = "SimpleDatasetCache" -DISK_EXPRESSION_CACHE = "DiskExpressionCache" - -DEPENDENCY_REDIS_CACHE = (DISK_DATASET_CACHE, DISK_EXPRESSION_CACHE) - _default_config = { # data provider config "calendar_provider": "LocalCalendarProvider", diff --git a/qlib/constant.py b/qlib/constant.py index ac6c76ae22..d11ea0ec6c 100644 --- a/qlib/constant.py +++ b/qlib/constant.py @@ -2,6 +2,7 @@ # Licensed under the MIT License. # REGION CONST +import multiprocessing from typing import TypeVar import numpy as np @@ -20,3 +21,14 @@ ONE_MIN = pd.Timedelta("1min") EPS_T = pd.Timedelta("1s") # use 1 second to exclude the right interval point float_or_ndarray = TypeVar("float_or_ndarray", float, np.ndarray) + +# pickle.dump protocol version: https://docs.python.org/3/library/pickle.html#data-stream-format +PROTOCOL_VERSION = 4 + +NUM_USABLE_CPU = max(multiprocessing.cpu_count() - 2, 1) + +DISK_DATASET_CACHE = "DiskDatasetCache" +SIMPLE_DATASET_CACHE = "SimpleDatasetCache" +DISK_EXPRESSION_CACHE = "DiskExpressionCache" + +DEPENDENCY_REDIS_CACHE = (DISK_DATASET_CACHE, DISK_EXPRESSION_CACHE)