From 90d4630b0b193331ee5cc89fbeef94f139612954 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Mon, 28 Oct 2019 09:30:20 -0700 Subject: [PATCH 1/2] rename CompressionType enum --- .../ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs | 4 ++-- UnitySDK/Assets/ML-Agents/Scripts/Agent.cs | 12 ++++++------ .../Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs | 4 ++-- .../Scripts/Sensor/CompressedObservation.cs | 3 +-- UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs | 6 +++--- .../ML-Agents/Scripts/Sensor/RenderTextureSensor.cs | 4 ++-- .../Assets/ML-Agents/Scripts/Sensor/SensorBase.cs | 4 ++-- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs b/UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs index 3f0be7f596..a5602f2a03 100644 --- a/UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs +++ b/UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs @@ -93,9 +93,9 @@ public byte[] GetCompressedObservation() return null; } - public CompressionType GetCompressionType() + public SensorCompressionType GetCompressionType() { - return CompressionType.None; + return SensorCompressionType.None; } public string GetName() diff --git a/UnitySDK/Assets/ML-Agents/Scripts/Agent.cs b/UnitySDK/Assets/ML-Agents/Scripts/Agent.cs index d05a65526b..f8abf6dfd6 100644 --- a/UnitySDK/Assets/ML-Agents/Scripts/Agent.cs +++ b/UnitySDK/Assets/ML-Agents/Scripts/Agent.cs @@ -160,7 +160,7 @@ public class AgentParameters /// 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 . /// This could occur due to a variety of reasons: @@ -328,15 +328,15 @@ void OnDisable() /// /// 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 /// identical to the current parameters of the agent, the model will - /// remain unchanged. + /// remain unchanged. /// - /// The identifier of the behavior. This - /// will categorize the agent when training. + /// The identifier of the behavior. This + /// will categorize the agent when training. /// /// The model to use for inference. - /// Define on what device the model + /// Define on what device the model /// will be run. public void GiveModel( string behaviorName, diff --git a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs index fd11898f93..574f226a81 100644 --- a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs +++ b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs @@ -55,9 +55,9 @@ public void WriteToTensor(TensorProxy tensorProxy, int agentIndex) } } - public CompressionType GetCompressionType() + public SensorCompressionType GetCompressionType() { - return CompressionType.PNG; + return SensorCompressionType.PNG; } /// diff --git a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs index b1db192c13..5dfe6f85bf 100644 --- a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs +++ b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs @@ -1,5 +1,4 @@ using System; -using MLAgents.InferenceBrain; using UnityEngine; namespace MLAgents.Sensor @@ -14,7 +13,7 @@ public struct CompressedObservation /// /// The format of the compressed data /// - public CompressionType CompressionType; + public SensorCompressionType CompressionType; /// /// The uncompressed dimensions of the data. diff --git a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs index 0a1040f4ab..49f8068955 100644 --- a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs +++ b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs @@ -2,7 +2,7 @@ namespace MLAgents.Sensor { - public enum CompressionType + public enum SensorCompressionType { None, PNG, @@ -38,10 +38,10 @@ public interface ISensor { byte[] GetCompressedObservation(); /// - /// 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(); /// /// Get the name of the sensor. This is used to ensure deterministic sorting of the sensors on an Agent, diff --git a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs index 424d692a45..871854c809 100644 --- a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs +++ b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs @@ -56,9 +56,9 @@ public void WriteToTensor(TensorProxy tensorProxy, int index) } } - public CompressionType GetCompressionType() + public SensorCompressionType GetCompressionType() { - return CompressionType.PNG; + return SensorCompressionType.PNG; } /// diff --git a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs index cb3de11d94..15eb53bee6 100644 --- a/UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs +++ b/UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs @@ -46,9 +46,9 @@ public virtual byte[] GetCompressedObservation() return null; } - public virtual CompressionType GetCompressionType() + public virtual SensorCompressionType GetCompressionType() { - return CompressionType.None; + return SensorCompressionType.None; } } } From eeaa506d617c108a17a9b4851d5d6e028ce7f3ea Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Mon, 28 Oct 2019 09:43:02 -0700 Subject: [PATCH 2/2] fix standalone build test for 2018+ --- .../Editor/Tests/StandaloneBuildTest.cs | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs b/UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs index b344a62c24..d88aacbd43 100644 --- a/UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs +++ b/UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs @@ -1,6 +1,9 @@ using System; using UnityEditor; using UnityEngine; +#if UNITY_2018_1_OR_NEWER +using UnityEditor.Build.Reporting; +#endif namespace MLAgents { @@ -9,8 +12,25 @@ public class StandaloneBuildTest static void BuildStandalonePlayerOSX() { 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); } @@ -18,10 +38,11 @@ static void BuildStandalonePlayerOSX() { Console.Error.WriteLine(error); EditorApplication.Exit(1); - + } Debug.Log(error); + } - + } }