From 2b97a9b104d116af6cbfd654b600768bef6047b0 Mon Sep 17 00:00:00 2001 From: Christopher Goy Date: Fri, 12 Mar 2021 15:04:33 -0800 Subject: [PATCH 1/4] Make the built-in physics modules optional dependencies. --- .yamato/com.unity.ml-agents-coverage.yml | 57 +++++ ...com.unity.ml-agents-optional-dep-tests.yml | 95 +++++---- .yamato/com.unity.ml-agents-test.yml | 199 +++++++++--------- com.unity.ml-agents.extensions/package.json | 3 +- com.unity.ml-agents/CHANGELOG.md | 2 + .../RayPerceptionSensorComponentBaseEditor.cs | 16 ++ .../Editor/Unity.ML-Agents.Editor.asmdef | 14 +- com.unity.ml-agents/Runtime/Agent.cs | 14 +- .../Runtime/Sensors/RayPerceptionSensor.cs | 10 +- .../Sensors/RayPerceptionSensorComponent2D.cs | 2 +- .../RayPerceptionSensorComponentBase.cs | 4 +- .../Runtime/Sensors/VectorSensor.cs | 2 - .../Runtime/Unity.ML-Agents.asmdef | 10 + com.unity.ml-agents/Runtime/Utilities.cs | 7 +- .../Editor/PublicAPI/PublicApiValidation.cs | 2 + .../Unity.ML-Agents.Editor.Tests.asmdef | 10 + .../Tests/Runtime/RuntimeAPITest.cs | 13 +- .../Sensor/RayPerceptionSensorTests.cs | 16 +- ...nity.ML-Agents.Runtime.Sensor.Tests.asmdef | 12 ++ .../Unity.ML-Agents.Runtime.Tests.asmdef | 12 ++ com.unity.ml-agents/package.json | 4 +- 21 files changed, 329 insertions(+), 175 deletions(-) create mode 100644 .yamato/com.unity.ml-agents-coverage.yml diff --git a/.yamato/com.unity.ml-agents-coverage.yml b/.yamato/com.unity.ml-agents-coverage.yml new file mode 100644 index 0000000000..7bf021dbad --- /dev/null +++ b/.yamato/com.unity.ml-agents-coverage.yml @@ -0,0 +1,57 @@ +test_editors: + - version: 2020.2 + testProject: DevProject + +test_platforms: + - name: linux + type: Unity::VM + image: package-ci/ubuntu:stable + flavor: b1.medium + +packages: + - name: com.unity.ml-agents + assembly: Unity.ML-Agents + minCoveragePct: 72 + - name: com.unity.ml-agents.extensions + assembly: Unity.ML-Agents.Extensions* + minCoveragePct: 75 +--- +{% for package in packages %} + {% for editor in test_editors %} + {% for platform in test_platforms %} + + {% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %} + +test_coverage_{{ package.name }}_{{ platform.name }}_{{ editor.version }}: + name : Coverage {{ package.name }} test {{ editor.version }} on {{ platform.name }} + agent: + type: {{ platform.type }} + image: {{ platform.image }} + flavor: {{ platform.flavor}} + commands: + - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - upm-ci project test -u {{ editor.version }} --type project-tests --project-path {{ editor.testProject }} --package-filter {{ package.name }} {{ coverageOptions }} --extra-utr-arg "reruncount=2" + - python3 ml-agents/tests/yamato/check_coverage_percent.py upm-ci~/test-results/ {{ package.minCoveragePct }} + artifacts: + logs: + paths: + - "upm-ci~/test-results/**/*" + dependencies: + - .yamato/com.unity.ml-agents-pack.yml#pack + triggers: + cancel_old_ci: true + {% if platform.name == "linux" %} + expression: | + (pull_request.target eq "main" OR + pull_request.target match "release.+") AND + NOT pull_request.draft AND + (pull_request.changes.any match "com.unity.ml-agents/**" OR + pull_request.changes.any match " {{ editor.testProject }}/**" OR + {% if package.name == "com.unity.ml-agents.extensions" %} + pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR + {% endif %} + pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml") + {% endif %} + {% endfor %} + {% endfor %} + {% endfor %} diff --git a/.yamato/com.unity.ml-agents-optional-dep-tests.yml b/.yamato/com.unity.ml-agents-optional-dep-tests.yml index 2d04d731d9..a44f01139c 100644 --- a/.yamato/com.unity.ml-agents-optional-dep-tests.yml +++ b/.yamato/com.unity.ml-agents-optional-dep-tests.yml @@ -1,37 +1,60 @@ -OptionalDependencyTestsLinux: - name : LinuxOptionalDependenciesTests - agent: - type: Unity::VM - image: package-ci/ubuntu:stable - flavor: b1.medium - commands: - - | - curl -L https://artifactory.prd.it.unity3d.com/artifactory/api/gpg/key/public | sudo apt-key add - - sudo sh -c "echo 'deb https://artifactory.prd.it.unity3d.com/artifactory/unity-apt-local bionic main' > /etc/apt/sources.list.d/unity.list" - sudo apt update - sudo apt install -y unity-config - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm - unity-config settings editor-path ./.Editor - unity-config project create opt-deps-test - unity-config project add dependency com.unity.ml-agents/ - unity-config project add testable com.unity.ml-agents - unity-config project add dependency com.unity.modules.imageconversion@1.0.0 - unity-config project add dependency com.unity.modules.jsonserialize@1.0.0 - unity-config project add dependency com.unity.modules.physics@1.0.0 - unity-config project add dependency com.unity.modules.physics2d@1.0.0 - upm-ci project test -u 2019.4 --type project-tests --project-path opt-deps-test --package-filter com.unity.ml-agents - artifacts: - logs: - paths: - - "upm-ci~/test-results/**/*" - dependencies: - - .yamato/com.unity.ml-agents-pack.yml#pack - triggers: - cancel_old_ci: true - expression: | - (pull_request.target eq "main" OR - pull_request.target match "release.+") AND - NOT pull_request.draft AND - (pull_request.changes.any match "com.unity.ml-agents/**" OR - pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml") +optional_deps: + - name: Analytics + project: "OptionalDepedencyTests/NoAnalyticsModule" + version: 2020.2 + - name: Physics + project: OptionalDepedencyTests/NoPhysicsModule + version: 2020.2 + - name: Physics2D + project: OptionalDepedencyTests/NoPhysics2DModule + version: 2020.2 +--- + + {% for optional_dep in optional_deps %} +OptionalDependencyTests_{{ optional_dep.name }}: + name : Test Optional Package Dependencies {{ optional_dep.name }} + agent: + type: Unity::VM + image: package-ci/ubuntu:stable + flavor: b1.medium + commands: + - | + curl -L https://artifactory.prd.it.unity3d.com/artifactory/api/gpg/key/public | sudo apt-key add - + sudo sh -c "echo 'deb https://artifactory.prd.it.unity3d.com/artifactory/unity-apt-local bionic main' > /etc/apt/sources.list.d/unity.list" + sudo apt update + sudo apt install -y unity-config + npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + unity-config settings editor-path ./.Editor + unity-config project create opt-deps-test + unity-config project add dependency com.unity.ml-agents/ + unity-config project add testable com.unity.ml-agents + unity-config project add dependency com.unity.modules.imageconversion@1.0.0 + unity-config project add dependency com.unity.modules.jsonserialize@1.0.0 + {% unless optional_dep.name == "Physics" %} + unity-config project add dependency com.unity.modules.physics@1.0.0 + {% endunless %} + {% unless optional_dep.name == "Physics2D" %} + unity-config project add dependency com.unity.modules.physics2d@1.0.0 + {% endunless %} + {% unless optional_dep.name == "Analytics" %} + unity-config project add dependency com.unity.modules.unityanalytics@1.0.0 + {% endunless %} + upm-ci project test -u {{ optional_dep.version }} --type project-tests --project-path opt-deps-test --package-filter com.unity.ml-agents + artifacts: + logs: + paths: + - "upm-ci~/test-results/**/*" + dependencies: + - .yamato/com.unity.ml-agents-pack.yml#pack + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents_linux_{{ optional_dep.version }} + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents.extensions_linux_{{ optional_dep.version }} + triggers: + cancel_old_ci: true + expression: | + (pull_request.target eq "main" OR + pull_request.target match "release.+") AND + NOT pull_request.draft AND + (pull_request.changes.any match "com.unity.ml-agents/**" OR + pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml") + {% endfor %} diff --git a/.yamato/com.unity.ml-agents-test.yml b/.yamato/com.unity.ml-agents-test.yml index 2d5f68b039..134718a08a 100644 --- a/.yamato/com.unity.ml-agents-test.yml +++ b/.yamato/com.unity.ml-agents-test.yml @@ -14,138 +14,131 @@ test_editors: enableNoDefaultPackages: !!bool true trunk_editor: - - version: trunk - # Workaround for MLA-1596 - need to make sure we load the right results. - enableCodeCoverage: !!bool false - testProject: DevProject + - version: trunk + # Workaround for MLA-1596 - need to make sure we load the right results. + enableCodeCoverage: !!bool false + testProject: DevProject test_platforms: - - name: win - type: Unity::VM - image: package-ci/win10:stable - flavor: b1.large - - name: mac - type: Unity::VM::osx - image: package-ci/mac:stable - flavor: b1.small - - name: linux - type: Unity::VM - image: package-ci/ubuntu:stable - flavor: b1.medium + - name: win + type: Unity::VM + image: package-ci/win10:stable + flavor: b1.large + - name: mac + type: Unity::VM::osx + image: package-ci/mac:stable + flavor: b1.small + - name: linux + type: Unity::VM + image: package-ci/ubuntu:stable + flavor: b1.medium packages: - - name: com.unity.ml-agents - assembly: Unity.ML-Agents - minCoveragePct: 72 - - name: com.unity.ml-agents.extensions - assembly: Unity.ML-Agents.Extensions* - minCoveragePct: 75 + - name: com.unity.ml-agents + assembly: Unity.ML-Agents + minCoveragePct: 72 + - name: com.unity.ml-agents.extensions + assembly: Unity.ML-Agents.Extensions* + minCoveragePct: 75 --- all_package_tests: - name: Run All Combinations of Editors/Platforms Tests - dependencies: + name: Run All Combinations of Editors/Platforms Tests + dependencies: + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents_linux_2019.4 + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents.extensions_linux_2019.4 {% for editor in test_editors %} {% for platform in test_platforms %} - - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} + - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} {% endfor %} {% endfor %} {% for editor in trunk_editor %} {% for platform in test_platforms %} - - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} + - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} {% endfor %} {% endfor %} - triggers: - cancel_old_ci: true - recurring: - - branch: main - frequency: daily + triggers: + cancel_old_ci: true + recurring: + - branch: main + frequency: daily -{% for package in packages %} + {% for package in packages %} {% for editor in test_editors %} - {% for platform in test_platforms %} - -{% if editor.enableCodeCoverage %} - {% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %} -{% else %} - {% assign coverageOptions = "" %} -{% endif %} + {% for platform in test_platforms %} -{% if editor.enableNoDefaultPackages %} + {% if editor.enableNoDefaultPackages %} {% assign noDefaultPackagesOptions = "--extra-create-project-arg='-upmNoDefaultPackages'" %} -{% else %} + {% else %} {% assign noDefaultPackagesOptions = "" %} -{% endif %} + {% endif %} test_{{ package.name }}_{{ platform.name }}_{{ editor.version }}: - name : {{ package.name }} test {{ editor.version }} on {{ platform.name }} - agent: - type: {{ platform.type }} - image: {{ platform.image }} - flavor: {{ platform.flavor}} - commands: - - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm - - upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} --package-filter {{ package.name }} {{ coverageOptions }} {{ noDefaultPackagesOptions }} --extra-utr-arg "reruncount=2" - {% if editor.enableCodeCoverage %} - - python3 ml-agents/tests/yamato/check_coverage_percent.py upm-ci~/test-results/ {{ package.minCoveragePct }} - {% endif %} - artifacts: - logs: - paths: - - "upm-ci~/test-results/**/*" - dependencies: - - .yamato/com.unity.ml-agents-pack.yml#pack - triggers: - cancel_old_ci: true - {% if platform.name == "linux" %} - expression: | - (pull_request.target eq "main" OR - pull_request.target match "release.+") AND - NOT pull_request.draft AND - (pull_request.changes.any match "com.unity.ml-agents/**" OR - pull_request.changes.any match " {{ editor.testProject }}/**" OR - {% if package.name == "com.unity.ml-agents.extensions" %} - pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR + name : {{ package.name }} test {{ editor.version }} on {{ platform.name }} + agent: + type: {{ platform.type }} + image: {{ platform.image }} + flavor: {{ platform.flavor}} + commands: + - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} --package-filter {{ package.name }} {{ noDefaultPackagesOptions }} --extra-utr-arg "reruncount=2" + artifacts: + logs: + paths: + - "upm-ci~/test-results/**/*" + dependencies: + - .yamato/com.unity.ml-agents-pack.yml#pack + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_{{ package.name }}_linux_2019.4 + triggers: + cancel_old_ci: true + {% if platform.name == "linux" %} + expression: | + (pull_request.target eq "main" OR + pull_request.target match "release.+") AND + NOT pull_request.draft AND + (pull_request.changes.any match "com.unity.ml-agents/**" OR + pull_request.changes.any match " {{ editor.testProject }}/**" OR + {% if package.name == "com.unity.ml-agents.extensions" %} + pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR + {% endif %} + pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml") {% endif %} - pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml") - {% endif %} - {% endfor %} + {% endfor %} + {% endfor %} {% endfor %} -{% endfor %} -{% for package in packages %} + {% for package in packages %} {% for editor in trunk_editor %} - {% for platform in test_platforms %} + {% for platform in test_platforms %} -{% if editor.enableCodeCoverage %} + {% if editor.enableCodeCoverage %} {% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %} -{% else %} + {% else %} {% assign coverageOptions = "" %} -{% endif %} + {% endif %} test_{{ package.name }}_{{ platform.name }}_trunk: - name : {{ package.name }} test {{ editor.version }} on {{ platform.name }} - agent: - type: {{ platform.type }} - image: {{ platform.image }} - flavor: {{ platform.flavor}} - commands: - - python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - - unity-downloader-cli -u trunk -c editor --wait --fast - - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm - - upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} --package-filter {{ package.name }} {{ coverageOptions }} --extra-create-project-arg="-upmNoDefaultPackages" --extra-utr-arg "reruncount=2" - {% if editor.enableCodeCoverage %} - - python3 ml-agents/tests/yamato/check_coverage_percent.py upm-ci~/test-results/ {{ package.minCoveragePct }} - {% endif %} - artifacts: - logs: - paths: - - "upm-ci~/test-results/**/*" - dependencies: - - .yamato/com.unity.ml-agents-pack.yml#pack - triggers: - cancel_old_ci: true - {% endfor %} + name : {{ package.name }} test {{ editor.version }} on {{ platform.name }} + agent: + type: {{ platform.type }} + image: {{ platform.image }} + flavor: {{ platform.flavor}} + commands: + - python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade + - unity-downloader-cli -u trunk -c editor --wait --fast + - npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm + - upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} --package-filter {{ package.name }} {{ coverageOptions }} --extra-create-project-arg="-upmNoDefaultPackages" --extra-utr-arg "reruncount=2" + {% if editor.enableCodeCoverage %} + - python3 ml-agents/tests/yamato/check_coverage_percent.py upm-ci~/test-results/ {{ package.minCoveragePct }} + {% endif %} + artifacts: + logs: + paths: + - "upm-ci~/test-results/**/*" + dependencies: + - .yamato/com.unity.ml-agents-pack.yml#pack + triggers: + cancel_old_ci: true + {% endfor %} + {% endfor %} {% endfor %} -{% endfor %} - diff --git a/com.unity.ml-agents.extensions/package.json b/com.unity.ml-agents.extensions/package.json index 6684068bf8..c294b52751 100644 --- a/com.unity.ml-agents.extensions/package.json +++ b/com.unity.ml-agents.extensions/package.json @@ -5,6 +5,7 @@ "unity": "2019.4", "description": "A source-only package for new features based on ML-Agents", "dependencies": { - "com.unity.ml-agents": "2.0.0-exp.1" + "com.unity.ml-agents": "2.0.0-exp.1", + "com.unity.modules.physics": "1.0.0" } } diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index b3e2ba27bc..f6b8b325f7 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -27,6 +27,8 @@ details. - The `.onnx` models input names have changed. All input placeholders will now use the prefix `obs_` removing the distinction between visual and vector observations. Models created with this version will not be usable with previous versions of the package (#5080) - The `.onnx` models discrete action output now contains the discrete actions values and not the logits. Models created with this version will not be usable with previous versions of the package (#5080) - Added ML-Agents package settings. (#5027) +- Make com.unity.modules.unityanalytics an optional dependency. (#5109) +- Make com.unity.modules.physics and com.unity.modules.physics2d optional dependencies. (#5112) #### ml-agents / ml-agents-envs / gym-unity (Python) ### Bug Fixes diff --git a/com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs b/com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs index 4cc36976c0..2d619745e4 100644 --- a/com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs +++ b/com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs @@ -10,6 +10,22 @@ internal class RayPerceptionSensorComponentBaseEditor : UnityEditor.Editor protected void OnRayPerceptionInspectorGUI(bool is3d) { +#if !MLA_UNITY_PHYSICS_MODULE + if (is3d) + { + EditorGUILayout.HelpBox("The Physics Module is not currently present. " + + "Please add it to your project in order to use the Ray Perception APIs in the " + + $"{nameof(RayPerceptionSensorComponent3D)}", MessageType.Warning); + } +#endif +#if !MLA_UNITY_PHYSICS2D_MODULE + if (!is3d) + { + EditorGUILayout.HelpBox("The Physics2D Module is not currently present. " + + "Please add it to your project in order to use the Ray Perception APIs in the " + + $"{nameof(RayPerceptionSensorComponent3D)}", MessageType.Warning); + } +#endif var so = serializedObject; so.Update(); diff --git a/com.unity.ml-agents/Editor/Unity.ML-Agents.Editor.asmdef b/com.unity.ml-agents/Editor/Unity.ML-Agents.Editor.asmdef index 53a0ff77fd..27f67d0d1c 100755 --- a/com.unity.ml-agents/Editor/Unity.ML-Agents.Editor.asmdef +++ b/com.unity.ml-agents/Editor/Unity.ML-Agents.Editor.asmdef @@ -14,5 +14,17 @@ "overrideReferences": false, "precompiledReferences": [], "autoReferenced": true, - "defineConstraints": [] + "defineConstraints": [], + "versionDefines": [ + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS_MODULE" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS2D_MODULE" + } + ] } diff --git a/com.unity.ml-agents/Runtime/Agent.cs b/com.unity.ml-agents/Runtime/Agent.cs index 201d31dd16..5c7cc73488 100644 --- a/com.unity.ml-agents/Runtime/Agent.cs +++ b/com.unity.ml-agents/Runtime/Agent.cs @@ -87,9 +87,9 @@ public void CopyActions(ActionBuffers actionBuffers) internal class AgentVectorActuator : VectorActuator { public AgentVectorActuator(IActionReceiver actionReceiver, - IHeuristicProvider heuristicProvider, - ActionSpec actionSpec, - string name = "VectorActuator" + IHeuristicProvider heuristicProvider, + ActionSpec actionSpec, + string name = "VectorActuator" ) : base(actionReceiver, heuristicProvider, actionSpec, name) { } @@ -692,9 +692,7 @@ public int CompletedEpisodes /// The new value of the reward. public void SetReward(float reward) { -#if DEBUG Utilities.DebugCheckNanAndInfinity(reward, nameof(reward), nameof(SetReward)); -#endif m_CumulativeReward += (reward - m_Reward); m_Reward = reward; } @@ -722,26 +720,20 @@ public void SetReward(float reward) /// Incremental reward value. public void AddReward(float increment) { -#if DEBUG Utilities.DebugCheckNanAndInfinity(increment, nameof(increment), nameof(AddReward)); -#endif m_Reward += increment; m_CumulativeReward += increment; } internal void SetGroupReward(float reward) { -#if DEBUG Utilities.DebugCheckNanAndInfinity(reward, nameof(reward), nameof(SetGroupReward)); -#endif m_GroupReward = reward; } internal void AddGroupReward(float increment) { -#if DEBUG Utilities.DebugCheckNanAndInfinity(increment, nameof(increment), nameof(AddGroupReward)); -#endif m_GroupReward += increment; } diff --git a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs index 21ee70d52e..19281eb206 100644 --- a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs +++ b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs @@ -422,12 +422,13 @@ out DebugDisplayInfo.RayInfo debugRayOut unscaledCastRadius; // Do the cast and assign the hit information for each detectable tag. - bool castHit; - float hitFraction; - GameObject hitObject; + var castHit = false; + var hitFraction = 1.0f; + GameObject hitObject = null; if (input.CastType == RayPerceptionCastType.Cast3D) { +#if MLA_UNITY_PHYSICS_MODULE RaycastHit rayHit; if (scaledCastRadius > 0f) { @@ -444,9 +445,11 @@ out DebugDisplayInfo.RayInfo debugRayOut // To avoid 0/0, set the fraction to 0. hitFraction = castHit ? (scaledRayLength > 0 ? rayHit.distance / scaledRayLength : 0.0f) : 1.0f; hitObject = castHit ? rayHit.collider.gameObject : null; +#endif } else { +#if MLA_UNITY_PHYSICS2D_MODULE RaycastHit2D rayHit; if (scaledCastRadius > 0f) { @@ -461,6 +464,7 @@ out DebugDisplayInfo.RayInfo debugRayOut castHit = rayHit; hitFraction = castHit ? rayHit.fraction : 1.0f; hitObject = castHit ? rayHit.collider.gameObject : null; +#endif } var rayOutput = new RayPerceptionOutput.RayOutput diff --git a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent2D.cs b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent2D.cs index cb055d4558..481a143d0e 100644 --- a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent2D.cs +++ b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent2D.cs @@ -14,7 +14,7 @@ public class RayPerceptionSensorComponent2D : RayPerceptionSensorComponentBase public RayPerceptionSensorComponent2D() { // Set to the 2D defaults (just in case they ever diverge). - RayLayerMask = Physics2D.DefaultRaycastLayers; + RayLayerMask = -5; } /// diff --git a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs index d1a332e525..a4734c014f 100644 --- a/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs +++ b/com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs @@ -97,9 +97,11 @@ public float RayLength set { m_RayLength = value; UpdateSensor(); } } + // The value of the default layers. + const int k_PhysicsDefaultLayers = -5; [HideInInspector, SerializeField, FormerlySerializedAs("rayLayerMask")] [Tooltip("Controls which layers the rays can hit.")] - LayerMask m_RayLayerMask = Physics.DefaultRaycastLayers; + LayerMask m_RayLayerMask = k_PhysicsDefaultLayers; /// /// Controls which layers the rays can hit. diff --git a/com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs b/com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs index 4f151efb94..635784d737 100644 --- a/com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs +++ b/com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs @@ -120,9 +120,7 @@ void Clear() void AddFloatObs(float obs) { -#if DEBUG Utilities.DebugCheckNanAndInfinity(obs, nameof(obs), nameof(AddFloatObs)); -#endif m_Observations.Add(obs); } diff --git a/com.unity.ml-agents/Runtime/Unity.ML-Agents.asmdef b/com.unity.ml-agents/Runtime/Unity.ML-Agents.asmdef index 90e7e3fae6..8e0fbb8e69 100755 --- a/com.unity.ml-agents/Runtime/Unity.ML-Agents.asmdef +++ b/com.unity.ml-agents/Runtime/Unity.ML-Agents.asmdef @@ -21,6 +21,16 @@ "name": "com.unity.modules.unityanalytics", "expression": "1.0.0", "define": "MLA_UNITY_ANALYTICS_MODULE" + }, + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS_MODULE" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS2D_MODULE" } ] } diff --git a/com.unity.ml-agents/Runtime/Utilities.cs b/com.unity.ml-agents/Runtime/Utilities.cs index fdc209f30c..973887ef50 100644 --- a/com.unity.ml-agents/Runtime/Utilities.cs +++ b/com.unity.ml-agents/Runtime/Utilities.cs @@ -1,10 +1,10 @@ using System; +using System.Diagnostics; namespace Unity.MLAgents { internal static class Utilities { - /// /// Calculates the cumulative sum of an integer array. The result array will be one element /// larger than the input array since it has a padded 0 at the beginning. @@ -26,10 +26,9 @@ internal static int[] CumSum(int[] input) return result; } -#if DEBUG + [Conditional("DEBUG")] internal static void DebugCheckNanAndInfinity(float value, string valueCategory, string caller) { - if (float.IsNaN(value)) { throw new ArgumentException($"NaN {valueCategory} passed to {caller}."); @@ -39,7 +38,5 @@ internal static void DebugCheckNanAndInfinity(float value, string valueCategory, throw new ArgumentException($"Inifinity {valueCategory} passed to {caller}."); } } -#endif } - } diff --git a/com.unity.ml-agents/Tests/Editor/PublicAPI/PublicApiValidation.cs b/com.unity.ml-agents/Tests/Editor/PublicAPI/PublicApiValidation.cs index 37ac9b3bfe..df4a3cc961 100644 --- a/com.unity.ml-agents/Tests/Editor/PublicAPI/PublicApiValidation.cs +++ b/com.unity.ml-agents/Tests/Editor/PublicAPI/PublicApiValidation.cs @@ -53,6 +53,7 @@ public void CheckSetupRenderTextureSensorComponent() Assert.IsTrue(sensorComponent.Grayscale); } +#if MLA_UNITY_PHYSICS_MODULE [Test] public void CheckSetupRayPerceptionSensorComponent() { @@ -69,5 +70,6 @@ public void CheckSetupRayPerceptionSensorComponent() sensorComponent.CreateSensor(); } +#endif } } diff --git a/com.unity.ml-agents/Tests/Editor/Unity.ML-Agents.Editor.Tests.asmdef b/com.unity.ml-agents/Tests/Editor/Unity.ML-Agents.Editor.Tests.asmdef index 1d45762e7a..041b707e8a 100755 --- a/com.unity.ml-agents/Tests/Editor/Unity.ML-Agents.Editor.Tests.asmdef +++ b/com.unity.ml-agents/Tests/Editor/Unity.ML-Agents.Editor.Tests.asmdef @@ -30,6 +30,16 @@ "name": "com.unity.modules.unityanalytics", "expression": "1.0.0", "define": "MLA_UNITY_ANALYTICS_MODULE" + }, + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS_MODULE" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS2D_MODULE" } ] } diff --git a/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs b/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs index 1905f3dbd8..4d7290ae73 100644 --- a/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs +++ b/com.unity.ml-agents/Tests/Runtime/RuntimeAPITest.cs @@ -1,4 +1,3 @@ -#if UNITY_INCLUDE_TESTS using System.Collections; using System.Collections.Generic; using Unity.MLAgents; @@ -72,7 +71,7 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() behaviorParams.BrainParameters.VectorObservationSize = 3; behaviorParams.BrainParameters.NumStackedVectorObservations = 2; behaviorParams.BrainParameters.VectorActionDescriptions = new[] { "Continuous1", "TestActionA", "TestActionB" }; - behaviorParams.BrainParameters.ActionSpec = new ActionSpec(1, new []{2, 2}); + behaviorParams.BrainParameters.ActionSpec = new ActionSpec(1, new[] { 2, 2 }); behaviorParams.BehaviorName = "TestBehavior"; behaviorParams.TeamId = 42; behaviorParams.UseChildSensors = true; @@ -81,7 +80,7 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() // Can't actually create an Agent with InferenceOnly and no model, so change back behaviorParams.BehaviorType = BehaviorType.Default; - +#if MLA_UNITY_PHSYICS_MODULE var sensorComponent = gameObject.AddComponent(); sensorComponent.SensorName = "ray3d"; sensorComponent.DetectableTags = new List { "Player", "Respawn" }; @@ -95,6 +94,7 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() // ISensor isn't set up yet. Assert.IsNull(sensorComponent.RaySensor); +#endif // Make sure we can set the behavior type correctly after the agent is initialized @@ -109,10 +109,10 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() decisionRequester.DecisionPeriod = 2; decisionRequester.TakeActionsBetweenDecisions = true; - +#if MLA_UNITY_PHSYICS_MODULE // Initialization should set up the sensors Assert.IsNotNull(sensorComponent.RaySensor); - +#endif // Let's change the inference device var otherDevice = behaviorParams.InferenceDevice == InferenceDevice.CPU ? InferenceDevice.GPU : InferenceDevice.CPU; agent.SetModel(behaviorParams.BehaviorName, behaviorParams.Model, otherDevice); @@ -126,7 +126,7 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() var actions = agent.GetStoredActionBuffers().DiscreteActions; // default Heuristic implementation should return zero actions. - Assert.AreEqual(new ActionSegment(new[] {0, 0}), actions); + Assert.AreEqual(new ActionSegment(new[] { 0, 0 }), actions); Assert.AreEqual(1, agent.numHeuristicCalls); Academy.Instance.EnvironmentStep(); @@ -137,4 +137,3 @@ public IEnumerator RuntimeApiTestWithEnumeratorPasses() } } } -#endif diff --git a/com.unity.ml-agents/Tests/Runtime/Sensor/RayPerceptionSensorTests.cs b/com.unity.ml-agents/Tests/Runtime/Sensor/RayPerceptionSensorTests.cs index 8e481fa21d..751ed433ac 100644 --- a/com.unity.ml-agents/Tests/Runtime/Sensor/RayPerceptionSensorTests.cs +++ b/com.unity.ml-agents/Tests/Runtime/Sensor/RayPerceptionSensorTests.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using NUnit.Framework; using UnityEngine; -using UnityEngine.TestTools; using Unity.MLAgents.Sensors; +using UnityEngine.TestTools; namespace Unity.MLAgents.Tests { @@ -24,6 +24,18 @@ public void TestGetRayAngles() public class RayPerception3DTests { + [Test] + public void TestDefaultLayersAreNegativeFive() + { +#if MLA_UNITY_PHYSICS_MODULE + Assert.IsTrue(Physics.DefaultRaycastLayers == -5); +#endif +#if MLA_UNITY_PHYSICS2D_MODULE + Assert.IsTrue(Physics2D.DefaultRaycastLayers == -5); +#endif + } + +#if MLA_UNITY_PHYSICS_MODULE // Use built-in tags const string k_CubeTag = "Player"; const string k_SphereTag = "Respawn"; @@ -72,6 +84,7 @@ void SetupScene() sphere3.tag = k_SphereTag; sphere3.name = "sphere3"; + Physics.SyncTransforms(); } @@ -402,5 +415,6 @@ public void TestStaticPerceiveNoTags() Assert.AreEqual(-1, castOutput.RayOutputs[0].HitTagIndex); } } +#endif } } diff --git a/com.unity.ml-agents/Tests/Runtime/Sensor/Unity.ML-Agents.Runtime.Sensor.Tests.asmdef b/com.unity.ml-agents/Tests/Runtime/Sensor/Unity.ML-Agents.Runtime.Sensor.Tests.asmdef index 168e944ab3..d779451c40 100644 --- a/com.unity.ml-agents/Tests/Runtime/Sensor/Unity.ML-Agents.Runtime.Sensor.Tests.asmdef +++ b/com.unity.ml-agents/Tests/Runtime/Sensor/Unity.ML-Agents.Runtime.Sensor.Tests.asmdef @@ -21,5 +21,17 @@ "autoReferenced": false, "defineConstraints": [ "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [ + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS_MODULE" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS2D_MODULE" + } ] } diff --git a/com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef b/com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef index b7e11ed50b..b740695c2a 100644 --- a/com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef +++ b/com.unity.ml-agents/Tests/Runtime/Unity.ML-Agents.Runtime.Tests.asmdef @@ -21,5 +21,17 @@ "autoReferenced": false, "defineConstraints": [ "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [ + { + "name": "com.unity.modules.physics", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS_MODULE" + }, + { + "name": "com.unity.modules.physics2d", + "expression": "1.0.0", + "define": "MLA_UNITY_PHYSICS2D_MODULE" + } ] } diff --git a/com.unity.ml-agents/package.json b/com.unity.ml-agents/package.json index 89a7fa8959..16865e2c91 100755 --- a/com.unity.ml-agents/package.json +++ b/com.unity.ml-agents/package.json @@ -7,8 +7,6 @@ "dependencies": { "com.unity.barracuda": "1.3.2-preview", "com.unity.modules.imageconversion": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.physics2d": "1.0.0" + "com.unity.modules.jsonserialize": "1.0.0" } } From acb9987730661857b96e39f37c9e4a1536a34ce8 Mon Sep 17 00:00:00 2001 From: Christopher Goy Date: Mon, 22 Mar 2021 13:11:37 -0700 Subject: [PATCH 2/4] Update yml formatting. --- .yamato/com.unity.ml-agents-test.yml | 57 ++++++++++++++-------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/.yamato/com.unity.ml-agents-test.yml b/.yamato/com.unity.ml-agents-test.yml index 134718a08a..19396d6579 100644 --- a/.yamato/com.unity.ml-agents-test.yml +++ b/.yamato/com.unity.ml-agents-test.yml @@ -1,17 +1,17 @@ test_editors: - - version: 2019.4 - enableCodeCoverage: !!bool true - # We want some scene tests to run in the DevProject, but packages there only support 2020+ - testProject: Project - enableNoDefaultPackages: !!bool true - - version: 2020.2 - enableCodeCoverage: !!bool true - testProject: DevProject - enableNoDefaultPackages: !!bool true - - version: 2021.1 - enableCodeCoverage: !!bool true - testProject: DevProject - enableNoDefaultPackages: !!bool true + - version: 2019.4 + enableCodeCoverage: !!bool true + # We want some scene tests to run in the DevProject, but packages there only support 2020+ + testProject: Project + enableNoDefaultPackages: !!bool true + - version: 2020.2 + enableCodeCoverage: !!bool true + testProject: DevProject + enableNoDefaultPackages: !!bool true + - version: 2021.1 + enableCodeCoverage: !!bool true + testProject: DevProject + enableNoDefaultPackages: !!bool true trunk_editor: - version: trunk @@ -45,19 +45,18 @@ packages: all_package_tests: name: Run All Combinations of Editors/Platforms Tests dependencies: - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents_linux_2019.4 - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents.extensions_linux_2019.4 - {% for editor in test_editors %} - {% for platform in test_platforms %} - - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} - {% endfor %} - {% endfor %} - - {% for editor in trunk_editor %} - {% for platform in test_platforms %} - - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} - {% endfor %} - {% endfor %} + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents_linux_2019.4 + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents.extensions_linux_2019.4 + {% for editor in test_editors %} + {% for platform in test_platforms %} + - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} + {% endfor %} + {% endfor %} + {% for editor in trunk_editor %} + {% for platform in test_platforms %} + - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} + {% endfor %} + {% endfor %} triggers: cancel_old_ci: true recurring: @@ -114,9 +113,9 @@ test_{{ package.name }}_{{ platform.name }}_{{ editor.version }}: {% if editor.enableCodeCoverage %} {% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %} - {% else %} - {% assign coverageOptions = "" %} - {% endif %} + {% else %} + {% assign coverageOptions = "" %} + {% endif %} test_{{ package.name }}_{{ platform.name }}_trunk: name : {{ package.name }} test {{ editor.version }} on {{ platform.name }} agent: From e688026d5e741dfa22dc36f2b5e1d16f1a530aad Mon Sep 17 00:00:00 2001 From: Christopher Goy Date: Mon, 22 Mar 2021 13:26:15 -0700 Subject: [PATCH 3/4] Fix up yml deps and meta files. --- .yamato/com.unity.ml-agents-coverage.yml | 35 +++++-------------- ...com.unity.ml-agents-optional-dep-tests.yml | 9 +++-- .yamato/com.unity.ml-agents-test.yml | 25 +++++++++++-- .yamato/coverage_tests.metafile | 17 +++++++++ 4 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 .yamato/coverage_tests.metafile diff --git a/.yamato/com.unity.ml-agents-coverage.yml b/.yamato/com.unity.ml-agents-coverage.yml index 7bf021dbad..866355435e 100644 --- a/.yamato/com.unity.ml-agents-coverage.yml +++ b/.yamato/com.unity.ml-agents-coverage.yml @@ -1,26 +1,9 @@ -test_editors: - - version: 2020.2 - testProject: DevProject - -test_platforms: - - name: linux - type: Unity::VM - image: package-ci/ubuntu:stable - flavor: b1.medium - -packages: - - name: com.unity.ml-agents - assembly: Unity.ML-Agents - minCoveragePct: 72 - - name: com.unity.ml-agents.extensions - assembly: Unity.ML-Agents.Extensions* - minCoveragePct: 75 +{% metadata_file .yamato/coverage_tests.metafile %} --- -{% for package in packages %} - {% for editor in test_editors %} - {% for platform in test_platforms %} - - {% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %} +{% for package in coverage_packages %} +{% for editor in coverage_test_editors %} +{% for platform in coverage_test_platforms %} +{% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %} test_coverage_{{ package.name }}_{{ platform.name }}_{{ editor.version }}: name : Coverage {{ package.name }} test {{ editor.version }} on {{ platform.name }} @@ -48,10 +31,10 @@ test_coverage_{{ package.name }}_{{ platform.name }}_{{ editor.version }}: (pull_request.changes.any match "com.unity.ml-agents/**" OR pull_request.changes.any match " {{ editor.testProject }}/**" OR {% if package.name == "com.unity.ml-agents.extensions" %} - pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR + pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR {% endif %} pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml") {% endif %} - {% endfor %} - {% endfor %} - {% endfor %} +{% endfor %} +{% endfor %} +{% endfor %} diff --git a/.yamato/com.unity.ml-agents-optional-dep-tests.yml b/.yamato/com.unity.ml-agents-optional-dep-tests.yml index a44f01139c..cf647e41cd 100644 --- a/.yamato/com.unity.ml-agents-optional-dep-tests.yml +++ b/.yamato/com.unity.ml-agents-optional-dep-tests.yml @@ -46,8 +46,13 @@ OptionalDependencyTests_{{ optional_dep.name }}: - "upm-ci~/test-results/**/*" dependencies: - .yamato/com.unity.ml-agents-pack.yml#pack - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents_linux_{{ optional_dep.version }} - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents.extensions_linux_{{ optional_dep.version }} + {% for coverage_editor in coverage_test_editors %} + {% for coverage_plathform in coverage_test_platforms %} + {% for coverage_package in coverage_test_packages %} + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_{{ coverage_package.name }}_{{ coverage_platform.name }}_{{ coverage_editor.version }} + {% endfor %} + {% endfor %} + {% endfor %} triggers: cancel_old_ci: true expression: | diff --git a/.yamato/com.unity.ml-agents-test.yml b/.yamato/com.unity.ml-agents-test.yml index 19396d6579..fd863408a4 100644 --- a/.yamato/com.unity.ml-agents-test.yml +++ b/.yamato/com.unity.ml-agents-test.yml @@ -1,3 +1,4 @@ +{% metadata_file .yamato/coverage_tests.metafile %} test_editors: - version: 2019.4 enableCodeCoverage: !!bool true @@ -45,8 +46,13 @@ packages: all_package_tests: name: Run All Combinations of Editors/Platforms Tests dependencies: - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents_linux_2019.4 - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_com.unity.ml-agents.extensions_linux_2019.4 + {% for coverage_editor in coverage_test_editors %} + {% for coverage_plathform in coverage_test_platforms %} + {% for coverage_package in coverage_test_packages %} + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_{{ coverage_package.name }}_{{ coverage_platform.name }}_{{ coverage_editor.version }} + {% endfor %} + {% endfor %} + {% endfor %} {% for editor in test_editors %} {% for platform in test_platforms %} - .yamato/com.unity.ml-agents-test.yml#test_com.unity.ml-agents_{{ platform.name }}_{{ editor.version }} @@ -88,7 +94,13 @@ test_{{ package.name }}_{{ platform.name }}_{{ editor.version }}: - "upm-ci~/test-results/**/*" dependencies: - .yamato/com.unity.ml-agents-pack.yml#pack - - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_{{ package.name }}_linux_2019.4 + {% for coverage_editor in coverage_test_editors %} + {% for coverage_plathform in coverage_test_platforms %} + {% for coverage_package in coverage_test_packages %} + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_{{ coverage_package.name }}_{{ coverage_platform.name }}_{{ coverage_editor.version }} + {% endfor %} + {% endfor %} + {% endfor %} triggers: cancel_old_ci: true {% if platform.name == "linux" %} @@ -136,6 +148,13 @@ test_{{ package.name }}_{{ platform.name }}_trunk: - "upm-ci~/test-results/**/*" dependencies: - .yamato/com.unity.ml-agents-pack.yml#pack + {% for coverage_editor in coverage_test_editors %} + {% for coverage_plathform in coverage_test_platforms %} + {% for coverage_package in coverage_test_packages %} + - .yamato/com.unity.ml-agents-coverage.yml#test_coverage_{{ coverage_package.name }}_{{ coverage_platform.name }}_{{ coverage_editor.version }} + {% endfor %} + {% endfor %} + {% endfor %} triggers: cancel_old_ci: true {% endfor %} diff --git a/.yamato/coverage_tests.metafile b/.yamato/coverage_tests.metafile new file mode 100644 index 0000000000..476d0d6263 --- /dev/null +++ b/.yamato/coverage_tests.metafile @@ -0,0 +1,17 @@ +coverage_test_editors: + - version: 2020.2 + testProject: DevProject + +coverage_test_platforms: + - name: linux + type: Unity::VM + image: package-ci/ubuntu:stable + flavor: b1.medium + +coverage_test_packages: + - name: com.unity.ml-agents + assembly: Unity.ML-Agents + minCoveragePct: 72 + - name: com.unity.ml-agents.extensions + assembly: Unity.ML-Agents.Extensions* + minCoveragePct: 75 From 2d56789d59eca4506231738c4dee8af57606f7d8 Mon Sep 17 00:00:00 2001 From: Christopher Goy Date: Mon, 22 Mar 2021 13:38:55 -0700 Subject: [PATCH 4/4] Fix yml. --- .yamato/com.unity.ml-agents-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.yamato/com.unity.ml-agents-coverage.yml b/.yamato/com.unity.ml-agents-coverage.yml index 866355435e..c9dd8747e8 100644 --- a/.yamato/com.unity.ml-agents-coverage.yml +++ b/.yamato/com.unity.ml-agents-coverage.yml @@ -1,6 +1,6 @@ {% metadata_file .yamato/coverage_tests.metafile %} --- -{% for package in coverage_packages %} +{% for package in coverage_test_packages %} {% for editor in coverage_test_editors %} {% for platform in coverage_test_platforms %} {% capture coverageOptions %} --enable-code-coverage --code-coverage-options 'generateHtmlReport;assemblyFilters:+{{ package.assembly }}'{% endcapture %}