Skip to content

cleanup port logic in UnityEnvironment #3673

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

Merged
merged 3 commits into from
Mar 24, 2020
Merged

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Mar 23, 2020

Proposed change(s)

@awjuliani hit this a few weeks ago, and it came up in an issue today too. If no environment was specified, we would still default to port 5005, but we should be smart enough to use 5004 (the editor port) in this case.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

#3667
https://jira.unity3d.com/browse/MLA-709?

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@@ -193,7 +193,7 @@ messages to the Unity environment from Python using it.
string_log = StringLogChannel()

# We start the communication with the Unity Editor and pass the string_log side channel as input
env = UnityEnvironment(base_port=UnityEnvironment.DEFAULT_EDITOR_PORT, side_channels=[string_log])
env = UnityEnvironment(side_channels=[string_log])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these should now do the correct thing, I removed the explicit port (for simplicity and future-proofing) wherever I found it in the docs.

@@ -8,8 +8,8 @@ def __init__(self, worker_id=0, base_port=5005):
"""
Python side of the communication. Must be used in pair with the right Unity Communicator equivalent.

:int worker_id: Offset from base_port. Used for training multiple environments simultaneously.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rearranged to match the argument order. I think I changed the wording of this wherever I saw it (git blame showed it was 3 years old).

Copy link
Contributor

@awjuliani awjuliani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@chriselion chriselion merged commit 1dbe507 into master Mar 24, 2020
@delete-merged-branch delete-merged-branch bot deleted the MLA-709-default-port branch March 24, 2020 03:48
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants