Skip to content

Python side changes to the SideChannel redesign #3826

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

Merged

Conversation

vincentpierre
Copy link
Contributor

Proposed change(s)

  • 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
  • Make OnMessageReceived protected
  • Make the engine config send one message per config field

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@vincentpierre vincentpierre self-assigned this Apr 22, 2020
@vincentpierre vincentpierre changed the title Develop mm env params unity vince Python side changes to the SideChannel redesign Apr 22, 2020
@vincentpierre
Copy link
Contributor Author

Python side changes to #3807

"""

class ConfigurationType(IntEnum):
SCREEN = (0,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no commas (these are 1-tuples, not ints)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(still the same formatting bug I am seeing)
Will change and be more careful

/// <summary>
/// Side channel that supports modifying attributes specific to the Unity Engine.
/// </summary>
internal class EngineConfigurationChannel : SideChannel
{
private enum ConfigurationType : int
{
Screen = 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Resolution" or "ScreenResolution"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ScreenResolution it is

* `height`: Defines the height of the display. (Must be set alongside width)
* `quality_level`: Defines the quality level of the simulation.
* `time_scale`: Defines the multiplier for the deltatime in the simulation. If set to a higher value, time will pass faster in the simulation but the physics may perform unpredictably.
* `target_frame_rate`: Instructs simulation to try to render at a specified frame rate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add "capture_frame_rate" too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed it. Thanks.

"""

class ConfigurationType(IntEnum):
SCREEN = (0,)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to "RESOLUTION" or "SCREEN_RESOLUTION"?

var captureFrameRate = msg.ReadInt32();
Time.captureFramerate = captureFrameRate;
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment in the other PR in EnvironmentParametersChannel.OnMessageReceived() - we should be consistent with how we handle unknown values. I don't think we should throw (otherwise it's not forwards compatible) but we should either do nothing (like here) or warn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can send a warning.

msg.write_float32(time_scale)
msg.write_int32(target_frame_rate)
super().queue_message_to_send(msg)
if width is not None and height is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise an exception is one is None and the other isn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

Copy link
Contributor

@chriselion chriselion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@vincentpierre vincentpierre merged commit ab9dc93 into develop-mm-env-params-unity Apr 22, 2020
@vincentpierre vincentpierre deleted the develop-mm-env-params-unity-vince branch April 22, 2020 22:40
vincentpierre added a commit that referenced this pull request Apr 23, 2020
* Make EnvironmentParameters a first-class citizen in the API

Missing: Python conterparts and testing.

* Minor comment fix to Engine Parameters

* A second minor fix.

* Make EngineConfigChannel Internal and add a singleton/sealed accessor

* Make StatsSideChannel Internal and add a singleton/sealed accessor

* Changes to SideChannelUtils

- 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

* Added Dispose methods to system-level sidechannel wrappers

- 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.

* Removed debub log.

* Back-up commit.

* Revert "Back-up commit."

This reverts commit f81e835.

* key changes to wrapper classes

made the wrapper classes non-singleton (but internal constructors)
made EngineParameters internal

* Re-enabled the option to add multiple side channels of the same type

* Fixed example env

* Add an enum flag to the EnvParamsChannel

* Adding .cs.meta files

* Update engine config side channel

Removed unnecessary accessors
Made capture frame rate a parameter

* Rename SideChannelUtils —> SideChannelsManager

* PR feedback

* Minor PR feedback.

* Python side changes to the SideChannel redesign (#3826)

* Modified the EngineConfig to send one message per field

* Created the Python Environment Parameters Channel and hooked it in

* Make OnMessageReceived protected

* addressing comments

* [Side Channels] Edited the documenation and renamed a few things (#3833)

* Edited the documetation and renamed a few things

* addressing comments

* Update docs/Python-API.md

Co-Authored-By: Chris Elion <[email protected]>

* Update com.unity.ml-agents/CHANGELOG.md

Co-Authored-By: Chris Elion <[email protected]>

* Removing unecessary migrating line

Co-authored-by: Chris Elion <[email protected]>

* Addressing renaming comments

* Removing the EngineParameters class

Co-authored-by: Vincent-Pierre BERGES <[email protected]>
Co-authored-by: Chris Elion <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants