mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-18 18:04:31 +08:00
improve the doc of auto init (#541)
* improve the doc of auto init * Update setup.py * Update setup.py * change cvxpy version Co-authored-by: Wangwuyi123 <51237097+Wangwuyi123@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ _version_path = Path(__file__).absolute().parent / "VERSION.txt" # This file is
|
|||||||
__version__ = _version_path.read_text(encoding="utf-8").strip()
|
__version__ = _version_path.read_text(encoding="utf-8").strip()
|
||||||
__version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version
|
__version__bak = __version__ # This version is backup for QlibConfig.reset_qlib_version
|
||||||
import os
|
import os
|
||||||
|
from typing import Union
|
||||||
import yaml
|
import yaml
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
@@ -158,7 +159,7 @@ def init_from_yaml_conf(conf_path, **kwargs):
|
|||||||
init(default_conf, **config)
|
init(default_conf, **config)
|
||||||
|
|
||||||
|
|
||||||
def get_project_path(config_name="config.yaml", cur_path=None) -> Path:
|
def get_project_path(config_name="config.yaml", cur_path: Union[Path, str, None] = None) -> Path:
|
||||||
"""
|
"""
|
||||||
If users are building a project follow the following pattern.
|
If users are building a project follow the following pattern.
|
||||||
- Qlib is a sub folder in project path
|
- Qlib is a sub folder in project path
|
||||||
@@ -187,6 +188,7 @@ def get_project_path(config_name="config.yaml", cur_path=None) -> Path:
|
|||||||
"""
|
"""
|
||||||
if cur_path is None:
|
if cur_path is None:
|
||||||
cur_path = Path(__file__).absolute().resolve()
|
cur_path = Path(__file__).absolute().resolve()
|
||||||
|
cur_path = Path(cur_path)
|
||||||
while True:
|
while True:
|
||||||
if (cur_path / config_name).exists():
|
if (cur_path / config_name).exists():
|
||||||
return cur_path
|
return cur_path
|
||||||
@@ -202,6 +204,40 @@ def auto_init(**kwargs):
|
|||||||
- The parsing process will be affected by the `conf_type` of the configuration file
|
- The parsing process will be affected by the `conf_type` of the configuration file
|
||||||
- Init qlib with default config
|
- Init qlib with default config
|
||||||
- Skip initialization if already initialized
|
- Skip initialization if already initialized
|
||||||
|
|
||||||
|
:**kwargs: it may contain following parameters
|
||||||
|
cur_path: the start path to find the project path
|
||||||
|
|
||||||
|
Here are two examples of the configuration
|
||||||
|
|
||||||
|
Example 1)
|
||||||
|
If you want create a new project-specific config based on a shared configure, you can use `conf_type: ref`
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
conf_type: ref
|
||||||
|
qlib_cfg: '<shared_yaml_config_path>'
|
||||||
|
# following configs in `qlib_cfg_update` is project=specific
|
||||||
|
qlib_cfg_update:
|
||||||
|
exp_manager:
|
||||||
|
class: "MLflowExpManager"
|
||||||
|
module_path: "qlib.workflow.expm"
|
||||||
|
kwargs:
|
||||||
|
uri: "file://<your mlflow experiment path>"
|
||||||
|
default_exp_name: "Experiment"
|
||||||
|
|
||||||
|
Example 2)
|
||||||
|
If you wan to create simple a stand alone config, you can use following config(a.k.a `conf_type: origin`)
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
exp_manager:
|
||||||
|
class: "MLflowExpManager"
|
||||||
|
module_path: "qlib.workflow.expm"
|
||||||
|
kwargs:
|
||||||
|
uri: "file://<your mlflow experiment path>"
|
||||||
|
default_exp_name: "Experiment"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
kwargs["skip_if_reg"] = kwargs.get("skip_if_reg", True)
|
kwargs["skip_if_reg"] = kwargs.get("skip_if_reg", True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user