From 911105b45116caee4dfdf9bd9a0e53e544e682f6 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Tue, 15 Sep 2020 21:27:54 -0700 Subject: [PATCH 1/3] Don't call NotifyDone in Agent.OnDisable if Academy is shut down --- com.unity.ml-agents/Runtime/Agent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.ml-agents/Runtime/Agent.cs b/com.unity.ml-agents/Runtime/Agent.cs index 9319a9a5ac..0912062224 100644 --- a/com.unity.ml-agents/Runtime/Agent.cs +++ b/com.unity.ml-agents/Runtime/Agent.cs @@ -491,8 +491,8 @@ protected virtual void OnDisable() Academy.Instance.DecideAction -= DecideAction; Academy.Instance.AgentAct -= AgentStep; Academy.Instance.AgentForceReset -= _AgentReset; + NotifyAgentDone(DoneReason.Disabled); } - NotifyAgentDone(DoneReason.Disabled); m_Brain?.Dispose(); m_Initialized = false; } From 3c8cacfa32459729cadf01eb1faf146a337d6212 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Tue, 15 Sep 2020 21:38:17 -0700 Subject: [PATCH 2/3] changelog --- com.unity.ml-agents/CHANGELOG.md | 2 ++ com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/com.unity.ml-agents/CHANGELOG.md b/com.unity.ml-agents/CHANGELOG.md index 485ef96d21..6ba1bc025e 100755 --- a/com.unity.ml-agents/CHANGELOG.md +++ b/com.unity.ml-agents/CHANGELOG.md @@ -49,6 +49,8 @@ your trainer configuration to do so. (#4448) #### com.unity.ml-agents (C#) - Previously, `com.unity.ml-agents` was not declaring built-in packages as dependencies in its package.json. The relevant dependencies are now listed. (#4384) +- Agents no longer try to send observations when they become disabled if the +Academy has been shut down. (#4489) #### ml-agents / ml-agents-envs / gym-unity (Python) - Fixed the sample code in the custom SideChannel example. (#4466) - A bug in the observation normalizer that would cause rewards to decrease diff --git a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs index 28db75fea1..6164ce6e7c 100644 --- a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs @@ -314,6 +314,10 @@ public void DecideBatch() /// Sensors that will produce the observations public void PutObservations(string behaviorName, AgentInfo info, List sensors) { + if (!m_IsOpen) + { + reutrn + } #if DEBUG if (!m_SensorShapeValidators.ContainsKey(behaviorName)) { From d8776da99feb6fb5d92f5f9ab922ba6380069406 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Tue, 15 Sep 2020 21:39:57 -0700 Subject: [PATCH 3/3] undo change to RpcCommunicator --- com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs index 6164ce6e7c..28db75fea1 100644 --- a/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs +++ b/com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs @@ -314,10 +314,6 @@ public void DecideBatch() /// Sensors that will produce the observations public void PutObservations(string behaviorName, AgentInfo info, List sensors) { - if (!m_IsOpen) - { - reutrn - } #if DEBUG if (!m_SensorShapeValidators.ContainsKey(behaviorName)) {