MCPcopy
hub / github.com/microsoft/qlib / auto_init

Function auto_init

qlib/__init__.py:233–307  ·  view source on GitHub ↗

This function will init qlib automatically with following priority - Find the project configuration and init qlib - The parsing process will be affected by the `conf_type` of the configuration file - Init qlib with default config - Skip initialization if already initialized

(**kwargs)

Source from the content-addressed store, hash-verified

231
232
233def auto_init(**kwargs):
234 """
235 This function will init qlib automatically with following priority
236 - Find the project configuration and init qlib
237 - The parsing process will be affected by the `conf_type` of the configuration file
238 - Init qlib with default config
239 - Skip initialization if already initialized
240
241 :**kwargs: it may contain following parameters
242 cur_path: the start path to find the project path
243
244 Here are two examples of the configuration
245
246 Example 1)
247 If you want to create a new project-specific config based on a shared configure, you can use `conf_type: ref`
248
249 .. code-block:: yaml
250
251 conf_type: ref
252 qlib_cfg: '<shared_yaml_config_path>' # this could be null reference no config from other files
253 # following configs in `qlib_cfg_update` is project=specific
254 qlib_cfg_update:
255 exp_manager:
256 class: "MLflowExpManager"
257 module_path: "qlib.workflow.expm"
258 kwargs:
259 uri: "file://<your mlflow experiment path>"
260 default_exp_name: "Experiment"
261
262 Example 2)
263 If you want to create simple a standalone config, you can use following config(a.k.a. `conf_type: origin`)
264
265 .. code-block:: python
266
267 exp_manager:
268 class: "MLflowExpManager"
269 module_path: "qlib.workflow.expm"
270 kwargs:
271 uri: "file://<your mlflow experiment path>"
272 default_exp_name: "Experiment"
273
274 """
275 kwargs["skip_if_reg"] = kwargs.get("skip_if_reg", True)
276
277 try:
278 pp = get_project_path(cur_path=kwargs.pop("cur_path", None))
279 except FileNotFoundError:
280 init(**kwargs)
281 else:
282 logger = get_module_logger("Initialization")
283 conf_pp = pp / "config.yaml"
284 with conf_pp.open() as f:
285 yaml = YAML(typ="safe", pure=True)
286 conf = yaml.load(f)
287
288 conf_type = conf.get("conf_type", "origin")
289 if conf_type == "origin":
290 # The type of config is just like original qlib config

Callers 6

workflow.pyFile · 0.90
vis_data.pyFile · 0.90
__main__.pyFile · 0.90
base.pyFile · 0.90
manage.pyFile · 0.90

Calls 8

get_project_pathFunction · 0.85
initFunction · 0.85
init_from_yaml_confFunction · 0.85
popMethod · 0.80
getMethod · 0.45
loadMethod · 0.45
updateMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected