gym.Env TypeError: 'type' object is not subscriptable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 48.7k
- Forks
- 7.7k
- PR merge metrics
- No merged PRs in 30d
Description
🐛 Bug Description
To Reproduce
Steps to reproduce the behavior:
- from qlib.rl.trainer import Checkpoint, train
Expected Behavior
Screenshot
Environment
TypeError Traceback (most recent call last)
Cell In[20], line 4
2 from pathlib import Path
3 from typing import cast
----> 4 from qlib.rl.trainer import Checkpoint, train
7 NSTEPS = 10
9 trainer_kwargs = {
10 "max_iters": 10,
11 "finite_env_type": "dummy",
(...)
18 ],
19 }
File ~.conda\envs\TradeMaster\lib\site-packages\qlib\rl\trainer_init_.py:6
1 # Copyright (c) Microsoft Corporation.
2 # Licensed under the MIT License.
4 """Train, test, inference utilities."""
----> 6 from .api import backtest, train
7 from .callbacks import Checkpoint, EarlyStopping, MetricsWriter
8 from .trainer import Trainer
File ~.conda\envs\TradeMaster\lib\site-packages\qlib\rl\trainer\api.py:13
11 from qlib.rl.reward import Reward
12 from qlib.rl.simulator import InitialStateType, Simulator
---> 13 from qlib.rl.utils import FiniteEnvType, LogWriter
15 from .trainer import Trainer
16 from .vessel import TrainingVessel
File ~.conda\envs\TradeMaster\lib\site-packages\qlib\rl\utils_init_.py:5
1 # Copyright (c) Microsoft Corporation.
2 # Licensed under the MIT License.
4 from .data_queue import DataQueue
----> 5 from .env_wrapper import EnvWrapper, EnvWrapperStatus
6 from .finite_env import FiniteEnvType, vectorize_env
7 from .log import ConsoleWriter, CsvWriter, LogBuffer, LogCollector, LogLevel, LogWriter
File ~.conda\envs\TradeMaster\lib\site-packages\qlib\rl\utils\env_wrapper.py:52
47 action_history: list
48 reward_history: list
51 class EnvWrapper(
---> 52 gym.Env[ObsType, PolicyActType],
53 Generic[InitialStateType, StateType, ActType, ObsType, PolicyActType],
54 ):
55 """Qlib-based RL environment, subclassing gym.Env.
56 A wrapper of components, including simulator, state-interpreter, action-interpreter, reward.
57
(...)
90 Can be none when no trajectory is available.
91 """
93 simulator: Simulator[InitialStateType, StateType, ActType]
TypeError: 'type' object is not subscriptable
Note: User could run cd scripts && python collect_info.py all under project directory to get system information
and paste them here directly.
- Qlib version:
- Python version:
- OS (
Windows,Linux,MacOS): - Commit number (optional, please provide it if you are using the dev version):
Additional Notes
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the EnvWrapper declaration in qlib/rl/utils/env_wrapper.py, reached while importing qlib.rl.trainer and qlib.rl.utils. Check the installed Python and gym environment while reproducing the import; done means importing Checkpoint and train no longer raises the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100