|
27 | 27 | if TYPE_CHECKING: |
28 | 28 | from qlib.utils.time import Freq |
29 | 29 |
|
| 30 | +from pydantic_settings import BaseSettings, SettingsConfigDict |
| 31 | + |
| 32 | + |
| 33 | +class MLflowSettings(BaseSettings): |
| 34 | + uri: str = "file:" + str(Path(os.getcwd()).resolve() / "mlruns") |
| 35 | + default_exp_name: str = "Experiment" |
| 36 | + |
| 37 | + |
| 38 | +class QSettings(BaseSettings): |
| 39 | + """ |
| 40 | + Qlib's settings. |
| 41 | + It tries to provide a default settings for most of Qlib's components. |
| 42 | + But it would be a long journey to provide a comprehensive settings for all of Qlib's components. |
| 43 | +
|
| 44 | + Here is some design guidelines: |
| 45 | + - The priority of settings is |
| 46 | + - Actively passed-in settings, like `qlib.init(provider_uri=...)` |
| 47 | + - The default settings |
| 48 | + - QSettings tries to provide default settings for most of Qlib's components. |
| 49 | + """ |
| 50 | + |
| 51 | + mlflow: MLflowSettings = MLflowSettings() |
| 52 | + |
| 53 | + model_config = SettingsConfigDict( |
| 54 | + env_prefix="QLIB_", |
| 55 | + env_nested_delimiter="_", |
| 56 | + ) |
| 57 | + |
| 58 | + |
| 59 | +QSETTINGS = QSettings() |
| 60 | + |
30 | 61 |
|
31 | 62 | class Config: |
32 | 63 | def __init__(self, default_conf): |
@@ -187,8 +218,8 @@ def register_from_C(config, skip_register=True): |
187 | 218 | "class": "MLflowExpManager", |
188 | 219 | "module_path": "qlib.workflow.expm", |
189 | 220 | "kwargs": { |
190 | | - "uri": "file:" + str(Path(os.getcwd()).resolve() / "mlruns"), |
191 | | - "default_exp_name": "Experiment", |
| 221 | + "uri": QSETTINGS.mlflow.uri, |
| 222 | + "default_exp_name": QSETTINGS.mlflow.default_exp_name, |
192 | 223 | }, |
193 | 224 | }, |
194 | 225 | "pit_record_type": { |
|
0 commit comments