Skip to content

Commit 8aa3c85

Browse files
Develop timeout (#5991)
* Added timeout cli. * Updated docs. * Updated mlagents learn cli test.
1 parent 6203c7e commit 8aa3c85

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

com.unity.ml-agents/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@ and this project adheres to
99
## [Unreleased]
1010
### Major Changes
1111
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
12-
- Updated to PyTorch 1.13.1
13-
- Deprecated support for Python 3.8.x and 3.9.x
1412
- Upgraded ML-Agents to Sentis 1.2.0-exp.2 (#)
1513
- The minimum supported Unity version was updated to 2022.3. (#)
1614
- Added batched raycast sensor option. (#)
1715

1816
#### ml-agents / ml-agents-envs
17+
- Updated to PyTorch 1.13.1
18+
- Deprecated support for Python 3.8.x and 3.9.x
1919

2020
### Minor Changes
2121
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
2222
- Added DecisionStep parameter to DecisionRequester (#)
2323
- This will allow the staggering of execution timing when using multi-agents, leading to more stable performance.
2424

2525
#### ml-agents / ml-agents-envs
26+
- Added timeout cli and yaml config file support for specifying environment timeout.
2627
- Added training config feature to evenly distribute checkpoints throughout training. (#5842)
2728
- Updated training area replicator to add a condition to only replicate training areas when running a build. (#5842)
2829

docs/Training-ML-Agents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ env_settings:
213213
env_args: null
214214
base_port: 5005
215215
num_envs: 1
216+
timeout_wait: 10
216217
seed: -1
217218
max_lifetime_restarts: 10
218219
restarts_rate_limit_n: 1

ml-agents/mlagents/trainers/cli_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ def _create_parser() -> argparse.ArgumentParser:
233233
help="Results base directory",
234234
)
235235

236+
argparser.add_argument(
237+
"--timeout-wait",
238+
default=60,
239+
help="The period of time to wait on a Unity environment to startup for training.",
240+
action=DetectDefault,
241+
)
242+
236243
eng_conf = argparser.add_argument_group(title="Engine Configuration")
237244
eng_conf.add_argument(
238245
"--width",

ml-agents/mlagents/trainers/learn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def run_training(run_seed: int, options: RunOptions, num_areas: int) -> None:
101101
engine_settings.no_graphics,
102102
run_seed,
103103
num_areas,
104+
env_settings.timeout_wait,
104105
port,
105106
env_settings.env_args,
106107
os.path.abspath(run_logs_dir), # Unity environment requires absolute path
@@ -175,6 +176,7 @@ def create_environment_factory(
175176
no_graphics: bool,
176177
seed: int,
177178
num_areas: int,
179+
timeout_wait: int,
178180
start_port: Optional[int],
179181
env_args: Optional[List[str]],
180182
log_folder: str,
@@ -194,6 +196,7 @@ def create_unity_environment(
194196
additional_args=env_args,
195197
side_channels=side_channels,
196198
log_folder=log_folder,
199+
timeout_wait=timeout_wait,
197200
)
198201

199202
return create_unity_environment

ml-agents/mlagents/trainers/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,7 @@ class EnvironmentSettings:
817817
base_port: int = parser.get_default("base_port")
818818
num_envs: int = attr.ib(default=parser.get_default("num_envs"))
819819
num_areas: int = attr.ib(default=parser.get_default("num_areas"))
820+
timeout_wait: int = attr.ib(default=parser.get_default("timeout_wait"))
820821
seed: int = parser.get_default("seed")
821822
max_lifetime_restarts: int = parser.get_default("max_lifetime_restarts")
822823
restarts_rate_limit_n: int = parser.get_default("restarts_rate_limit_n")

ml-agents/mlagents/trainers/tests/test_learn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def test_bad_env_path():
105105
no_graphics=True,
106106
seed=-1,
107107
num_areas=1,
108+
timeout_wait=1,
108109
start_port=8000,
109110
env_args=None,
110111
log_folder="results/log_folder",

0 commit comments

Comments
 (0)