浏览代码

Merge 0.11.0 to develop (#2825)

* Update package and communicator versions to 0.11

* Remove pip cache fallback for CircleCI

This change removes the caching fallback in the case where dependencies
change, since it can cause CI failures when we have incompatible
dependencies in the cache.

* Limit Tensorflow version for tests to <2.0

* Use stable bokken image. (#2815)

* build fixes for 2018+ (#2808)

* rename CompressionType enum

* fix standalone build test for 2018+

* Add more editor versions for testing. (#2809)

* class variable for API verison, fix env tests (#2817)

* fixed area prefab

agents were pointing to the wrong laser gameObject.
/develop-newnormalization
GitHub 5 年前
当前提交
6ba6f08c
共有 22 个文件被更改,包括 180 次插入148 次删除
  1. 2
      .circleci/config.yml
  2. 34
      .yamato/csharp-tests.yml
  3. 54
      .yamato/standalone-build-test.yml
  4. 4
      UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs
  5. 29
      UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs
  6. 23
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Prefabs/FoodCollectorArea.prefab
  7. 5
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scenes/FoodCollector.unity
  8. 2
      UnitySDK/Assets/ML-Agents/Scripts/Academy.cs
  9. 12
      UnitySDK/Assets/ML-Agents/Scripts/Agent.cs
  10. 4
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs
  11. 2
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs
  12. 6
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs
  13. 4
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs
  14. 4
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs
  15. 2
      gym-unity/setup.py
  16. 3
      ml-agents-envs/mlagents/envs/environment.py
  17. 6
      ml-agents-envs/mlagents/envs/mock_communicator.py
  18. 2
      ml-agents-envs/setup.py
  19. 2
      ml-agents/setup.py
  20. 55
      run-standalone-build-osx.sh
  21. 71
      run-tests-editmode-osx-editor.sh
  22. 2
      test_constraints_max_version.txt

2
.circleci/config.yml


keys:
# Parameterize the cache so that different python versions can get different versions of the packages
- v1-dependencies-py<< parameters.pyversion >>-{{ checksum "python_deps.txt" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-py<< parameters.pyversion >>-
- run:
name: Install Dependencies

34
.yamato/csharp-tests.yml


name: Mac Edit Mode Tests
triggers:
test_editors:
- version: 2017.4
- version: 2018.4
- version: 2019.3
---
{% for editor in test_editors %}
test_mac_editmode_{{ editor.version }}:
name: Test Mac EditMode {{ editor.version }}
agent:
type: Unity::VM::osx
image: ml-agents/ml-agents-bokken-mac:stable
flavor: i1.small
variables:
UNITY_VERSION: {{ editor.version }}
commands:
- ./run-tests-editmode-osx-editor.sh
triggers:
- "/develop-.*/"
- "/develop-.*/"
- "develop"
- "develop"
pull_requests:
- targets:
only:

agent:
type: Unity::VM::osx
image: ml-agents/ml-agents-bokken-mac:stable
flavor: i1.small
variables:
LC_ALL: "en_US.UTF-8"
commands:
- ./run-tests-editmode-osx-editor.sh
{% endfor %}

54
.yamato/standalone-build-test.yml


name: Mac Standalone Build Test
triggers:
branches:
only:
- "/develop-.*/"
targets:
only:
- "develop"
pull_requests:
- targets:
only:
- "master"
- "/release-.*/"
- "/hotfix-.*/"
agent:
type: Unity::VM::osx
image: ml-agents/ml-agents-bokken-mac:stable
flavor: i1.small
variables:
LC_ALL: "en_US.UTF-8"
commands:
- ./run-standalone-build-osx.sh
test_editors:
- version: 2017.4
- version: 2018.4
- version: 2019.3
---
{% for editor in test_editors %}
test_mac_standalone_{{ editor.version }}:
name: Test Mac Standalone {{ editor.version }}
agent:
type: Unity::VM::osx
image: ml-agents/ml-agents-bokken-mac:stable
flavor: i1.small
variables:
UNITY_VERSION: {{ editor.version }}
commands:
- ./run-standalone-build-osx.sh
triggers:
branches:
only:
- "/develop-.*/"
targets:
only:
- "develop"
pull_requests:
- targets:
only:
- "master"
- "/release-.*/"
- "/hotfix-.*/"
{% endfor %}

4
UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs


return null;
}
public CompressionType GetCompressionType()
public SensorCompressionType GetCompressionType()
return CompressionType.None;
return SensorCompressionType.None;
}
public string GetName()

29
UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs


using System;
using UnityEditor;
using UnityEngine;
#if UNITY_2018_1_OR_NEWER
using UnityEditor.Build.Reporting;
#endif
namespace MLAgents
{

{
string[] scenes = { "Assets/ML-Agents/Examples/3DBall/Scenes/3DBall.unity" };
var error = BuildPipeline.BuildPlayer(scenes, "testPlayer", BuildTarget.StandaloneOSX, BuildOptions.None);
if (string.IsNullOrEmpty(error))
var buildResult = BuildPipeline.BuildPlayer(scenes, "testPlayer", BuildTarget.StandaloneOSX, BuildOptions.None);
#if UNITY_2018_1_OR_NEWER
var isOK = buildResult.summary.result == BuildResult.Succeeded;
var error = "";
foreach (var stepInfo in buildResult.steps)
{
foreach (var msg in stepInfo.messages)
{
if (msg.type != LogType.Log && msg.type != LogType.Warning)
{
error += msg.content + "\n";
}
}
}
#else
var error = buildResult;
var isOK = string.IsNullOrEmpty(error);
#endif
if (isOK)
{
EditorApplication.Exit(0);
}

EditorApplication.Exit(1);
}
}

23
UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Prefabs/FoodCollectorArea.prefab


vectorObservationSize: 53
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
cameraResolutions: []
vectorActionDescriptions: []
vectorActionSpaceType: 0
m_Model: {fileID: 11400000, guid: d32fca21cf4c04536ab7f88eb9de83e0, type: 3}

m_Name:
m_EditorClassIdentifier:
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

m_Name:
m_EditorClassIdentifier:
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

badMaterial: {fileID: 2100000, guid: 88b9ae7af2c1748a0a1f63407587a601, type: 2}
goodMaterial: {fileID: 2100000, guid: c67450f290f3e4897bc40276a619e78d, type: 2}
frozenMaterial: {fileID: 2100000, guid: 66163cf35956a4be08e801b750c26f33, type: 2}
myLaser: {fileID: 1081721624670010}
myLaser: {fileID: 1617924810425504}
contribute: 0
useVectorObs: 1
--- !u!114 &114192565006091356

m_Name:
m_EditorClassIdentifier:
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

badMaterial: {fileID: 2100000, guid: 88b9ae7af2c1748a0a1f63407587a601, type: 2}
goodMaterial: {fileID: 2100000, guid: c67450f290f3e4897bc40276a619e78d, type: 2}
frozenMaterial: {fileID: 2100000, guid: 66163cf35956a4be08e801b750c26f33, type: 2}
myLaser: {fileID: 1081721624670010}
myLaser: {fileID: 1045923826166930}
contribute: 0
useVectorObs: 1
--- !u!114 &114374774605792098

vectorObservationSize: 53
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
cameraResolutions: []
vectorActionDescriptions: []
vectorActionSpaceType: 0
m_Model: {fileID: 11400000, guid: d32fca21cf4c04536ab7f88eb9de83e0, type: 3}

vectorObservationSize: 53
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
cameraResolutions: []
vectorActionDescriptions: []
vectorActionSpaceType: 0
m_Model: {fileID: 11400000, guid: d32fca21cf4c04536ab7f88eb9de83e0, type: 3}

m_Name:
m_EditorClassIdentifier:
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

badMaterial: {fileID: 2100000, guid: 88b9ae7af2c1748a0a1f63407587a601, type: 2}
goodMaterial: {fileID: 2100000, guid: c67450f290f3e4897bc40276a619e78d, type: 2}
frozenMaterial: {fileID: 2100000, guid: 66163cf35956a4be08e801b750c26f33, type: 2}
myLaser: {fileID: 1081721624670010}
myLaser: {fileID: 1421240237750412}
contribute: 0
useVectorObs: 1
--- !u!114 &114661830999747712

m_Name:
m_EditorClassIdentifier:
agentParameters:
agentCameras: []
agentRenderTextures: []
maxStep: 5000
resetOnDone: 1
onDemandDecision: 0

badMaterial: {fileID: 2100000, guid: 88b9ae7af2c1748a0a1f63407587a601, type: 2}
goodMaterial: {fileID: 2100000, guid: c67450f290f3e4897bc40276a619e78d, type: 2}
frozenMaterial: {fileID: 2100000, guid: 66163cf35956a4be08e801b750c26f33, type: 2}
myLaser: {fileID: 1081721624670010}
myLaser: {fileID: 1941433838307300}
contribute: 0
useVectorObs: 1
--- !u!114 &114762047763154270

vectorObservationSize: 53
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
cameraResolutions: []
vectorActionDescriptions: []
vectorActionSpaceType: 0
m_Model: {fileID: 11400000, guid: d32fca21cf4c04536ab7f88eb9de83e0, type: 3}

vectorObservationSize: 53
numStackedVectorObservations: 1
vectorActionSize: 03000000030000000300000002000000
cameraResolutions: []
vectorActionDescriptions: []
vectorActionSpaceType: 0
m_Model: {fileID: 11400000, guid: d32fca21cf4c04536ab7f88eb9de83e0, type: 3}

5
UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scenes/FoodCollector.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44971162, g: 0.49977726, b: 0.5756362, a: 1}
m_IndirectSpecularColor: {r: 0.4497121, g: 0.4997778, b: 0.5756369, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

m_Script: {fileID: 11500000, guid: 4fe57113e76a5426297487dd6faadc5b, type: 3}
m_Name:
m_EditorClassIdentifier:
broadcastHub:
brainsToControl:
- {fileID: 11400000, guid: 9e7865ec29c894c2d8c1617b0fa392f9, type: 2}
m_TrainingConfiguration:
width: 500
height: 500

2
UnitySDK/Assets/ML-Agents/Scripts/Academy.cs


"docs/Learning-Environment-Design-Academy.md")]
public abstract class Academy : MonoBehaviour
{
const string k_ApiVersion = "API-10";
const string k_ApiVersion = "API-11";
/// Temporary storage for global gravity value
/// Used to restore oringal value when deriving Academy modifies it

12
UnitySDK/Assets/ML-Agents/Scripts/Agent.cs


/// of the environment extracts its current observation, sends them to its
/// policy and in return receives an action. In practice,
/// however, an agent need not send its observation at every step since very
/// little may have changed between successive steps.
/// little may have changed between successive steps.
///
/// At any step, an agent may be considered <see cref="m_Done"/>.
/// This could occur due to a variety of reasons:

/// <summary>
/// Updates the Model for the agent. Any model currently assigned to the
/// agent will be replaced with the provided one. If the arguments are
/// agent will be replaced with the provided one. If the arguments are
/// remain unchanged.
/// remain unchanged.
/// <param name="behaviorName"> The identifier of the behavior. This
/// will categorize the agent when training.
/// <param name="behaviorName"> The identifier of the behavior. This
/// will categorize the agent when training.
/// <param name = "inferenceDevice"> Define on what device the model
/// <param name = "inferenceDevice"> Define on what device the model
/// will be run.</param>
public void GiveModel(
string behaviorName,

4
UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs


}
}
public CompressionType GetCompressionType()
public SensorCompressionType GetCompressionType()
return CompressionType.PNG;
return SensorCompressionType.PNG;
}
/// <summary>

2
UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs


/// <summary>
/// The format of the compressed data
/// </summary>
public CompressionType CompressionType;
public SensorCompressionType CompressionType;
/// <summary>
/// The uncompressed dimensions of the data.

6
UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs


namespace MLAgents.Sensor
{
public enum CompressionType
public enum SensorCompressionType
{
None,
PNG

byte[] GetCompressedObservation();
/// <summary>
/// Return the compression type being used. If no compression is used, return CompressionType.None
/// Return the compression type being used. If no compression is used, return SensorCompressionType.None
CompressionType GetCompressionType();
SensorCompressionType GetCompressionType();
/// <summary>
/// Get the name of the sensor. This is used to ensure deterministic sorting of the sensors on an Agent,

4
UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs


}
}
public CompressionType GetCompressionType()
public SensorCompressionType GetCompressionType()
return CompressionType.PNG;
return SensorCompressionType.PNG;
}
/// <summary>

4
UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs


return null;
}
public virtual CompressionType GetCompressionType()
public virtual SensorCompressionType GetCompressionType()
return CompressionType.None;
return SensorCompressionType.None;
}
}
}

2
gym-unity/setup.py


from setuptools import setup, find_packages
from setuptools.command.install import install
VERSION = "0.11.0.dev0"
VERSION = "0.11.0"
class VerifyVersionCommand(install):

3
ml-agents-envs/mlagents/envs/environment.py


SCALAR_ACTION_TYPES = (int, np.int32, np.int64, float, np.float32, np.float64)
SINGLE_BRAIN_ACTION_TYPES = SCALAR_ACTION_TYPES + (list, np.ndarray)
SINGLE_BRAIN_TEXT_TYPES = list
API_VERSION = "API-11"
def __init__(
self,

atexit.register(self._close)
self.port = base_port + worker_id
self._buffer_size = 12000
self._version_ = "API-10"
self._version_ = UnityEnvironment.API_VERSION
self._loaded = (
False
) # If true, this means the environment was successfully loaded

6
ml-agents-envs/mlagents/envs/mock_communicator.py


from .communicator import Communicator
from .environment import UnityEnvironment
from mlagents.envs.communicator_objects.unity_rl_output_pb2 import UnityRLOutputProto
from mlagents.envs.communicator_objects.brain_parameters_pb2 import BrainParametersProto
from mlagents.envs.communicator_objects.unity_rl_initialization_output_pb2 import (

is_training=True,
)
rl_init = UnityRLInitializationOutputProto(
name="RealFakeAcademy", version="API-10", log_path="", brain_parameters=[bp]
name="RealFakeAcademy",
version=UnityEnvironment.API_VERSION,
log_path="",
brain_parameters=[bp],
)
output = UnityRLOutputProto(agentInfos=self._get_agent_infos())
return UnityOutputProto(rl_initialization_output=rl_init, rl_output=output)

2
ml-agents-envs/setup.py


from setuptools import setup
from setuptools.command.install import install
VERSION = "0.11.0.dev0"
VERSION = "0.11.0"
here = os.path.abspath(os.path.dirname(__file__))

2
ml-agents/setup.py


from setuptools import setup, find_namespace_packages
from setuptools.command.install import install
VERSION = "0.11.0.dev0"
VERSION = "0.11.0"
here = os.path.abspath(os.path.dirname(__file__))

55
run-standalone-build-osx.sh


set -eo pipefail
EDITOR_VERSION="2017.4.33f1"
BOKKEN_UNITY="/Users/bokken/${EDITOR_VERSION}/Unity.app/Contents/MacOS/Unity"
HUB_UNITY="/Applications/Unity/Hub/Editor/${EDITOR_VERSION}/Unity.app/Contents/MacOS/Unity"
if [[ -z "${UNITY_VERSION}" ]]; then
if [[ -f ${BOKKEN_UNITY} ]]; then
UNITY=${BOKKEN_UNITY}
echo "Environment Variable UNITY_VERSION was not set"
exit 1
UNITY=${HUB_UNITY}
fi
BOKKEN_UNITY="/Users/bokken/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
HUB_UNITY="/Applications/Unity/Hub/Editor/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
pushd $(dirname "${0}") > /dev/null
BASETPATH=$(pwd -L)
popd > /dev/null
if [[ -f ${BOKKEN_UNITY} ]]; then
UNITY=${BOKKEN_UNITY}
else
UNITY=${HUB_UNITY}
fi
pushd $(dirname "${0}") > /dev/null
BASETPATH=$(pwd -L)
popd > /dev/null
echo "Cleaning previous results"
echo "Starting tests via $UNITY"
echo "Cleaning previous results"
CMD_LINE="$UNITY -projectPath $BASETPATH/UnitySDK -logfile - -batchmode -executeMethod MLAgents.StandaloneBuildTest.BuildStandalonePlayerOSX"
echo "Starting tests via $UNITY"
echo "$CMD_LINE ..."
CMD_LINE="$UNITY -projectPath $BASETPATH/UnitySDK -batchmode -executeMethod MLAgents.StandaloneBuildTest.BuildStandalonePlayerOSX"
${CMD_LINE}
RES=$?
echo "$CMD_LINE ..."
if [[ "${RES}" -eq "0" ]]; then
echo "Standalone build completed successfully.";
exit 0;
else
echo "Standalone build failed."
exit 1;
fi
${CMD_LINE}
RES=$?
exit ${RES}
if [[ "${RES}" -eq "0" ]]; then
echo "Standalone build completed successfully.";
exit 0;
else
echo "Standalone build failed."
exit 1;
exit ${RES}

71
run-tests-editmode-osx-editor.sh


set -eo pipefail
EDITOR_VERSION="2017.4.33f1"
BOKKEN_UNITY="/Users/bokken/${EDITOR_VERSION}/Unity.app/Contents/MacOS/Unity"
HUB_UNITY="/Applications/Unity/Hub/Editor/${EDITOR_VERSION}/Unity.app/Contents/MacOS/Unity"
if [[ -z "${UNITY_VERSION}" ]]; then
echo "Environment Variable UNITY_VERSION was not set"
exit 1
if [[ -f ${BOKKEN_UNITY} ]]; then
UNITY=${BOKKEN_UNITY}
UNITY=${HUB_UNITY}
fi
BOKKEN_UNITY="/Users/bokken/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
HUB_UNITY="/Applications/Unity/Hub/Editor/${UNITY_VERSION}/Unity.app/Contents/MacOS/Unity"
pushd $(dirname "${0}") > /dev/null
BASETPATH=$(pwd -L)
popd > /dev/null
if [[ -f ${BOKKEN_UNITY} ]]; then
UNITY=${BOKKEN_UNITY}
else
UNITY=${HUB_UNITY}
fi
echo "Cleaning previous results"
pushd $(dirname "${0}") > /dev/null
BASETPATH=$(pwd -L)
popd > /dev/null
if [[ -e ${BASETPATH}/results.xml ]]
then
rm ${BASETPATH}/results.xml
fi
echo "Cleaning previous results"
if [[ -e ${BASETPATH}/results.xml ]]
then
rm ${BASETPATH}/results.xml
fi
echo "Starting tests via $UNITY"
echo "Starting tests via $UNITY"
CMD_LINE="$UNITY -runTests -logfile - -projectPath $BASETPATH/UnitySDK -testResults $BASETPATH/results.xml -testPlatform editmode"
CMD_LINE="$UNITY -runTests -projectPath $BASETPATH/UnitySDK -testResults $BASETPATH/results.xml -testPlatform editmode"
echo "$CMD_LINE ..."
echo "$CMD_LINE ..."
$CMD_LINE
RES=$?
$CMD_LINE
RES=$?
TOTAL=$(echo 'cat /test-run/test-suite/@total' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
PASSED=$(echo 'cat /test-run/test-suite/@passed' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
FAILED=$(echo 'cat /test-run/test-suite/@failed' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
DURATION=$(echo 'cat /test-run/test-suite/@duration' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
TOTAL=$(echo 'cat /test-run/test-suite/@total' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
PASSED=$(echo 'cat /test-run/test-suite/@passed' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
FAILED=$(echo 'cat /test-run/test-suite/@failed' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
DURATION=$(echo 'cat /test-run/test-suite/@duration' | xmllint --shell results.xml | awk -F'[="]' '!/>/{print $(NF-1)}')
echo "$TOTAL tests executed in ${DURATION}s: $PASSED passed, $FAILED failed. More details in results.xml"
echo "$TOTAL tests executed in ${DURATION}s: $PASSED passed, $FAILED failed. More details in results.xml"
if [[ ${RES} -eq 0 ]] && [[ -e ${BASETPATH}/results.xml ]]; then
echo "Test run SUCCEEDED!"
else
echo "Test run FAILED!"
fi
if [[ ${RES} -eq 0 ]] && [[ -e ${BASETPATH}/results.xml ]]; then
echo "Test run SUCCEEDED!"
else
echo "Test run FAILED!"
fi
rm "${BASETPATH}/results.xml"
rm "${BASETPATH}/results.xml"
exit ${RES}
exit ${RES}
fi

2
test_constraints_max_version.txt


# For projects with upper bounds, we should periodically update this list to the latest release version
grpcio>=1.23.0
numpy>=1.17.2
tensorflow>=1.14.0
tensorflow>=1.14.0,<2.0
正在加载...
取消
保存