Skip to content

Commit

Permalink
[MLA-1587] Don't warn about minor version mismatch, add links in spec…
Browse files Browse the repository at this point in the history
…ific messages (#4688)

* Don't warn about minor version mismatch, add links in specific messages

* changelog

* fix tests
  • Loading branch information
Chris Elion authored Dec 15, 2020
1 parent 258f4dc commit 0ecb67f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
1 change: 1 addition & 0 deletions com.unity.ml-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Please refer to "Information that is passively collected by Unity" in the

### 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)


Expand Down
14 changes: 11 additions & 3 deletions com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 2 additions & 10 deletions com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 6 additions & 9 deletions ml-agents-envs/mlagents_envs/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 0ecb67f

Please sign in to comment.