microsoft / qlib

Qlib is an AI-oriented quantitative investment platform that aims to realize the potential, empower research, and create value using AI technologies in quantitative investment, from exploring ideas to implementing productions. Qlib supports diverse machine learning modeling paradigms. including supervised learning, market dynamics modeling, and RL.
https://qlib.readthedocs.io/en/latest/
MIT License
15.22k stars 2.6k forks source link

TypeError in run_all_models.py #816

Open Waterkin opened 2 years ago

Waterkin commented 2 years ago

🐛 Bug Description

File "run_all_model.py", line 385, in fire.Fire(ModelRunner) # run all the model File "/home/wlh/anaconda3/envs/qlib/lib/python3.7/site-packages/fire/core.py", line 141, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/home/wlh/anaconda3/envs/qlib/lib/python3.7/site-packages/fire/core.py", line 471, in _Fire target=component.name) File "/home/wlh/anaconda3/envs/qlib/lib/python3.7/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace component = fn(*varargs, *kwargs) File "run_all_model.py", line 40, in _return_wrapped return function_to_decorate(args, **kwargs) File "run_all_model.py", line 320, in run yaml_path = gen_yaml_file_without_seed_kwargs(yaml_path, temp_dir) File "run_all_model.py", line 190, in gen_yaml_file_without_seed_kwargs config = yaml.load(fp) TypeError: load() missing 1 required positional argument: 'Loader'

To Reproduce

Steps to reproduce the behavior:

1.python run_all_model.py run 3

Expected Behavior

Screenshot

image

Environment

Note: User could run cd scripts && python collect_info.py all under project directory to get system information and paste them here directly.

Additional Notes

Wangwuyi123 commented 2 years ago

@Waterkin I failed to duplicate your mistake, Can you go back in detail. Specific commands, specific circumstances

you-n-g commented 2 years ago

@Waterkin Can you give us more details about how to reproduce your error? It will be helpful if you can give more details about your environments information by running cd scripts && python collect_info.py all

Waterkin commented 2 years ago

(qlib-37) 👍  scripts   main ±  python collect_info.py all Darwin x86_64 Darwin-21.2.0-x86_64-i386-64bit Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64

Python version: 3.7.9 (default, Aug 31 2020, 07:22:35) [Clang 10.0.0 ]

Qlib version: 0.8.0 numpy==1.21.5 pandas==1.1.2 scipy==1.7.3 requests==2.26.0 sacred==0.8.2 python-socketio==5.5.0 redis==4.1.0 python-redis-lock==3.7.0 schedule==1.1.0 cvxpy==1.1.18 hyperopt==0.1.1 fire==0.4.0 statsmodels==0.13.1 xlrd==1.2.0 plotly==5.5.0 matplotlib==3.5.1 tables==3.7.0 pyyaml==6.0 mlflow==1.22.0 tqdm==4.62.3 loguru==0.5.3 lightgbm==3.1.0 tornado==6.1 joblib==1.1.0 fire==0.4.0 ruamel.yaml==0.17.19

@Waterkin Can you give us more details about how to reproduce your error? It will be helpful if you can give more details about your environments information by running cd scripts && python collect_info.py all

you-n-g commented 2 years ago

@Waterkin Will replacing yaml.load wiht yaml.safe_load be helpful ? https://github.com/microsoft/qlib/blob/main/examples/run_all_model.py#L189

Newtoniano commented 2 years ago

@Waterkin see https://github.com/microsoft/qlib/issues/799#issuecomment-1069043821 since @you-n-g PR probably fixed this too (didn't run this file to double check), granted you first downgrade pyyaml to 5.4.1 with pip install pyyaml==5.4.1

wd2374 commented 2 years ago

由于Yaml 5.1版本后弃用了 yaml.load(file) 这个用法。Yaml 5.1版本之后就修改了需要指定Loader,通过默认加载​​器(FullLoader)禁止执行任意函数,使得此load函数的安全得到加强。 有三个解决方法: 1、添加Load参数:config = yaml.load(fp,Loader=yaml.FullLoader) 2、使用safe_load()函数代替 load() 3、降级pyyaml 版本