| using System; |
| using Unity.MLAgents.Analytics; |
| using Unity.MLAgents.CommunicatorObjects; |
|
|
| namespace Unity.MLAgents.SideChannels |
| { |
| |
| |
| |
| internal class TrainingAnalyticsSideChannel : SideChannel |
| { |
| const string k_TrainingAnalyticsConfigId = "b664a4a9-d86f-5a5f-95cb-e8353a7e8356"; |
|
|
| |
| |
| |
| |
| internal TrainingAnalyticsSideChannel() |
| { |
| ChannelId = new Guid(k_TrainingAnalyticsConfigId); |
| } |
|
|
| |
| protected override void OnMessageReceived(IncomingMessage msg) |
| { |
| Google.Protobuf.WellKnownTypes.Any anyMessage = null; |
| try |
| { |
| anyMessage = Google.Protobuf.WellKnownTypes.Any.Parser.ParseFrom(msg.GetRawBytes()); |
| } |
| catch (Google.Protobuf.InvalidProtocolBufferException) |
| { |
| |
| return; |
| } |
|
|
| if (anyMessage.Is(TrainingEnvironmentInitialized.Descriptor)) |
| { |
| var envInitProto = anyMessage.Unpack<TrainingEnvironmentInitialized>(); |
| var envInitEvent = envInitProto.ToTrainingEnvironmentInitializedEvent(); |
| TrainingAnalytics.TrainingEnvironmentInitialized(envInitEvent); |
| } |
| else if (anyMessage.Is(TrainingBehaviorInitialized.Descriptor)) |
| { |
| var behaviorInitProto = anyMessage.Unpack<TrainingBehaviorInitialized>(); |
| var behaviorTrainingEvent = behaviorInitProto.ToTrainingBehaviorInitializedEvent(); |
| TrainingAnalytics.TrainingBehaviorInitialized(behaviorTrainingEvent); |
| } |
| |
| } |
| } |
| } |
|
|