-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Side Channel Design Changes #3807
Conversation
Missing: Python conterparts and testing.
- Disallow two sidechannels of the same type to be added - Remove GetSideChannels that return a list as that is now unnecessary - Make most methods except (register/unregister) internal to limit users impacting the “system-level” side channels - Add an improved comment to SideChannel.cs
- Specifically to StatsRecorder, EnvironmentParameters and EngineParameters. - Updated Academy.Dispose to take advantage of these. - Updated Editor tests to cover all three “system-level” side channels. Kudos to Unit Tests (TestAcademy / TestAcademyDispose) for catching these.
com.unity.ml-agents/Runtime/SideChannels/EnvironmentParametersChannel.cs
Show resolved
Hide resolved
This reverts commit f81e835.
made the wrapper classes non-singleton (but internal constructors) made EngineParameters internal
Removed unnecessary accessors Made capture frame rate a parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vincentpierre - the branch is ready for you to take over and make the Python changes. This should include:
- Updating the engine config side channel to include capture framerate as the last field. This will require adding a new CLI option that has a default value of 60.
- Creating EnvironmentParameters side channel that is uni-directional Python to Unity with the message format of: string, int, block. The int represents an enum value that is equivalent to the EnvironmentDataTypes enum in EnvironmentParametersChannel.cs
- Switch from using floatproperties to the new environment parameters side channel
com.unity.ml-agents/Runtime/SideChannels/EnvironmentParametersChannel.cs
Show resolved
Hide resolved
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ProjectSettingsOverrides.cs
Show resolved
Hide resolved
com.unity.ml-agents/Runtime/SideChannels/EngineConfigurationChannel.cs
Outdated
Show resolved
Hide resolved
/// <param name="key">Parameter key.</param> | ||
/// <param name="defaultValue">Default value to return.</param> | ||
/// <returns></returns> | ||
public float GetParameterWithDefault(string key, float defaultValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe "GetWithDefault" or "GetValueWithDefault" or (if for some reason you want to be like Java.HashMap) "GetOrDefault"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this shorter notation. I don't want to be like Java, but GetOrDefault is clearer, no?
But, if we make this change, should we also make these for consistency?
- floatproperties: GetPropertyWithDefault --> GetWithDefault
- floatproperties: SetProperty --> Set
- rawbytes: GetAndClearReceivedMessages --> GetAndClear
- rawbytes: GetReceivedMessages --> Get
- rawbytes: SendRawBytes --> Send
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetPropertyWithDefault is the one I'd like to change the most, since I feel like "parameter"/"property" doesn't really add any value.
I'd rather leave GetAndClearReceivedMessages to keep it clear (pun intended) that it's a destructive action.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vincentpierre - one more change if we think its worth it.
com.unity.ml-agents/Runtime/SideChannels/SideChannelsManager.cs
Outdated
Show resolved
Hide resolved
com.unity.ml-agents/Runtime/SideChannels/SideChannelsManager.cs
Outdated
Show resolved
Hide resolved
Don't forget to increase the communication protocol version! |
} | ||
else | ||
{ | ||
throw new UnityAgentsException("EnvironmentParametersChannel only supports floats."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should either silently ignore unhandled types here, or at most log a warning (no exception).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Modified the EngineConfig to send one message per field * Created the Python Environment Parameters Channel and hooked it in * Make OnMessageReceived protected * addressing comments
|
* Edited the documetation and renamed a few things * addressing comments * Update docs/Python-API.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Update com.unity.ml-agents/CHANGELOG.md Co-Authored-By: Chris Elion <chris.elion@unity3d.com> * Removing unecessary migrating line Co-authored-by: Chris Elion <chris.elion@unity3d.com>
/// <param name="key">The parameter key</param> | ||
/// <param name="defaultValue">Default value for this parameter.</param> | ||
/// <returns></returns> | ||
public float GetParameterWithDefault(string key, float defaultValue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I might have commented on the wrong thing before. But this is the method I was suggesting we shorten to GetWithDefault()
/// Returns a list of all the string identifiers of the properties currently present. | ||
/// </summary> | ||
/// <returns> The list of string identifiers </returns> | ||
public IList<string> List() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we just call this Keys()
?
/// that if the Engine settings are directly changed anywhere in your Project, then the values | ||
/// returned here may not be reflective of the actual Engine settings. | ||
/// </summary> | ||
internal sealed class EngineParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like this class has no purpose now, since it's internal. Should we just remove it, and move the EngineConfigurationChannel/RegisterSideChannel setup to Academy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that yes. This is without change to the API so we can hold it off or I can do it now. Any preference ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then again, it's internal so we can remove it if we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I was going to say do it later, but looks like you already did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of EngineParameters was just to contain the registering/unregistering of the side channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine to not have it, just wanted to clarify intentions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it had a purpose originally, but we removed so much that it wasn't worth keeping around just to handle registration.
Proposed change(s)
See https://docs.google.com/document/d/1a0Ua_P1D8VUz8r_YMtiBa1swFISshJaaXslTncl_lmo/edit
Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)
Types of change(s)
Checklist
Other comments