浏览代码

Fixes package validation errors for side-channels-related classes. (#3502)

* Fixes package validation errors for side-channels-related classes.
/asymm-envs
GitHub 5 年前
当前提交
f3d02dda
共有 5 个文件被更改,包括 36 次插入2 次删除
  1. 8
      com.unity.ml-agents/Runtime/SideChannel/EngineConfigurationChannel.cs
  2. 16
      com.unity.ml-agents/Runtime/SideChannel/FloatPropertiesChannel.cs
  3. 5
      com.unity.ml-agents/Runtime/SideChannel/RawBytesChannel.cs
  4. 7
      com.unity.ml-agents/Runtime/SideChannel/SideChannel.cs
  5. 2
      com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs

8
com.unity.ml-agents/Runtime/SideChannel/EngineConfigurationChannel.cs


namespace MLAgents
{
/// <summary>
/// Side channel that supports modifying attributes specific to the Unity Engine.
/// </summary>
/// <summary>
/// Initializes the side channel.
/// </summary>
/// <inheritdoc/>
public override void OnMessageReceived(byte[] data)
{
using (var memStream = new MemoryStream(data))

16
com.unity.ml-agents/Runtime/SideChannel/FloatPropertiesChannel.cs


namespace MLAgents
{
/// <summary>
/// Interface for managing a collection of float properties keyed by a string variable.
/// </summary>
public interface IFloatProperties
{
/// <summary>

IList<string> ListProperties();
}
/// <summary>
/// Side channel that is comprised of a collection of float variables, represented by
/// <see cref="IFloatProperties"/>
/// </summary>
public class FloatPropertiesChannel : SideChannel, IFloatProperties
{
Dictionary<string, float> m_FloatProperties = new Dictionary<string, float>();

/// <summary>
/// Initializes the side channel with the provided channel ID.
/// </summary>
/// <param name="channelId">ID for the side channel.</param>
public FloatPropertiesChannel(Guid channelId = default(Guid))
{
if (channelId == default(Guid))

}
}
/// <inheritdoc/>
public override void OnMessageReceived(byte[] data)
{
var kv = DeserializeMessage(data);

}
}
/// <inheritdoc/>
public void SetProperty(string key, float value)
{
m_FloatProperties[key] = value;

}
}
/// <inheritdoc/>
public float GetPropertyWithDefault(string key, float defaultValue)
{
if (m_FloatProperties.ContainsKey(key))

}
}
/// <inheritdoc/>
/// <inheritdoc/>
public IList<string> ListProperties()
{
return new List<string>(m_FloatProperties.Keys);

5
com.unity.ml-agents/Runtime/SideChannel/RawBytesChannel.cs


namespace MLAgents
{
/// <summary>
/// Side channel for managing raw bytes of data. It is up to the clients of this side channel
/// to interpret the messages.
/// </summary>
public class RawBytesChannel : SideChannel
{
List<byte[]> m_MessagesReceived = new List<byte[]>();

ChannelId = channelId;
}
/// <inheritdoc/>
public override void OnMessageReceived(byte[] data)
{
m_MessagesReceived.Add(data);

7
com.unity.ml-agents/Runtime/SideChannel/SideChannel.cs


namespace MLAgents
{
/// <summary>
/// Side channels provide an alternative mechanism of sending/receiving data from Unity
/// to Python that is outside of the traditional machine learning loop. ML-Agents provides
/// some specific implementations of side channels, but users can create their own.
/// </summary>
public abstract class SideChannel
{
// The list of messages (byte arrays) that need to be sent to Python via the communicator.

/// An int identifier for the SideChannel. Ensures that there is only ever one side channel
/// of each type. Ensure the Unity side channels will be linked to their Python equivalent.
/// </summary>
/// <returns> The integer identifier of the SideChannel</returns>
/// <returns> The integer identifier of the SideChannel.</returns>
public Guid ChannelId{
get;
protected set;

2
com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs


}
[Test]
public void TestStoreInitalize()
public void TestStoreInitialize()
{
var fileSystem = new MockFileSystem();

正在加载...
取消
保存