Skip to content

Commit 7cce739

Browse files
committed
Fix Mac backcompat test (#5519)
1 parent d96398d commit 7cce739

File tree

4 files changed

+65
-11
lines changed

4 files changed

+65
-11
lines changed

.yamato/training-backcompat-tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
test_mac_backcompat_2019.4:
3+
{% capture editor_version %}2019.4{% endcapture %}
4+
{% capture csharp_backcompat_version %}1.0.0{% endcapture %}
5+
# This test has to run on mac because it requires the custom build of tensorflow without AVX
6+
# Test against 2020.1 because 2020.2 has to run against package version 1.2.0
7+
name: Test Mac Backcompat Training {{ editor_version }}
8+
agent:
9+
type: Unity::VM::osx
10+
image: ml-agents/ml-agents-bokken-mac:0.1.5-853758
11+
flavor: b1.small
12+
variables:
13+
UNITY_VERSION: {{ editor_version }}
14+
commands:
15+
- |
16+
python -m venv venv && source venv/bin/activate
17+
python -m pip install pyyaml --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
18+
python -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
19+
unity-downloader-cli -u {{ editor_version }} -c editor --wait --fast
20+
# Backwards-compatibility tests.
21+
# If we make a breaking change to the communication protocol, these will need
22+
# to be disabled until the next release.
23+
python -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=mac
24+
python -u -m ml-agents.tests.yamato.training_int_tests --csharp {{ csharp_backcompat_version }}
25+
- |
26+
python -m venv venv_old && source venv_old/bin/activate
27+
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.24.0
29+
triggers:
30+
cancel_old_ci: true
31+
recurring:
32+
- branch: main
33+
frequency: daily
34+
artifacts:
35+
logs:
36+
paths:
37+
- "artifacts/standalone_build.txt"
38+
- "artifacts/inference.nn.txt"
39+
- "artifacts/inference.onnx.txt"
40+
- "artifacts/*.log"
41+
standalonebuild:
42+
paths:
43+
- "artifacts/testPlayer*/**"
44+
- "artifacts/models/**"

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public UnityRLInitParameters Initialize(CommunicatorInitParameters initParameter
233233
throw new UnityAgentsException("Incompatible trainer version.");
234234
}
235235
initParametersOut = new UnityRLInitParameters();
236-
m_Channel.ShutdownAsync().Wait();
236+
NotifyQuitAndShutDownChannel();
237237
return false;
238238
}
239239

@@ -331,7 +331,14 @@ UnityInputProto Initialize(UnityOutputProto unityOutput,
331331
void NotifyQuitAndShutDownChannel()
332332
{
333333
QuitCommandReceived?.Invoke();
334-
m_Channel.ShutdownAsync().Wait();
334+
try
335+
{
336+
m_Channel.ShutdownAsync().Wait();
337+
}
338+
catch (Exception)
339+
{
340+
// do nothing
341+
}
335342
}
336343

337344
#endregion

ml-agents/tests/yamato/training_int_tests.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def run_training(python_version, csharp_version):
2121
print(
2222
f"Running training with python={python_version or latest} and c#={csharp_version or latest}"
2323
)
24-
nn_file_expected = f"./models/{run_id}/3DBall.nn"
25-
if os.path.exists(nn_file_expected):
24+
output_dir = "results"
25+
onnx_file_expected = f"./{output_dir}/{run_id}/3DBall.onnx"
26+
27+
if os.path.exists(onnx_file_expected):
2628
# Should never happen - make sure nothing leftover from an old test.
2729
print("Artifacts from previous build found!")
2830
sys.exit(1)
@@ -62,13 +64,12 @@ def run_training(python_version, csharp_version):
6264

6365
# Copy the default training config but override the max_steps parameter,
6466
# and reduce the batch_size and buffer_size enough to ensure an update step happens.
65-
override_config_file(
66-
"config/trainer_config.yaml",
67-
"override.yaml",
68-
max_steps=100,
69-
batch_size=10,
70-
buffer_size=10,
71-
)
67+
yaml_out = "override.yaml"
68+
overrides = {
69+
"hyperparameters": {"batch_size": 10, "buffer_size": 10},
70+
"max_steps": 100,
71+
}
72+
override_config_file("config/ppo/3DBall.yaml", yaml_out, overrides)
7273

7374
mla_learn_cmd = (
7475
f"mlagents-learn override.yaml --train --env="

ml-agents/tests/yamato/yamato_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ def init_venv(
109109
pip_commands += [
110110
f"mlagents=={mlagents_python_version}",
111111
f"gym-unity=={mlagents_python_version}",
112+
# TODO build these and publish to internal pypi
113+
"tf2onnx==1.6.1",
112114
]
113115
else:
114116
# Local install

0 commit comments

Comments
 (0)