From 39a45473d4f6d28957563920faae45fffd2b7a51 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Tue, 15 Dec 2020 10:31:58 -0800 Subject: [PATCH] [MLA-1587] Don't warn about minor version mismatch, add links in specific messages (#4688) (#4759) * Don't warn about minor version mismatch, add links in specific messages * changelog * fix tests --- com.unity.ml-agents/CHANGELOG.md | 1 + .../Runtime/Communicator/GrpcExtensions.cs | 14 +++++++++++--- .../Runtime/Communicator/RpcCommunicator.cs | 12 ++---------- .../Editor/Communicator/RpcCommunicatorTests.cs | 4 +--- ml-agents-envs/mlagents_envs/environment.py | 15 ++++++--------- 5 files changed, 21 insertions(+), 25 deletions(-) diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 6b8ac35680..551632b17d 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -21,6 +21,7 @@ both continuous and discrete action sizes in Behavior Parameters. (#4702, #4718) ### Bug Fixes #### com.unity.ml-agents (C#) +- Removed noisy warnings about API minor version mismatches in both the C# and python code. (#4688) #### ml-agents / ml-agents-envs / gym-unity (Python) diff --git a/com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs b/com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs index 6bc493c91f..2693c0b7e8 100644 --- a/com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs +++ b/com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs @@ -302,7 +302,11 @@ public static ObservationProto GetObservationProto(this ISensor sensor, Observat { if (!s_HaveWarnedTrainerCapabilitiesMultiPng) { - Debug.LogWarning($"Attached trainer doesn't support multiple PNGs. Switching to uncompressed observations for sensor {sensor.GetName()}."); + Debug.LogWarning( + $"Attached trainer doesn't support multiple PNGs. Switching to uncompressed observations for sensor {sensor.GetName()}. " + + "Please find the versions that work best together from our release page: " + + "https://github.com/Unity-Technologies/ml-agents/releases" + ); s_HaveWarnedTrainerCapabilitiesMultiPng = true; } compressionType = SensorCompressionType.None; @@ -317,9 +321,13 @@ public static ObservationProto GetObservationProto(this ISensor sensor, Observat { if (!s_HaveWarnedTrainerCapabilitiesMapping) { - Debug.LogWarning($"The sensor {sensor.GetName()} is using non-trivial mapping and " + + Debug.LogWarning( + $"The sensor {sensor.GetName()} is using non-trivial mapping and " + "the attached trainer doesn't support compression mapping. " + - "Switching to uncompressed observations."); + "Switching to uncompressed observations. " + + "Please find the versions that work best together from our release page: " + + "https://github.com/Unity-Technologies/ml-agents/releases" + ); s_HaveWarnedTrainerCapabilitiesMapping = true; } compressionType = SensorCompressionType.None; diff --git a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs index b1719ba8e8..20165bf417 100644 --- a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs @@ -82,16 +82,8 @@ internal static bool CheckCommunicationVersionsAreCompatible( } else if (unityVersion.Minor != pythonVersion.Minor) { - // Even if we initialize, we still want to check to make sure that we inform users of minor version - // changes. This will surface any features that may not work due to minor version incompatibilities. - Debug.LogWarningFormat( - "WARNING: The communication API versions between Unity and python differ at the minor version level. " + - "Python API: {0}, Unity API: {1} Python Library Version: {2} .\n" + - "This means that some features may not work unless you upgrade the package with the lower version." + - "Please find the versions that work best together from our release page.\n" + - "https://github.com/Unity-Technologies/ml-agents/releases", - pythonApiVersion, unityCommunicationVersion, pythonLibraryVersion - ); + // If a feature is used in Unity but not supported in the trainer, + // we will warn at the point it's used. Don't warn here to avoid noise. } return true; } diff --git a/com.unity.ml-agents/Tests/Editor/Communicator/RpcCommunicatorTests.cs b/com.unity.ml-agents/Tests/Editor/Communicator/RpcCommunicatorTests.cs index 303766ab7a..3dee08bc49 100644 --- a/com.unity.ml-agents/Tests/Editor/Communicator/RpcCommunicatorTests.cs +++ b/com.unity.ml-agents/Tests/Editor/Communicator/RpcCommunicatorTests.cs @@ -26,9 +26,7 @@ public void TestCheckCommunicationVersionsAreCompatible() Assert.IsTrue(RpcCommunicator.CheckCommunicationVersionsAreCompatible(unityVerStr, pythonVerStr, pythonPackageVerStr)); - - // Ensure that a warning was printed. - LogAssert.Expect(LogType.Warning, new Regex("(.\\s)+")); + LogAssert.NoUnexpectedReceived(); unityVerStr = "2.0.0"; Assert.IsFalse(RpcCommunicator.CheckCommunicationVersionsAreCompatible(unityVerStr, diff --git a/ml-agents-envs/mlagents_envs/environment.py b/ml-agents-envs/mlagents_envs/environment.py index e51ffd67de..ad07e6e4b3 100644 --- a/ml-agents-envs/mlagents_envs/environment.py +++ b/ml-agents-envs/mlagents_envs/environment.py @@ -100,16 +100,13 @@ def _check_communication_compatibility( elif unity_communicator_version.version[0] != api_version.version[0]: # Major versions mismatch. return False - elif unity_communicator_version.version[1] != api_version.version[1]: - # Non-beta minor versions mismatch. Log a warning but allow execution to continue. - logger.warning( - f"WARNING: The communication API versions between Unity and python differ at the minor version level. " - f"Python API: {python_api_version}, Unity API: {unity_communicator_version}.\n" - f"This means that some features may not work unless you upgrade the package with the lower version." - f"Please find the versions that work best together from our release page.\n" - "https://github.com/Unity-Technologies/ml-agents/releases" - ) else: + # Major versions match, so either: + # 1) The versions are identical, in which case there's no compatibility issues + # 2) The Unity version is newer, in which case we'll warn or fail on the Unity side if trying to use + # unsupported features + # 3) The trainer version is newer, in which case new trainer features might be available but unused by C# + # In any of the cases, there's no reason to warn about mismatch here. logger.info( f"Connected to Unity environment with package version {unity_package_version} " f"and communication version {unity_com_ver}"