microsoft / microsoft/qlib

Run cmd python -m qlib.rl.contrib.train_onpolicy --config_path exp_configs/train_opds.yml --run_backtest with error

Open
#1,764 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
48.7k
Forks
7.7k
PR merge metrics
No merged PRs in 30d

Description

python -m qlib.rl.contrib.train_onpolicy --config_path exp_configs/train_opds.yml --run_backtest

/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/env/venvs.py:66: UserWarning: You provided an environment generator that returned an OpenAI Gym environment. We strongly recommend transitioning to Gymnasium environments. Tianshou is automatically wrapping your environments in a compatibility layer, which could potentially cause issues.
warnings.warn(
Traceback (most recent call last):
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 268, in
main(config, run_training=not args.no_training, run_backtest=args.run_backtest)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 241, in main
train_and_test(
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/contrib/train_onpolicy.py", line 159, in train_and_test
train(
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/trainer/api.py", line 63, in train
trainer.fit(vessel)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/trainer/trainer.py", line 224, in fit
self.vessel.train(vector_env)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/trainer/vessel.py", line 171, in train
collector = Collector(self.policy, vector_env, VectorReplayBuffer(self.buffer_size, len(vector_env)))
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/data/collector.py", line 80, in init
self.reset(False)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/data/collector.py", line 131, in reset
self.reset_env(gym_reset_kwargs)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/data/collector.py", line 147, in reset_env
obs, info = self.env.reset(**gym_reset_kwargs)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/utils/finite_env.py", line 233, in reset
for i, o in zip(request_id, super().reset(request_id)):
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/tianshou/env/venvs.py", line 280, in reset
assert (
AssertionError: The environment does not adhere to the Gymnasium's API.
Exception ignored in: <function DataQueue.del at 0x7fc212bf9dc0>
Traceback (most recent call last):
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/utils/data_queue.py", line 148, in del
self.cleanup()
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/site-packages/qlib/rl/utils/data_queue.py", line 101, in cleanup
self._queue.get(block=False)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/queues.py", line 111, in get
res = self._recv_bytes()
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/connection.py", line 216, in recv_bytes
buf = self._recv_bytes(maxlength)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/connection.py", line 414, in _recv_bytes
buf = self._recv(4)
File "/hdd9/yanzheng/folder_to_make_space_for_home/miniconda3/envs/py38/lib/python3.8/multiprocessing/connection.py", line 383, in _recv
raise EOFError
EOFError:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the command with exp_configs/train_opds.yml and --run_backtest, then trace the reset path from qlib/rl/contrib/train_onpolicy.py through qlib/rl/trainer/vessel.py and qlib/rl/utils/finite_env.py into Tianshou's venvs.py. Check the environment reset contract and determine what needs to change so the command passes the Gymnasium API assertion without the cleanup error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.