Skip to content

Commit

Permalink
Develop timeout (#5991)
Browse files Browse the repository at this point in the history
* Added timeout cli.

* Updated docs.

* Updated mlagents learn cli test.
  • Loading branch information
miguelalonsojr authored Oct 9, 2023
1 parent 6203c7e commit 8aa3c85
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ and this project adheres to
## [Unreleased]
### Major Changes
#### com.unity.ml-agents / com.unity.ml-agents.extensions (C#)
- Updated to PyTorch 1.13.1
- Deprecated support for Python 3.8.x and 3.9.x
- Upgraded ML-Agents to Sentis 1.2.0-exp.2 (#)
- The minimum supported Unity version was updated to 2022.3. (#)
- Added batched raycast sensor option. (#)

#### ml-agents / ml-agents-envs
- Updated to PyTorch 1.13.1
- Deprecated support for Python 3.8.x and 3.9.x

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

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

Expand Down
1 change: 1 addition & 0 deletions docs/Training-ML-Agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ env_settings:
env_args: null
base_port: 5005
num_envs: 1
timeout_wait: 10
seed: -1
max_lifetime_restarts: 10
restarts_rate_limit_n: 1
Expand Down
7 changes: 7 additions & 0 deletions ml-agents/mlagents/trainers/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ def _create_parser() -> argparse.ArgumentParser:
help="Results base directory",
)

argparser.add_argument(
"--timeout-wait",
default=60,
help="The period of time to wait on a Unity environment to startup for training.",
action=DetectDefault,
)

eng_conf = argparser.add_argument_group(title="Engine Configuration")
eng_conf.add_argument(
"--width",
Expand Down
3 changes: 3 additions & 0 deletions ml-agents/mlagents/trainers/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def run_training(run_seed: int, options: RunOptions, num_areas: int) -> None:
engine_settings.no_graphics,
run_seed,
num_areas,
env_settings.timeout_wait,
port,
env_settings.env_args,
os.path.abspath(run_logs_dir), # Unity environment requires absolute path
Expand Down Expand Up @@ -175,6 +176,7 @@ def create_environment_factory(
no_graphics: bool,
seed: int,
num_areas: int,
timeout_wait: int,
start_port: Optional[int],
env_args: Optional[List[str]],
log_folder: str,
Expand All @@ -194,6 +196,7 @@ def create_unity_environment(
additional_args=env_args,
side_channels=side_channels,
log_folder=log_folder,
timeout_wait=timeout_wait,
)

return create_unity_environment
Expand Down
1 change: 1 addition & 0 deletions ml-agents/mlagents/trainers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ class EnvironmentSettings:
base_port: int = parser.get_default("base_port")
num_envs: int = attr.ib(default=parser.get_default("num_envs"))
num_areas: int = attr.ib(default=parser.get_default("num_areas"))
timeout_wait: int = attr.ib(default=parser.get_default("timeout_wait"))
seed: int = parser.get_default("seed")
max_lifetime_restarts: int = parser.get_default("max_lifetime_restarts")
restarts_rate_limit_n: int = parser.get_default("restarts_rate_limit_n")
Expand Down
1 change: 1 addition & 0 deletions ml-agents/mlagents/trainers/tests/test_learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def test_bad_env_path():
no_graphics=True,
seed=-1,
num_areas=1,
timeout_wait=1,
start_port=8000,
env_args=None,
log_folder="results/log_folder",
Expand Down

0 comments on commit 8aa3c85

Please sign in to comment.