Skip to content

Commit 50d5fcf

Browse files
committed
yml afe load
1 parent 77830a5 commit 50d5fcf

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

qlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def init_from_yaml_conf(conf_path, **kwargs):
147147
"""
148148

149149
with open(conf_path) as f:
150-
config = yaml.load(f, Loader=yaml.SafeLoader)
150+
config = yaml.safe_load(f)
151151
config.update(kwargs)
152152
default_conf = config.pop("default_conf", "client")
153153
init(default_conf, **config)

qlib/contrib/online/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def add_user(self, user_id, config_file, add_date):
110110
raise ValueError("User data for {} already exists".format(user_id))
111111

112112
with config_file.open("r") as fp:
113-
config = yaml.load(fp)
113+
config = yaml.safe_load(fp)
114114
# load model
115115
model = init_instance_by_config(config["model"])
116116

qlib/contrib/online/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def prepare(um, today, user_id, exchange_config=None):
8888
dates.append(get_next_trading_date(dates[-1], future=True))
8989
if exchange_config:
9090
with pathlib.Path(exchange_config).open("r") as fp:
91-
exchange_paras = yaml.load(fp)
91+
exchange_paras = yaml.safe_load(fp)
9292
else:
9393
exchange_paras = {}
9494
trade_exchange = Exchange(trade_dates=dates, **exchange_paras)

qlib/contrib/tuner/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, config_path):
1414
self.config_path = config_path
1515

1616
with open(config_path) as fp:
17-
config = yaml.load(fp)
17+
config = yaml.safe_load(fp)
1818
self.config = copy.deepcopy(config)
1919

2020
self.pipeline_ex_config = PipelineExperimentConfig(config.get("experiment", dict()), self)

qlib/utils/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ def parse_config(config):
128128
# Check whether config is file
129129
if os.path.exists(config):
130130
with open(config, "r") as f:
131-
return yaml.load(f, Loader=yaml.SafeLoader)
131+
return yaml.safe_load(f)
132132
# Check whether the str can be parsed
133133
try:
134-
return yaml.load(config)
134+
return yaml.safe_load(config)
135135
except BaseException:
136136
raise ValueError("cannot parse config!")
137137

qlib/workflow/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def sys_config(config, config_path):
4444
# worflow handler function
4545
def workflow(config_path, experiment_name="workflow", uri_folder="mlruns"):
4646
with open(config_path) as fp:
47-
config = yaml.load(fp, Loader=yaml.SafeLoader)
47+
config = yaml.safe_load(fp)
4848

4949
# config the `sys` section
5050
sys_config(config, config_path)

0 commit comments

Comments
 (0)