Skip to content

Release v0.8 #1931

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 45 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d362adb
Add a script to record videos every X seconds or academy steps (#1414)
LeSphax Feb 12, 2019
c050705
Add timeout wait param (Develop) (#1700)
awjuliani Feb 19, 2019
8761fc3
Add back 'get_communicator' in UnityEnvironment
harper-u3d Feb 20, 2019
e0c7da3
Move 'take_action' into Policy class (#1669)
Feb 25, 2019
470a9d2
Develop windows install instructions update (#1760)
dmalpica Feb 26, 2019
e54f3e8
Merge pull request #1765 from Unity-Technologies/release-v0.7
vincentpierre Feb 28, 2019
2400e7b
Fixup link
mvuksano Feb 28, 2019
06e2188
Merge pull request #1771 from markovuksanovic/patch-2
eshvk Mar 5, 2019
96cac6c
Add line to describe what Branch Descriptions is (#1772)
rafvasq Mar 5, 2019
361bb90
Fix for Brains not reinitialising when the scene is reloaded. (#1758)
tkggwatson Mar 13, 2019
fabc14f
Refactor RayPerception and add RayPerception2D (#1793)
awjuliani Mar 13, 2019
aeeaaad
Optimisation - Removed a lot of garbage allocation (#1804)
tkggwatson Mar 19, 2019
2c4a493
Develop codacy test (#1667)
xiaomaogy Mar 22, 2019
0f54267
Add doc about AVX support (#1865)
awjuliani Mar 25, 2019
adfd705
Fixed compilation under Scripting API compatibility level ".NET Stand…
mantasp Mar 28, 2019
c4c35c6
API for sending custom protobuf messages to and from Unity. (#1595)
malmaud Mar 28, 2019
425fad1
Update BrainParametersDrawer.cs (#1840)
rafvasq Mar 28, 2019
6bdcbfc
Fix typos in Gym Wrapper README.md (#1823)
supercurious Mar 28, 2019
74ae0ea
External Contribution: Use RenderTexture instead of Camera for Visual…
Mar 28, 2019
b1d7ac5
Split `mlagents` into two packages (#1812)
awjuliani Apr 1, 2019
5a5246a
Update to documentation (#1872)
vincentpierre Apr 1, 2019
296944e
Adding instructions to Basic Guide for Running in Python (#1725)
borisneal Apr 1, 2019
4849ef0
Added logging per Brain of time to update policy, time elapsed during…
eshvk Mar 1, 2019
b89bb0f
Reorganize to make metrics collection more accurate
eshvk Mar 29, 2019
69b223c
Merge pull request #1858 from Unity-Technologies/develop-esh-metrics
eshvk Apr 3, 2019
e59eff4
Adds SubprocessUnityEnvironment for parallel envs (#1751)
Apr 3, 2019
51f82fd
Soccer Twos - Fixes missing tag change, plus code cleanup (#1813)
awjuliani Apr 3, 2019
2d8300f
* Ticked API :
eshvk Apr 3, 2019
a547892
Included TFS page to redirect (#1893)
shihzy Apr 4, 2019
9aa47db
Install dependencies for ml-agents-envs and ml-agents in Docker (#1895)
eshvk Apr 4, 2019
a2aa7a2
Add documentation for new multi-env CLI flags
harper-u3d Apr 5, 2019
3902463
Fix not saving .nn file after max_timesteps (#1896)
Apr 8, 2019
8ee84fe
Fix environment factory pickling on Windows (#1912)
Apr 9, 2019
d2ad6e8
Fix parallel writes to UnitySDK.log on Windows
Apr 9, 2019
15fcf95
Fix subprocess model saving on Windows
Apr 8, 2019
35d6706
Fix '--slow' flag after environment updates
Apr 11, 2019
2e945ba
Release v0.8 docs (#1924)
shihzy Apr 12, 2019
30a5738
Merge pull request #1922 from Unity-Technologies/release-v08-slowflag
eshvk Apr 12, 2019
d6e05c3
Updated all the scenes’s model and the bouncer’s expected reward
xiaomaogy Apr 12, 2019
caa9290
Merge pull request #1928 from Unity-Technologies/release-v0.8-model-u…
eshvk Apr 12, 2019
bb22226
Updated the 3dballhard model
xiaomaogy Apr 12, 2019
b02cd29
Basic Retrain (#1929)
eshvk Apr 12, 2019
b9a9bf5
Merge pull request #1930 from Unity-Technologies/release-v0.8-model-u…
eshvk Apr 12, 2019
86c4574
Migration doc fixes
eshvk Apr 12, 2019
ad97e16
Merge pull request #1933 from Unity-Technologies/release-v0.8-fix
eshvk Apr 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix subprocess model saving on Windows
On Windows the interrupt for subprocesses works in a different
way from OSX/Linux. The result is that child subprocesses and
their pipes may close while the parent process is still running
during a keyboard (ctrl+C) interrupt.

To handle this, this change adds handling for EOFError and
BrokenPipeError exceptions when interacting with subprocess
environments. Additional management is also added to be sure
when using parallel runs using the "num-runs" option that
the threads for each run are joined and KeyboardInterrupts are
handled.

These changes made the "_win_handler" we used to specially
manage interrupts on Windows unnecessary, so they have been
removed.
  • Loading branch information
Jonathan Harper committed Apr 10, 2019
commit 15fcf95f86c837facb39b03381f9e379449f3d18
21 changes: 15 additions & 6 deletions ml-agents-envs/mlagents/envs/subprocess_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,24 @@ class UnityEnvWorker(NamedTuple):
conn: Connection

def send(self, name: str, payload=None):
cmd = EnvironmentCommand(name, payload)
self.conn.send(cmd)
try:
cmd = EnvironmentCommand(name, payload)
self.conn.send(cmd)
except (BrokenPipeError, EOFError):
raise KeyboardInterrupt

def recv(self) -> EnvironmentResponse:
response: EnvironmentResponse = self.conn.recv()
return response
try:
response: EnvironmentResponse = self.conn.recv()
return response
except (BrokenPipeError, EOFError):
raise KeyboardInterrupt

def close(self):
self.conn.send(EnvironmentCommand("close"))
try:
self.conn.send(EnvironmentCommand('close'))
except (BrokenPipeError, EOFError):
pass
self.process.join()


Expand Down Expand Up @@ -87,10 +96,10 @@ def create_worker(
env_factory: Callable[[int], BaseUnityEnvironment]
) -> UnityEnvWorker:
parent_conn, child_conn = Pipe()

# Need to use cloudpickle for the env factory function since function objects aren't picklable
# on Windows as of Python 3.6.
pickled_env_factory = cloudpickle.dumps(env_factory)

child_process = Process(target=worker, args=(child_conn, pickled_env_factory, worker_id))
child_process.start()
return UnityEnvWorker(child_process, worker_id, parent_conn)
Expand Down
15 changes: 12 additions & 3 deletions ml-agents/mlagents/trainers/learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def run_training(sub_id: int, run_seed: int, run_options, process_queue):
trainer_config_path = run_options['<trainer-config-path>']
# Recognize and use docker volume if one is passed as an argument
if not docker_target_name:
model_path = './models/{run_id}'.format(run_id=run_id)
model_path = './models/{run_id}-{sub_id}'.format(run_id=run_id, sub_id=sub_id)
summaries_dir = './summaries'
else:
trainer_config_path = \
Expand All @@ -63,9 +63,10 @@ def run_training(sub_id: int, run_seed: int, run_options, process_queue):
'/{docker_target_name}/{curriculum_folder}'.format(
docker_target_name=docker_target_name,
curriculum_folder=curriculum_folder)
model_path = '/{docker_target_name}/models/{run_id}'.format(
model_path = '/{docker_target_name}/models/{run_id}-{sub_id}'.format(
docker_target_name=docker_target_name,
run_id=run_id)
run_id=run_id,
sub_id=sub_id)
summaries_dir = '/{docker_target_name}/summaries'.format(
docker_target_name=docker_target_name)

Expand Down Expand Up @@ -274,6 +275,14 @@ def main():
while process_queue.get() is not True:
continue

# Wait for jobs to complete. Otherwise we'll have an extra
# unhandled KeyboardInterrupt if we end early.
try:
for job in jobs:
job.join()
except KeyboardInterrupt:
pass

# For python debugger to directly run this script
if __name__ == "__main__":
main()
4 changes: 2 additions & 2 deletions ml-agents/mlagents/trainers/tests/test_learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_run_training(load_config, create_environment_factory, subproc_env_mock)
with patch.object(TrainerController, "start_learning", MagicMock()):
learn.run_training(0, 0, basic_options(), MagicMock())
mock_init.assert_called_once_with(
'./models/ppo',
'./models/ppo-0',
'./summaries',
'ppo-0',
50000,
Expand Down Expand Up @@ -74,5 +74,5 @@ def test_docker_target_path(load_config, create_environment_factory, subproc_env
with patch.object(TrainerController, "start_learning", MagicMock()):
learn.run_training(0, 0, options_with_docker_target, MagicMock())
mock_init.assert_called_once()
assert(mock_init.call_args[0][0] == '/dockertarget/models/ppo')
assert(mock_init.call_args[0][0] == '/dockertarget/models/ppo-0')
assert(mock_init.call_args[0][1] == '/dockertarget/summaries')
18 changes: 0 additions & 18 deletions ml-agents/mlagents/trainers/trainer_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import logging
import shutil
import sys
if sys.platform.startswith('win'):
import win32api
import win32con
from typing import *

import numpy as np
Expand Down Expand Up @@ -104,18 +101,6 @@ def _save_model_when_interrupted(self, steps=0):
'while the graph is generated.')
self._save_model(steps)

def _win_handler(self, event):
"""
This function gets triggered after ctrl-c or ctrl-break is pressed
under Windows platform.
"""
if event in (win32con.CTRL_C_EVENT, win32con.CTRL_BREAK_EVENT):
self._save_model_when_interrupted(self.global_step)
self._export_graph()
sys.exit()
return True
return False

def _write_training_metrics(self):
"""
Write all CSV metrics
Expand Down Expand Up @@ -223,9 +208,6 @@ def start_learning(self, env: BaseUnityEnvironment, trainer_config):
for brain_name, trainer in self.trainers.items():
trainer.write_tensorboard_text('Hyperparameters',
trainer.parameters)
if sys.platform.startswith('win'):
# Add the _win_handler function to the windows console's handler function list
win32api.SetConsoleCtrlHandler(self._win_handler, True)
try:
curr_info = self._reset_env(env)
while any([t.get_step <= t.get_max_steps \
Expand Down