Skip to content

Commit 080afe3

Browse files
author
Chris Elion
authored
Rename --port commandline arg to --mlagents-port (#3477)
1 parent fbcdd83 commit 080afe3

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

com.unity.ml-agents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2020
- The stepping logic for the Agent and the Academy has been simplified (#3448)
2121
- Update Barracuda to 0.6.0-preview
2222
- The checkpoint file suffix was changed from `.cptk` to `.ckpt` (#3470)
23+
- The command-line argument used to determine the port that an environment will listen on was changed from `--port` to `--mlagents-port`.
2324
- The method `GetStepCount()` on the Agent class has been replaced with the property getter `StepCount`
2425

2526
### Bugfixes

com.unity.ml-agents/Runtime/Academy.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class Academy : IDisposable
5151
{
5252
const string k_ApiVersion = "API-15-dev0";
5353
const int k_EditorTrainingPort = 5004;
54+
internal const string k_portCommandLineFlag = "--mlagents-port";
5455

5556
// Lazy initializer pattern, see https://csharpindepth.com/articles/singleton#lazy
5657
static Lazy<Academy> s_Lazy = new Lazy<Academy>(() => new Academy());
@@ -113,7 +114,7 @@ public bool IsCommunicatorOn
113114
// Signals to all the listeners that the academy is being destroyed
114115
internal event Action DestroyAction;
115116

116-
// Signals the Agent that a new step is about to start.
117+
// Signals the Agent that a new step is about to start.
117118
// This will mark the Agent as Done if it has reached its maxSteps.
118119
internal event Action AgentIncrementStep;
119120

@@ -255,7 +256,7 @@ static int ReadPortFromArgs()
255256
var inputPort = "";
256257
for (var i = 0; i < args.Length; i++)
257258
{
258-
if (args[i] == "--port")
259+
if (args[i] == k_portCommandLineFlag)
259260
{
260261
inputPort = args[i + 1];
261262
}

ml-agents-envs/mlagents_envs/environment.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class UnityEnvironment(BaseEnv):
5454
SINGLE_BRAIN_ACTION_TYPES = SCALAR_ACTION_TYPES + (list, np.ndarray)
5555
API_VERSION = "API-15-dev0"
5656
DEFAULT_EDITOR_PORT = 5004
57+
PORT_COMMAND_LINE_ARG = "--mlagents-port"
5758

5859
def __init__(
5960
self,
@@ -212,7 +213,10 @@ def executable_launcher(self, file_name, docker_training, no_graphics, args):
212213
subprocess_args = [launch_string]
213214
if no_graphics:
214215
subprocess_args += ["-nographics", "-batchmode"]
215-
subprocess_args += ["--port", str(self.port)]
216+
subprocess_args += [
217+
UnityEnvironment.PORT_COMMAND_LINE_ARG,
218+
str(self.port),
219+
]
216220
subprocess_args += args
217221
try:
218222
self.proc1 = subprocess.Popen(
@@ -250,10 +254,10 @@ def executable_launcher(self, file_name, docker_training, no_graphics, args):
250254
# we created with `xvfb`.
251255
#
252256
docker_ls = (
253-
"exec xvfb-run --auto-servernum"
254-
" --server-args='-screen 0 640x480x24'"
255-
" {0} --port {1}"
256-
).format(launch_string, str(self.port))
257+
f"exec xvfb-run --auto-servernum --server-args='-screen 0 640x480x24'"
258+
f" {launch_string} {UnityEnvironment.PORT_COMMAND_LINE_ARG} {self.port}"
259+
)
260+
257261
self.proc1 = subprocess.Popen(
258262
docker_ls,
259263
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)