Skip to content

Commit 6c253e3

Browse files
author
Chris Elion
committed
[MLA-1587] Don't warn about minor version mismatch, add links in specific messages (#4688)
* Don't warn about minor version mismatch, add links in specific messages * changelog * fix tests
1 parent f74faae commit 6c253e3

File tree

5 files changed

+21
-25
lines changed

5 files changed

+21
-25
lines changed

com.unity.ml-agents/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ both continuous and discrete action sizes in Behavior Parameters. (#4702, #4718)
2121

2222
### Bug Fixes
2323
#### com.unity.ml-agents (C#)
24+
- Removed noisy warnings about API minor version mismatches in both the C# and python code. (#4688)
2425
#### ml-agents / ml-agents-envs / gym-unity (Python)
2526

2627

com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ public static ObservationProto GetObservationProto(this ISensor sensor, Observat
302302
{
303303
if (!s_HaveWarnedTrainerCapabilitiesMultiPng)
304304
{
305-
Debug.LogWarning($"Attached trainer doesn't support multiple PNGs. Switching to uncompressed observations for sensor {sensor.GetName()}.");
305+
Debug.LogWarning(
306+
$"Attached trainer doesn't support multiple PNGs. Switching to uncompressed observations for sensor {sensor.GetName()}. " +
307+
"Please find the versions that work best together from our release page: " +
308+
"https://github.com/Unity-Technologies/ml-agents/releases"
309+
);
306310
s_HaveWarnedTrainerCapabilitiesMultiPng = true;
307311
}
308312
compressionType = SensorCompressionType.None;
@@ -317,9 +321,13 @@ public static ObservationProto GetObservationProto(this ISensor sensor, Observat
317321
{
318322
if (!s_HaveWarnedTrainerCapabilitiesMapping)
319323
{
320-
Debug.LogWarning($"The sensor {sensor.GetName()} is using non-trivial mapping and " +
324+
Debug.LogWarning(
325+
$"The sensor {sensor.GetName()} is using non-trivial mapping and " +
321326
"the attached trainer doesn't support compression mapping. " +
322-
"Switching to uncompressed observations.");
327+
"Switching to uncompressed observations. " +
328+
"Please find the versions that work best together from our release page: " +
329+
"https://github.com/Unity-Technologies/ml-agents/releases"
330+
);
323331
s_HaveWarnedTrainerCapabilitiesMapping = true;
324332
}
325333
compressionType = SensorCompressionType.None;

com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,8 @@ internal static bool CheckCommunicationVersionsAreCompatible(
8282
}
8383
else if (unityVersion.Minor != pythonVersion.Minor)
8484
{
85-
// Even if we initialize, we still want to check to make sure that we inform users of minor version
86-
// changes. This will surface any features that may not work due to minor version incompatibilities.
87-
Debug.LogWarningFormat(
88-
"WARNING: The communication API versions between Unity and python differ at the minor version level. " +
89-
"Python API: {0}, Unity API: {1} Python Library Version: {2} .\n" +
90-
"This means that some features may not work unless you upgrade the package with the lower version." +
91-
"Please find the versions that work best together from our release page.\n" +
92-
"https://github.com/Unity-Technologies/ml-agents/releases",
93-
pythonApiVersion, unityCommunicationVersion, pythonLibraryVersion
94-
);
85+
// If a feature is used in Unity but not supported in the trainer,
86+
// we will warn at the point it's used. Don't warn here to avoid noise.
9587
}
9688
return true;
9789
}

com.unity.ml-agents/Tests/Editor/Communicator/RpcCommunicatorTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ public void TestCheckCommunicationVersionsAreCompatible()
2626
Assert.IsTrue(RpcCommunicator.CheckCommunicationVersionsAreCompatible(unityVerStr,
2727
pythonVerStr,
2828
pythonPackageVerStr));
29-
30-
// Ensure that a warning was printed.
31-
LogAssert.Expect(LogType.Warning, new Regex("(.\\s)+"));
29+
LogAssert.NoUnexpectedReceived();
3230

3331
unityVerStr = "2.0.0";
3432
Assert.IsFalse(RpcCommunicator.CheckCommunicationVersionsAreCompatible(unityVerStr,

ml-agents-envs/mlagents_envs/environment.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,13 @@ def _check_communication_compatibility(
100100
elif unity_communicator_version.version[0] != api_version.version[0]:
101101
# Major versions mismatch.
102102
return False
103-
elif unity_communicator_version.version[1] != api_version.version[1]:
104-
# Non-beta minor versions mismatch. Log a warning but allow execution to continue.
105-
logger.warning(
106-
f"WARNING: The communication API versions between Unity and python differ at the minor version level. "
107-
f"Python API: {python_api_version}, Unity API: {unity_communicator_version}.\n"
108-
f"This means that some features may not work unless you upgrade the package with the lower version."
109-
f"Please find the versions that work best together from our release page.\n"
110-
"https://github.com/Unity-Technologies/ml-agents/releases"
111-
)
112103
else:
104+
# Major versions match, so either:
105+
# 1) The versions are identical, in which case there's no compatibility issues
106+
# 2) The Unity version is newer, in which case we'll warn or fail on the Unity side if trying to use
107+
# unsupported features
108+
# 3) The trainer version is newer, in which case new trainer features might be available but unused by C#
109+
# In any of the cases, there's no reason to warn about mismatch here.
113110
logger.info(
114111
f"Connected to Unity environment with package version {unity_package_version} "
115112
f"and communication version {unity_com_ver}"

0 commit comments

Comments
 (0)