Skip to content

Commit

Permalink
yml afe load
Browse files Browse the repository at this point in the history
  • Loading branch information
you-n-g committed Feb 18, 2021
1 parent 77830a5 commit 50d5fcf
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion qlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def init_from_yaml_conf(conf_path, **kwargs):
"""

with open(conf_path) as f:
config = yaml.load(f, Loader=yaml.SafeLoader)
config = yaml.safe_load(f)
config.update(kwargs)
default_conf = config.pop("default_conf", "client")
init(default_conf, **config)
2 changes: 1 addition & 1 deletion qlib/contrib/online/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def add_user(self, user_id, config_file, add_date):
raise ValueError("User data for {} already exists".format(user_id))

with config_file.open("r") as fp:
config = yaml.load(fp)
config = yaml.safe_load(fp)
# load model
model = init_instance_by_config(config["model"])

Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/online/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def prepare(um, today, user_id, exchange_config=None):
dates.append(get_next_trading_date(dates[-1], future=True))
if exchange_config:
with pathlib.Path(exchange_config).open("r") as fp:
exchange_paras = yaml.load(fp)
exchange_paras = yaml.safe_load(fp)
else:
exchange_paras = {}
trade_exchange = Exchange(trade_dates=dates, **exchange_paras)
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/tuner/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, config_path):
self.config_path = config_path

with open(config_path) as fp:
config = yaml.load(fp)
config = yaml.safe_load(fp)
self.config = copy.deepcopy(config)

self.pipeline_ex_config = PipelineExperimentConfig(config.get("experiment", dict()), self)
Expand Down
4 changes: 2 additions & 2 deletions qlib/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ def parse_config(config):
# Check whether config is file
if os.path.exists(config):
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
try:
return yaml.load(config)
return yaml.safe_load(config)
except BaseException:
raise ValueError("cannot parse config!")

Expand Down
2 changes: 1 addition & 1 deletion qlib/workflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def sys_config(config, config_path):
# worflow handler function
def workflow(config_path, experiment_name="workflow", uri_folder="mlruns"):
with open(config_path) as fp:
config = yaml.load(fp, Loader=yaml.SafeLoader)
config = yaml.safe_load(fp)

# config the `sys` section
sys_config(config, config_path)
Expand Down

0 comments on commit 50d5fcf

Please sign in to comment.