DLR-RM / rl-baselines3-zoo

A training framework for Stable Baselines3 reinforcement learning agents, with hyperparameter optimization and pre-trained agents included.
https://rl-baselines3-zoo.readthedocs.io
MIT License
2.01k stars 510 forks source link

[Bug]: enjoy tries to access huggingface #382

Closed solismortis closed 1 year ago

solismortis commented 1 year ago

🐛 Bug

Even though I can see the model in the rl-trained-agents folder.

To Reproduce

python enjoy.py --algo a2c --env CartPole-v1_1 --folder rl-trained-agents/ -n 5000

Relevant log output / Error message

Loading latest experiment, id=0
Pretrained model not found, trying to download it from sb3 Huggingface hub: https://huggingface.co/sb3
Downloading from https://huggingface.co/sb3/a2c-CartPole-v1_1
Traceback (most recent call last):
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/rl_zoo3/enjoy.py", line 87, in enjoy
    _, model_path, log_path = get_model_path(
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/rl_zoo3/utils.py", line 507, in get_model_path
    raise ValueError(f"No model found for {algo} on {env_name}, path: {model_path}")
ValueError: No model found for a2c on CartPole-v1_1, path: rl-trained-agents/a2c/CartPole-v1_1.zip

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py", line 259, in hf_raise_for_status
    response.raise_for_status()
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/sb3/a2c-CartPole-v1_1/resolve/main/a2c-CartPole-v1_1.zip

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/enjoy.py", line 4, in <module>
    enjoy()
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/rl_zoo3/enjoy.py", line 104, in enjoy
    download_from_hub(
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/rl_zoo3/load_from_hub.py", line 48, in download_from_hub
    checkpoint = load_from_hub(repo_id, model_name.filename)
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_sb3/load_from_hub.py", line 16, in load_from_hub
    downloaded_model_file = hf_hub_download(
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1195, in hf_hub_download
    metadata = get_hf_file_metadata(
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1541, in get_hf_file_metadata
    hf_raise_for_status(r)
  File "/home/mel/PycharmProjects/rl-baselines3-zoo/venv/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py", line 291, in hf_raise_for_status
    raise RepositoryNotFoundError(message, response) from e
huggingface_hub.utils._errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-64808066-04dedf24470933db6bd01759)

Repository Not Found for url: https://huggingface.co/sb3/a2c-CartPole-v1_1/resolve/main/a2c-CartPole-v1_1.zip.
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated.
Invalid username or password.

System Info

Checklist

qgallouedec commented 1 year ago

Can you confirm that the following command does not throw an error?

python -c 'import os; assert os.path.isfile("rl-trained-agents/a2c/CartPole-v1_1.zip"), "File does not exist"'
solismortis commented 1 year ago

Can you confirm that the following command does not throw an error?

AssertionError: File does not exist.

But it is there.

Wait, the file is called CartPole-v1.zip.

araffin commented 1 year ago

you have a typo: --env CartPole-v1_1 -> --env CartPole-v1

solismortis commented 1 year ago

you have a typo: --env CartPole-v1_1 -> --env CartPole-v1

This happened because I went browsing the rl-trained-agents folder. Maybe enjoy should check for this mistake for dummies like me.