mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-14 16:26:55 +08:00
yml afe load
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.SafeLoader)
|
config = yaml.safe_load(f)
|
||||||
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)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class UserManager:
|
|||||||
raise ValueError("User data for {} already exists".format(user_id))
|
raise ValueError("User data for {} already exists".format(user_id))
|
||||||
|
|
||||||
with config_file.open("r") as fp:
|
with config_file.open("r") as fp:
|
||||||
config = yaml.load(fp)
|
config = yaml.safe_load(fp)
|
||||||
# load model
|
# load model
|
||||||
model = init_instance_by_config(config["model"])
|
model = init_instance_by_config(config["model"])
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ def prepare(um, today, user_id, exchange_config=None):
|
|||||||
dates.append(get_next_trading_date(dates[-1], future=True))
|
dates.append(get_next_trading_date(dates[-1], future=True))
|
||||||
if exchange_config:
|
if exchange_config:
|
||||||
with pathlib.Path(exchange_config).open("r") as fp:
|
with pathlib.Path(exchange_config).open("r") as fp:
|
||||||
exchange_paras = yaml.load(fp)
|
exchange_paras = yaml.safe_load(fp)
|
||||||
else:
|
else:
|
||||||
exchange_paras = {}
|
exchange_paras = {}
|
||||||
trade_exchange = Exchange(trade_dates=dates, **exchange_paras)
|
trade_exchange = Exchange(trade_dates=dates, **exchange_paras)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class TunerConfigManager:
|
|||||||
self.config_path = config_path
|
self.config_path = config_path
|
||||||
|
|
||||||
with open(config_path) as fp:
|
with open(config_path) as fp:
|
||||||
config = yaml.load(fp)
|
config = yaml.safe_load(fp)
|
||||||
self.config = copy.deepcopy(config)
|
self.config = copy.deepcopy(config)
|
||||||
|
|
||||||
self.pipeline_ex_config = PipelineExperimentConfig(config.get("experiment", dict()), self)
|
self.pipeline_ex_config = PipelineExperimentConfig(config.get("experiment", dict()), self)
|
||||||
|
|||||||
@@ -128,10 +128,10 @@ 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, Loader=yaml.SafeLoader)
|
return yaml.safe_load(f)
|
||||||
# Check whether the str can be parsed
|
# Check whether the str can be parsed
|
||||||
try:
|
try:
|
||||||
return yaml.load(config)
|
return yaml.safe_load(config)
|
||||||
except BaseException:
|
except BaseException:
|
||||||
raise ValueError("cannot parse config!")
|
raise ValueError("cannot parse config!")
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ def sys_config(config, config_path):
|
|||||||
# worflow handler function
|
# worflow handler function
|
||||||
def workflow(config_path, experiment_name="workflow", uri_folder="mlruns"):
|
def workflow(config_path, experiment_name="workflow", uri_folder="mlruns"):
|
||||||
with open(config_path) as fp:
|
with open(config_path) as fp:
|
||||||
config = yaml.load(fp, Loader=yaml.SafeLoader)
|
config = yaml.safe_load(fp)
|
||||||
|
|
||||||
# config the `sys` section
|
# config the `sys` section
|
||||||
sys_config(config, config_path)
|
sys_config(config, config_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user