Skip to content

Commit bc90240

Browse files
surfnerdsini
authored andcommitted
Fix Mac backcompat test (#5519)
1 parent cdc2313 commit bc90240

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

.yamato/training-backcompat-tests.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

2-
test_mac_backcompat_2020.1:
3-
{% capture editor_version %}2020.1{% endcapture %}
2+
test_mac_backcompat_2019.4:
3+
{% capture editor_version %}2019.4{% endcapture %}
44
{% capture csharp_backcompat_version %}1.0.0{% endcapture %}
55
# This test has to run on mac because it requires the custom build of tensorflow without AVX
66
# Test against 2020.1 because 2020.2 has to run against package version 1.2.0
77
name: Test Mac Backcompat Training {{ editor_version }}
88
agent:
99
type: Unity::VM::osx
10-
image: ml-agents/ml-agents-bokken-mac:0.1.4-492264
10+
image: ml-agents/ml-agents-bokken-mac:0.1.5-853758
1111
flavor: b1.small
1212
variables:
1313
UNITY_VERSION: {{ editor_version }}
1414
commands:
1515
- |
16-
python3 -m venv venv && source venv/bin/activate
16+
python -m venv venv && source venv/bin/activate
1717
python -m pip install pyyaml --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
1818
python -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
1919
unity-downloader-cli -u {{ editor_version }} -c editor --wait --fast
@@ -23,9 +23,9 @@ test_mac_backcompat_2020.1:
2323
python -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=mac
2424
python -u -m ml-agents.tests.yamato.training_int_tests --csharp {{ csharp_backcompat_version }}
2525
- |
26-
python3 -m venv venv_old && source venv_old/bin/activate
26+
python -m venv venv_old && source venv_old/bin/activate
2727
python -m pip install pyyaml --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
28-
python -u -m ml-agents.tests.yamato.training_int_tests --python 0.16.0
28+
python -u -m ml-agents.tests.yamato.training_int_tests --python 0.24.0
2929
triggers:
3030
cancel_old_ci: true
3131
recurring:

com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ out input
141141
Debug.Log($"Unexpected exception when trying to initialize communication: {ex}");
142142
}
143143
initParametersOut = new UnityRLInitParameters();
144-
m_Channel.ShutdownAsync().Wait();
144+
NotifyQuitAndShutDownChannel();
145145
return false;
146146
}
147147

@@ -241,7 +241,14 @@ UnityInputProto Initialize(int port, UnityOutputProto unityOutput, out UnityInpu
241241
void NotifyQuitAndShutDownChannel()
242242
{
243243
QuitCommandReceived?.Invoke();
244-
m_Channel.ShutdownAsync().Wait();
244+
try
245+
{
246+
m_Channel.ShutdownAsync().Wait();
247+
}
248+
catch (Exception)
249+
{
250+
// do nothing
251+
}
245252
}
246253

247254
#endregion

ml-agents/tests/yamato/training_int_tests.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import sys
66
import subprocess
77
import time
8-
from typing import Any
98

109
from .yamato_utils import (
1110
find_executables,
@@ -14,7 +13,6 @@
1413
run_standalone_build,
1514
init_venv,
1615
override_config_file,
17-
override_legacy_config_file,
1816
checkout_csharp_version,
1917
undo_git_checkout,
2018
)
@@ -26,7 +24,7 @@ def run_training(python_version: str, csharp_version: str) -> bool:
2624
print(
2725
f"Running training with python={python_version or latest} and c#={csharp_version or latest}"
2826
)
29-
output_dir = "models" if python_version else "results"
27+
output_dir = "results"
3028
onnx_file_expected = f"./{output_dir}/{run_id}/3DBall.onnx"
3129

3230
if os.path.exists(onnx_file_expected):
@@ -70,17 +68,11 @@ def run_training(python_version: str, csharp_version: str) -> bool:
7068
# Copy the default training config but override the max_steps parameter,
7169
# and reduce the batch_size and buffer_size enough to ensure an update step happens.
7270
yaml_out = "override.yaml"
73-
if python_version:
74-
overrides: Any = {"max_steps": 100, "batch_size": 10, "buffer_size": 10}
75-
override_legacy_config_file(
76-
python_version, "config/trainer_config.yaml", yaml_out, **overrides
77-
)
78-
else:
79-
overrides = {
80-
"hyperparameters": {"batch_size": 10, "buffer_size": 10},
81-
"max_steps": 100,
82-
}
83-
override_config_file("config/ppo/3DBall.yaml", yaml_out, overrides)
71+
overrides = {
72+
"hyperparameters": {"batch_size": 10, "buffer_size": 10},
73+
"max_steps": 100,
74+
}
75+
override_config_file("config/ppo/3DBall.yaml", yaml_out, overrides)
8476

8577
log_output_path = f"{get_base_output_path()}/training.log"
8678
env_path = os.path.join(get_base_output_path(), standalone_player_path)

ml-agents/tests/yamato/yamato_utils.py

-3
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,10 @@ def init_venv(
134134
pip_commands = ["--upgrade pip", "--upgrade setuptools"]
135135
if mlagents_python_version:
136136
# install from pypi
137-
if platform != "darwin":
138-
raise RuntimeError("Yamato can only run tensorflow on mac platforms!")
139137
pip_commands += [
140138
f"mlagents=={mlagents_python_version}",
141139
f"gym-unity=={mlagents_python_version}",
142140
# TODO build these and publish to internal pypi
143-
"~/tensorflow_pkg/tensorflow-2.0.0-cp37-cp37m-macosx_10_14_x86_64.whl",
144141
"tf2onnx==1.6.1",
145142
]
146143
else:

0 commit comments

Comments
 (0)