-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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][minor] Fix multiple Unity3DEnvs trying to connect to the same custom port #13519
[rllib][minor] Fix multiple Unity3DEnvs trying to connect to the same custom port #13519
Conversation
10edc21
to
ce5fb5b
Compare
ce5fb5b
to
6b6c548
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for the fix @yurirocha15 !
Could you do one more thing and add your new tests to the rllib/BUILD file?
Somewhere here?
py_test(
name = "env/wrappers/tests/test_unity3d_env",
tags = ["env"],
size = "small",
srcs = ["env/wrappers/tests/test_unity3d_env.py"]
)
# .... before this one here vv
py_test(
name = "env/wrappers/tests/test_recsim_wrapper",
tags = ["env"],
size = "small",
srcs = ["env/wrappers/tests/test_recsim_wrapper.py"]
)
Travis is failing to find mlagents_envs (which is imported in the tests). I guess it might be necessary to add the mlagents requirements to python/requirements_rllib.txt. |
@sven1977 Would it be ok to add mlagents to rllib requirements? |
@YuriRocha thanks a lot for adding the test. Yes, you can add
to |
I added the two modules to the requirements_rllib.txt. Just waiting for tests now to pass. ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @yurirocha15 ! Looks good now.
@sven1977 Thank you! |
…e custom port (ray-project#13519)" This reverts commit 67f4110.
…e custom port (ray-project#13519)" This reverts commit 67f4110.
Why are these changes needed?
When running the Unity3D env with several workers while using a custom port, every environment will try to connect to the same port.
The current logic increments the base_port while keeping the worker_id fixed. This works without issues if the default base port is used. However, if the user decides to use a custom port, this will override the base_port, trying to create several environments using the same custom port. The first environment will succeed, while the remaining environments will be trapped in an infinite loop.
This PR fixes that by keeping the base_port fixed and incrementing the worker_id instead.
This PR also changed the base port value when calling a compiled app (to 5005, the same default as ml-agents uses internally. The editor port stays the same). There is a use case where the user might be running a distributed training in the background while debugging/prototyping/testing new features in the editor. If the first compiled environment is using the editor default port, the editor will fail to connect.
Related issue number
Checks
scripts/format.sh
to lint the changes in this PR.Added unit tests to check the default ports, and to check if two consecutive calls would have different base_port + worker_id (for either default and user-defined ports).
Also tested using the rllib/examples/unity3d_env_local.py.