Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gym.Env TypeError: 'type' object is not subscriptable #1477

Open
Zeigar opened this issue Mar 24, 2023 · 1 comment
Open

gym.Env TypeError: 'type' object is not subscriptable #1477

Zeigar opened this issue Mar 24, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@Zeigar
Copy link

Zeigar commented Mar 24, 2023

🐛 Bug Description

To Reproduce

Steps to reproduce the behavior:

  1. 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

@Zeigar Zeigar added the bug Something isn't working label Mar 24, 2023
@Cadenza-Li
Copy link
Contributor

Hi,you can try downgrade tianshou to 4.10, it works for me.
https://github.com/microsoft/qlib/blob/main/setup.py

  # In version 0.4.11 of tianshou, the code:
  # logits, hidden = self.actor(batch.obs, state=state, info=batch.info)
  # was changed in PR787,
  # which causes pytest errors(AttributeError: 'dict' object has no attribute 'info') in CI,
  # so we restricted the version of tianshou.
  # References:
  # https://github.com/thu-ml/tianshou/releases
  "tianshou<=0.4.10",
  "gym>=0.24",  # If you do not put gym at the end, gym will degrade causing pytest results to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants