mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-14 16:26:55 +08:00
safe yaml loader
This commit is contained in:
@@ -147,7 +147,7 @@ def init_from_yaml_conf(conf_path, **kwargs):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
with open(conf_path) as f:
|
with open(conf_path) as f:
|
||||||
config = yaml.load(f, Loader=yaml.FullLoader)
|
config = yaml.load(f, Loader=yaml.SafeLoader)
|
||||||
config.update(kwargs)
|
config.update(kwargs)
|
||||||
default_conf = config.pop("default_conf", "client")
|
default_conf = config.pop("default_conf", "client")
|
||||||
init(default_conf, **config)
|
init(default_conf, **config)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ def parse_config(config):
|
|||||||
# Check whether config is file
|
# Check whether config is file
|
||||||
if os.path.exists(config):
|
if os.path.exists(config):
|
||||||
with open(config, "r") as f:
|
with open(config, "r") as f:
|
||||||
return yaml.load(f)
|
return yaml.load(f, Loader=yaml.SafeLoader)
|
||||||
# Check whether the str can be parsed
|
# Check whether the str can be parsed
|
||||||
try:
|
try:
|
||||||
return yaml.load(config)
|
return yaml.load(config)
|
||||||
|
|||||||
Reference in New Issue
Block a user