Skip to content

Commit 9093939

Browse files
author
Chris Elion
authored
Update v2-staging from main (March 15) (#5123)
1 parent edd3a5a commit 9093939

File tree

400 files changed

+10270
-45915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+10270
-45915
lines changed

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ jobs:
1919
- uses: actions/setup-dotnet@v1
2020
with:
2121
dotnet-version: '3.1.x'
22-
- run: dotnet tool install -g dotnet-format --version 4.1.131201
2322
- uses: pre-commit/action@v2.0.0
2423

2524
markdown-link-check:

.github/workflows/pytest.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ jobs:
1919
TEST_ENFORCE_BUFFER_KEY_TYPES: 1
2020
strategy:
2121
matrix:
22-
python-version: [3.6.x, 3.7.x, 3.8.x]
22+
python-version: [3.6.x, 3.7.x, 3.8.x, 3.9.x]
23+
include:
24+
- python-version: 3.6.x
25+
pip_constraints: test_constraints_min_version.txt
26+
- python-version: 3.7.x
27+
pip_constraints: test_constraints_mid_version.txt
28+
- python-version: 3.8.x
29+
pip_constraints: test_constraints_mid_version.txt
30+
- python-version: 3.9.x
31+
pip_constraints: test_constraints_max_version.txt
2332
steps:
2433
- uses: actions/checkout@v2
2534
- name: Set up Python
@@ -32,7 +41,7 @@ jobs:
3241
# This path is specific to Ubuntu
3342
path: ~/.cache/pip
3443
# Look to see if there is a cache hit for the corresponding requirements file
35-
key: ${{ runner.os }}-pip-${{ hashFiles('ml-agents/setup.py', 'ml-agents-envs/setup.py', 'gym-unity/setup.py', 'test_requirements.txt') }}
44+
key: ${{ runner.os }}-pip-${{ hashFiles('ml-agents/setup.py', 'ml-agents-envs/setup.py', 'gym-unity/setup.py', 'test_requirements.txt', matrix.pip_constraints) }}
3645
restore-keys: |
3746
${{ runner.os }}-pip-
3847
${{ runner.os }}-
@@ -42,11 +51,11 @@ jobs:
4251
run: |
4352
python -m pip install --upgrade pip
4453
python -m pip install --upgrade setuptools
45-
python -m pip install --progress-bar=off -e ./ml-agents-envs
46-
python -m pip install --progress-bar=off -e ./ml-agents
47-
python -m pip install --progress-bar=off -r test_requirements.txt
48-
python -m pip install --progress-bar=off -e ./gym-unity
49-
python -m pip install --progress-bar=off -e ./ml-agents-plugin-examples
54+
python -m pip install --progress-bar=off -e ./ml-agents-envs -c ${{ matrix.pip_constraints }}
55+
python -m pip install --progress-bar=off -e ./ml-agents -c ${{ matrix.pip_constraints }}
56+
python -m pip install --progress-bar=off -r test_requirements.txt -c ${{ matrix.pip_constraints }}
57+
python -m pip install --progress-bar=off -e ./gym-unity -c ${{ matrix.pip_constraints }}
58+
python -m pip install --progress-bar=off -e ./ml-agents-plugin-examples -c ${{ matrix.pip_constraints }}
5059
- name: Save python dependencies
5160
run: |
5261
pip freeze > pip_versions-${{ matrix.python-version }}.txt

.pre-commit-config.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ repos:
8383
types: [markdown]
8484
exclude: ".*localized.*"
8585

86+
- repo: https://github.com/dotnet/format
87+
rev: "7e343070a0355c86f72bdee226b5e19ffcbac931" # TODO - update to a tagged version when one that includes the hook is ready.
88+
hooks:
89+
- id: dotnet-format
90+
args: [--folder, --include]
91+
8692
# "Local" hooks, see https://pre-commit.com/#repository-local-hooks
8793
- repo: local
8894
hooks:
@@ -119,4 +125,3 @@ repos:
119125
name: validate release links
120126
language: script
121127
entry: utils/validate_release_links.py
122-
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
OptionalDependencyTestsLinux:
2+
name : LinuxOptionalDependenciesTests
3+
agent:
4+
type: Unity::VM
5+
image: package-ci/ubuntu:stable
6+
flavor: b1.medium
7+
commands:
8+
- |
9+
curl -L https://artifactory.prd.it.unity3d.com/artifactory/api/gpg/key/public | sudo apt-key add -
10+
sudo sh -c "echo 'deb https://artifactory.prd.it.unity3d.com/artifactory/unity-apt-local bionic main' > /etc/apt/sources.list.d/unity.list"
11+
sudo apt update
12+
sudo apt install -y unity-config
13+
npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
14+
unity-config settings editor-path ./.Editor
15+
unity-config project create opt-deps-test
16+
unity-config project add dependency com.unity.ml-agents/
17+
unity-config project add testable com.unity.ml-agents
18+
unity-config project add dependency com.unity.modules.imageconversion@1.0.0
19+
unity-config project add dependency com.unity.modules.jsonserialize@1.0.0
20+
unity-config project add dependency com.unity.modules.physics@1.0.0
21+
unity-config project add dependency com.unity.modules.physics2d@1.0.0
22+
upm-ci project test -u 2019.4 --type project-tests --project-path opt-deps-test --package-filter com.unity.ml-agents
23+
artifacts:
24+
logs:
25+
paths:
26+
- "upm-ci~/test-results/**/*"
27+
dependencies:
28+
- .yamato/com.unity.ml-agents-pack.yml#pack
29+
triggers:
30+
cancel_old_ci: true
31+
expression: |
32+
(pull_request.target eq "main" OR
33+
pull_request.target match "release.+") AND
34+
NOT pull_request.draft AND
35+
(pull_request.changes.any match "com.unity.ml-agents/**" OR
36+
pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml")
37+

.yamato/com.unity.ml-agents-pack.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ pack:
55
image: package-ci/ubuntu:stable
66
flavor: b1.small
77
commands:
8-
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
9-
- upm-ci project pack --project-path Project
8+
- |
9+
python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade
10+
unity-downloader-cli -u 2018.4 -c editor --wait --fast
11+
./.Editor/Unity -projectPath Project -batchMode -executeMethod Unity.MLAgents.SampleExporter.ExportCuratedSamples -logFile -
12+
npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
13+
upm-ci project pack --project-path Project
1014
artifacts:
1115
packages:
1216
paths:

.yamato/com.unity.ml-agents-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,4 @@ test_{{ package.name }}_{{ platform.name }}_trunk:
150150
{% endfor %}
151151
{% endfor %}
152152
{% endfor %}
153+

.yamato/python-ll-api-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test_linux_ll_api_{{ editor.version }}:
1818
python ml-agents/tests/yamato/scripts/run_llapi.py
1919
python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-Basic
2020
python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-WallJump
21-
python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-Bouncer
21+
python ml-agents/tests/yamato/scripts/run_llapi.py --env=artifacts/testPlayer-Match3
2222
dependencies:
2323
- .yamato/standalone-build-test.yml#test_linux_standalone_{{ editor.version }}
2424
triggers:

.yamato/standalone-build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test_linux_standalone_{{ editor.version }}:
1515
- unity-downloader-cli -u {{ editor.version }} -c editor --wait --fast
1616
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux
1717
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux --scene=Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity
18-
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux --scene=Assets/ML-Agents/Examples/Bouncer/Scenes/Bouncer.unity
18+
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux --scene=Assets/ML-Agents/Examples/Match3/Scenes/Match3.unity
1919
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux --scene=Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity
2020
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux --scene=Assets/ML-Agents/TestScenes/TestCompressedGrid/TestGridCompressed.unity
2121
- python3 -u -m ml-agents.tests.yamato.standalone_build_tests --build-target=linux --scene=Assets/ML-Agents/TestScenes/TestCompressedTexture/TestTextureCompressed.unity

DevProject/Packages/packages-lock.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates"
3232
},
3333
"com.unity.barracuda": {
34-
"version": "1.3.0-preview",
34+
"version": "1.3.1-preview",
3535
"depth": 1,
3636
"source": "registry",
3737
"dependencies": {
@@ -108,7 +108,7 @@
108108
"depth": 0,
109109
"source": "local",
110110
"dependencies": {
111-
"com.unity.barracuda": "1.3.0-preview",
111+
"com.unity.barracuda": "1.3.1-preview",
112112
"com.unity.modules.imageconversion": "1.0.0",
113113
"com.unity.modules.jsonserialize": "1.0.0",
114114
"com.unity.modules.physics": "1.0.0",
@@ -121,7 +121,7 @@
121121
"depth": 0,
122122
"source": "local",
123123
"dependencies": {
124-
"com.unity.ml-agents": "1.7.2-preview"
124+
"com.unity.ml-agents": "1.8.0-preview"
125125
}
126126
},
127127
"com.unity.multiplayer-hlapi": {
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using Newtonsoft.Json;
5+
using UnityEditor;
6+
using UnityEngine;
7+
8+
namespace Unity.MLAgents
9+
{
10+
public class SampleExporter
11+
{
12+
const string k_MLAgentsSampleFile = "mlagents-sample.json";
13+
const string k_PackageSampleFile = ".sample.json";
14+
const string k_MLAgentsDir = "ML-Agents";
15+
const string k_MLAgentsExamplesDir = "Examples";
16+
const string k_MLAgentsPackageName = "com.unity.ml-agents";
17+
const string k_MLAgentsSamplesDirName = "Samples";
18+
const string k_MLAgentsScriptsDirName = "Scripts";
19+
20+
struct MLAgentsSampleJson
21+
{
22+
#pragma warning disable 649
23+
public string displayName;
24+
public string description;
25+
// ReSharper disable once CollectionNeverUpdated.Local
26+
public List<string> scenes;
27+
#pragma warning restore 649
28+
}
29+
30+
struct PackageSampleJson
31+
{
32+
public string displayName;
33+
public string description;
34+
}
35+
36+
public static void ExportCuratedSamples()
37+
{
38+
var oldBurst = EditorPrefs.GetBool("BurstCompilation");
39+
EditorPrefs.SetBool("BurstCompilation", false);
40+
try
41+
{
42+
// Path to Project/Assets
43+
var assetsDir = Application.dataPath;
44+
var repoRoot = Directory.GetParent(Directory.GetParent(assetsDir).FullName).FullName;
45+
46+
// Top level of where to store the samples
47+
var samplesDir = Path.Combine(
48+
repoRoot,
49+
k_MLAgentsPackageName,
50+
k_MLAgentsSamplesDirName);
51+
52+
if (!Directory.Exists(samplesDir))
53+
{
54+
Directory.CreateDirectory(samplesDir);
55+
}
56+
57+
// Path to the examples dir in the project
58+
var examplesDir = Path.Combine(Application.dataPath, k_MLAgentsDir, k_MLAgentsExamplesDir);
59+
foreach (var exampleDirectory in Directory.GetDirectories(examplesDir))
60+
{
61+
var mlAgentsSamplePath = Path.Combine(exampleDirectory, k_MLAgentsSampleFile);
62+
if (File.Exists(mlAgentsSamplePath))
63+
{
64+
var sampleJson = JsonConvert.DeserializeObject<MLAgentsSampleJson>(File.ReadAllText(mlAgentsSamplePath));
65+
Debug.Log(JsonConvert.SerializeObject(sampleJson));
66+
foreach (var scene in sampleJson.scenes)
67+
{
68+
var scenePath = Path.Combine(exampleDirectory, scene);
69+
if (File.Exists(scenePath))
70+
{
71+
// Create a Sample Directory
72+
var currentSampleDir = Directory.CreateDirectory(Path.Combine(samplesDir,
73+
Path.GetFileNameWithoutExtension(scenePath)));
74+
75+
76+
var scriptsPath = Path.Combine(exampleDirectory, k_MLAgentsScriptsDirName);
77+
Debug.Log($"Scene Path: {scenePath}");
78+
var assets = new List<string> { scenePath.Substring(scenePath.IndexOf("Assets")) };
79+
if (!Directory.Exists(Path.Combine(scriptsPath)))
80+
{
81+
scriptsPath = exampleDirectory;
82+
}
83+
84+
scriptsPath = scriptsPath.Substring(scriptsPath.IndexOf("Assets"));
85+
foreach (var guid in AssetDatabase.FindAssets("t:Script", new[] { scriptsPath }))
86+
{
87+
var path = AssetDatabase.GUIDToAssetPath(guid);
88+
assets.Add(path);
89+
Debug.Log($"Adding Asset: {path}");
90+
}
91+
92+
var packageFilePath = Path.GetFileNameWithoutExtension(scenePath) + ".unitypackage";
93+
AssetDatabase.ExportPackage(assets.ToArray(),
94+
Path.Combine(Application.dataPath, packageFilePath),
95+
ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Recurse);
96+
97+
// Move the .unitypackage into the samples folder.
98+
var packageFileFullPath = Path.Combine(Application.dataPath, packageFilePath);
99+
100+
var packageInSamplePath = Path.Combine(currentSampleDir.FullName, packageFilePath);
101+
Debug.Log($"Moving {packageFileFullPath} to {packageInSamplePath}");
102+
File.Move(packageFileFullPath, packageInSamplePath);
103+
104+
// write the .sample.json file to the sample directory
105+
File.WriteAllText(Path.Combine(currentSampleDir.FullName, k_PackageSampleFile),
106+
JsonConvert.SerializeObject(new PackageSampleJson
107+
{
108+
description = sampleJson.description,
109+
displayName = sampleJson.displayName
110+
}));
111+
}
112+
}
113+
}
114+
}
115+
}
116+
catch (Exception e)
117+
{
118+
Debug.Log(e);
119+
EditorApplication.Exit(1);
120+
}
121+
EditorPrefs.SetBool("BurstCompilation", oldBurst);
122+
EditorApplication.Exit(0);
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)