|
| 1 | +name: "\U0001F916 Custom Gym Environment Issue" |
| 2 | +description: How to report an issue when using a custom Gym environment |
| 3 | +labels: ["question", "custom gym env"] |
| 4 | +body: |
| 5 | + - type: markdown |
| 6 | + attributes: |
| 7 | + value: | |
| 8 | + **Important Note: We do not do technical support, nor consulting** and don't answer personal questions per email. |
| 9 | + Please post your question on the [RL Discord](https://discord.com/invite/xhfNqQv), [Reddit](https://www.reddit.com/r/reinforcementlearning/) or [Stack Overflow](https://stackoverflow.com/) in that case. |
| 10 | +
|
| 11 | + **Please check your environment first using**: |
| 12 | + ```python |
| 13 | + from stable_baselines3.common.env_checker import check_env |
| 14 | +
|
| 15 | + env = CustomEnv(arg1, ...) |
| 16 | + # It will check your custom environment and output additional warnings if needed |
| 17 | + check_env(env) |
| 18 | + ``` |
| 19 | + - type: textarea |
| 20 | + id: description |
| 21 | + attributes: |
| 22 | + label: 🐛 Bug |
| 23 | + description: A clear and concise description of what the bug is. |
| 24 | + validations: |
| 25 | + required: true |
| 26 | + - type: textarea |
| 27 | + id: code-example |
| 28 | + attributes: |
| 29 | + label: Code example |
| 30 | + description: | |
| 31 | + Please try to provide a minimal example to reproduce the bug. |
| 32 | + For a custom environment, you need to give at least the observation space, action space, `reset()` and `step()` methods (see working example below). |
| 33 | + Error messages and stack traces are also helpful. |
| 34 | + Please use the [markdown code blocks](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) for both code and stack traces. |
| 35 | + value: | |
| 36 | + ```python |
| 37 | + import gymnasium as gym |
| 38 | + import numpy as np |
| 39 | +
|
| 40 | + from stable_baselines3 import A2C |
| 41 | + from stable_baselines3.common.env_checker import check_env |
| 42 | +
|
| 43 | +
|
| 44 | + class CustomEnv(gym.Env): |
| 45 | +
|
| 46 | + def __init__(self): |
| 47 | + super().__init__() |
| 48 | + self.observation_space = gym.spaces.Box(low=-np.inf, high=np.inf, shape=(14,)) |
| 49 | + self.action_space = gym.spaces.Box(low=-1, high=1, shape=(6,)) |
| 50 | +
|
| 51 | + def reset(self): |
| 52 | + return self.observation_space.sample(), {} |
| 53 | +
|
| 54 | + def step(self, action): |
| 55 | + obs = self.observation_space.sample() |
| 56 | + reward = 1.0 |
| 57 | + done = False |
| 58 | + truncated = False |
| 59 | + info = {} |
| 60 | + return obs, reward, done, truncated, info |
| 61 | +
|
| 62 | + env = CustomEnv() |
| 63 | + check_env(env) |
| 64 | +
|
| 65 | + model = A2C("MlpPolicy", env, verbose=1).learn(1000) |
| 66 | + ``` |
| 67 | +
|
| 68 | + - type: textarea |
| 69 | + id: traceback |
| 70 | + attributes: |
| 71 | + label: Relevant log output / Error message |
| 72 | + description: Please copy and paste any relevant log output / error message. This will be automatically formatted into code, so no need for backticks. |
| 73 | + placeholder: "Traceback (most recent call last): File ..." |
| 74 | + render: shell |
| 75 | + |
| 76 | + - type: textarea |
| 77 | + id: system-info |
| 78 | + attributes: |
| 79 | + label: System Info |
| 80 | + description: | |
| 81 | + Describe the characteristic of your environment: |
| 82 | + * Describe how the library was installed (pip, docker, source, ...) |
| 83 | + * GPU models and configuration |
| 84 | + * Python version |
| 85 | + * PyTorch version |
| 86 | + * Gym version |
| 87 | + * Versions of any other relevant libraries |
| 88 | +
|
| 89 | + You can use `sb3.get_system_info()` to print relevant packages info: |
| 90 | + ```python |
| 91 | + import stable_baselines3 as sb3 |
| 92 | + sb3.get_system_info() |
| 93 | + ``` |
| 94 | + - type: checkboxes |
| 95 | + id: terms |
| 96 | + attributes: |
| 97 | + label: Checklist |
| 98 | + options: |
| 99 | + - label: I have checked that there is no similar [issue](https://github.com/DLR-RM/stable-baselines3/issues) in the repo |
| 100 | + required: true |
| 101 | + - label: I have read the [documentation](https://stable-baselines3.readthedocs.io/en/master/) |
| 102 | + required: true |
| 103 | + - label: I have provided a minimal working example to reproduce the bug |
| 104 | + required: true |
| 105 | + - label: I have checked my env using the env checker |
| 106 | + required: true |
| 107 | + - label: I've used the [markdown code blocks](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) for both code and stack traces. |
| 108 | + required: true |
0 commit comments