huggingface / huggingface/deep-rl-class
[HANDS-ON BUG] Unit 1 - deprecated cod
- Dominant language
- MDX
- Stars
- 5k
- Forks
- 811
- PR merge metrics
- No merged PRs in 30d
Description
# Describe the bug
A clear and concise description of what the bug is.
**Please share your notebook link so that we can reproduce the error**
**Error #1**
**setup.py**
`Preparing metadata (setup.py) ... done Collecting pygame==2.1.3 (from gymnasium[box2d]->-r https://raw.githubusercontent.com/huggingface/deep-rl-class/main/notebooks/unit1/requirements-unit1.txt (line 3)) Downloading pygame-2.1.3.tar.gz (12.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.8/12.8 MB 77.6 MB/s eta 0:00:00 error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. Preparing metadata (setup.py) ... error error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. `
**Fix:**
`Error is occurring because the notebook is trying to install an older version of pygame (2.1.3) which is failing to compile on the current Python environment. `
**New command:**
!pip install "stable-baselines3[extra]>=2.0.0" gymnasium[box2d] huggingface_sb3
Error #2
Deprecated LunarLander-v2
```
import gymnasium as gym
# First, we create our environment called LunarLander-v2
env = gym.make("LunarLander-v2")
```
**Fix:**
Change LunarLander-v2 for LunarLander-v3
**Error #3**
Leaderboard does not work.
https://huggingface.co/spaces/huggingface-projects/Deep-Reinforcement-Learning-Leaderboard
**Error #4**
When I finish Unit one, the progress is not reflected in the progress screen.
Now that Thomas Simonini is not in HF anymore, is anyone taking care of this?
https://huggingface.co/spaces/ThomasSimonini/Check-my-progress-Deep-RL-Course
**Suggestion 1**
EvalCallBack evalutation during training
```
from stable_baselines3.common.callbacks import EvalCallback
eval_callback = EvalCallback(
env,
best_model_save_path="./best_model/",
log_path="./logs/",
eval_freq=12_000,
n_eval_episodes=20,
deterministic=True,
)
model.learn(
total_timesteps=300_000,
callback=eval_callback,
reset_num_timesteps=False,
)
```
**Suggestion 2**
It would be great to have a render to see the landing, example:
```
import base64
from pathlib import Path
from IPython import display as ipythondisplay
from stable_baselines3.common.vec_env import VecVideoRecorder, DummyVecEnv
def show_video():
"""Displays the recorded video in the notebook."""
html = []
for mp4 in Path("videos").glob("*.mp4"):
video_b64 = base64.b64encode(mp4.read_bytes()).decode()
html.append(f'''
''')
ipythondisplay.display(ipythondisplay.HTML(data="
".join(html)))
# 1. Create a dummy vectorized environment
video_env = DummyVecEnv([lambda: gym.make("LunarLander-v3", render_mode="rgb_array")])
# 2. Wrap it with VecVideoRecorder to record the frames
video_env = VecVideoRecorder(video_env, "videos/",
record_video_trigger=lambda x: x == 0,
video_length=1000,
name_prefix="best-agent")
# 3. Run one episode
obs = video_env.reset()
for _ in range(1000):
action, _states = best_model.predict(obs, deterministic=True)
obs, rewards, dones, info = video_env.step(action)
if dones:
break
# 4. Close the environment and show the result
video_env.close()
show_video()
```
# Material
- Did you use Google Colab? YES
Colab Link: https://colab.research.google.com/github/huggingface/deep-rl-class/blob/master/notebooks/unit1/unit1.ipynb
If not:
- Your Operating system (OS)
- Version of your OS
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with notebooks/unit1/unit1.ipynb and the referenced notebooks/unit1/requirements-unit1.txt; reproduce the pygame metadata failure and the LunarLander-v2 error in Colab. Check the linked leaderboard and progress Spaces separately. Done means Unit 1 installs and runs with current package versions, uses the supported environment name, and its progress and leaderboard behavior are either restored or clearly scoped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100