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

[RLlib] custom_env example does not work #30582

Closed
kunterbunt opened this issue Nov 22, 2022 · 5 comments
Closed

[RLlib] custom_env example does not work #30582

kunterbunt opened this issue Nov 22, 2022 · 5 comments
Assignees
Labels
bug Something that is supposed to be working; but isn't P2 Important issue, but not time-critical rllib RLlib related issues

Comments

@kunterbunt
Copy link

kunterbunt commented Nov 22, 2022

What happened + What you expected to happen

Executing the example script throws the following error:

Running with following CLI options: Namespace(as_test=False, framework='tf2', local_mode=False, no_tune=False, run='PPO', stop_iters=50, stop_reward=0.1, stop_timesteps=100000)
2022-11-22 13:26:57,570 INFO worker.py:1528 -- Started a local Ray instance.
Traceback (most recent call last):
  File "/home/seba/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/seba/.pyenv/versions/3.8.12/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "<path>/test_drl_custom_policy.py", line 161, in <module>
    get_trainable_cls(args.run)
AttributeError: 'dict' object has no attribute 'environment'

I tried both tf and tf2.

Versions / Dependencies

  • tensorflow 2.11.0
  • ray 2.1.0
  • Python 3.8.12
  • Linux manjaro 5.15.76-1-MANJARO #1 SMP PREEMPT Sat Oct 29 14:22:16 UTC 2022 x86_64 GNU/Linux

Reproduction script

Exactly this script

Issue Severity

High: It blocks me from completing my task.

@kunterbunt kunterbunt added bug Something that is supposed to be working; but isn't triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Nov 22, 2022
@kunterbunt kunterbunt changed the title [RLli] custom_env example does notw ork [RLli] custom_env example does not work Nov 22, 2022
@sven1977 sven1977 added P2 Important issue, but not time-critical and removed triage Needs triage (eg: priority, bug/not-bug, and owning component) labels Nov 23, 2022
@anatolii-kotov
Copy link

I have the same issue on Mac OS 13.0.1 with Python 3.9.15, Pytorch and Ray 2.1.0

@kunterbunt kunterbunt changed the title [RLli] custom_env example does not work [RLlib] custom_env example does not work Dec 2, 2022
@signalprime
Copy link

signalprime commented Dec 11, 2022

What is the last known stable version where things work with the examples? I understand it is a WIP.

the fix was found here. Essentially it was:

    config = (
        PPOConfig()
        .environment(SimpleCorridor, env_config={"corridor_length": 5})
        ...

@sven1977 sven1977 self-assigned this Dec 12, 2022
@sven1977 sven1977 added the rllib RLlib related issues label Dec 12, 2022
@sven1977
Copy link
Contributor

Seems to be resolved. Thanks for filing this issue and your answers @kunterbunt , @anatolii-kotov , and @signalprime !

@kunterbunt
Copy link
Author

Seems to be resolved. Thanks for filing this issue and your answers @kunterbunt , @anatolii-kotov , and @signalprime !

Shouldn't the example code be fixed before the issue is closed? Yes, the fix works, but should everyone who looks into your tutorials and demo code stumble upon this error, dig up this issue, find the reference to another issue, and manually apply the fix?

@amanarora28
Copy link

I am getting this error while running custom env form examples.
Please help me resolve.
ValueError: Env must be of one of the following supported types: BaseEnv, gym.Env, MultiAgentEnv, VectorEnv, RemoteBaseEnv, ExternalMultiAgentEnv, ExternalEnv, but instead is of type <class 'main.SimpleCorridor'>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is supposed to be working; but isn't P2 Important issue, but not time-critical rllib RLlib related issues
Projects
None yet
Development

No branches or pull requests

5 participants