Skip to content
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

Removing Obsolete methods from the package #5024

Merged
merged 7 commits into from
Mar 8, 2021

Conversation

vincentpierre
Copy link
Contributor

@vincentpierre vincentpierre commented Mar 2, 2021

Proposed change(s)

Removing all methods marked with Obsolete attribute

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 Mar 2, 2021
#pragma warning disable 618
return new[] { CreateActuator() };
#pragma warning restore 618
return new IActuator[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be abstract (with no implementation).

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. Please update the migration guide as you go.

@chriselion
Copy link
Contributor

(and changelog)

/// </value>
[Obsolete("VectorActionSize has been deprecated, please use ActionSpec instead.")]
[FormerlySerializedAs("vectorActionSize")]
public int[] VectorActionSize = new[] { 1 };
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately, I think we need to keep these around so that old assets can still be loaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by old assets ? What functionality are we trying to preserve ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, for v2, I was thinking refactoring BrainParameters and BehaviorParameters completely, so maybe it is best to set expectations early and tune down the scope I had in mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you have a scene or prefab from v1.6.0 or earlier, the BrainParameters have VectorActionSize and VectorActionSpaceType fields on them. When you first open this in 1.7.0 or later, we have to read the values from the old field and fill in the ActionSpec (m_ActionSpec) with them. The work happens in the UpdateToActionSpec() method, which is called in OnBeforeSerialize() and OnAfterDeserialize().

So if we remove these and a user loads a scene from <=1.6.0, their Agent will have no actions. In my opinion, this is a big pain for upgrading and we shouldn't do it. I'm willing to be convinced otherwise, but I think we need a bigger discussion on it.

That being said, I don't love that we have to keep the fields around (and public!) just so that they can be read once. It would be worth following up with #devs-serialization to see if there's a better way we can do this while hiding the fields. If nothing else, we can rename them to e.g. DeprecatedDoNotUseVectorActionSize.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, these fields are used in a bunch of places that you didn't update, so this doesn't compile. I'll update yamato tests to run on PRs targeting the staging branch.

/// </summary>
[Obsolete("VectorActionSpaceType has been deprecated, please use ActionSpec instead.")]
[FormerlySerializedAs("vectorActionSpaceType")]
public SpaceType VectorActionSpaceType = SpaceType.Discrete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Needs to stay too.

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.

I don't think we can remove VectorActionSpaceType and VectorActionSize. Can you put them back for this PR, and we can see what can be done to hide them better in a different PR?

@@ -1310,24 +1271,6 @@ public virtual void OnActionReceived(ActionBuffers actions)
// Nothing implemented.
return;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

OnActionReceived should be empty now (no reason to look at the actionSpec)

@chriselion
Copy link
Contributor

chriselion commented Mar 3, 2021

It's OK to remove BrainParameters.NumActions

[Obsolete("NumActions has been deprecated, please use ActionSpec instead.")]
public int NumActions

…ented Heuristic, Removing NumAction from Brain Parameters
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.0.0-preview]
Copy link
Contributor

Choose a reason for hiding this comment

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

Package verification will probably complain about this. You might need to mark the old Unreleased section as 1.9.0, and this as Unreleased

/// </summary>
/// <param name="actionMasker"></param>
[Obsolete("CollectDiscreteActionMasks has been deprecated, please use WriteDiscreteActionMask.")]
public virtual void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there's still a reference to CollectDiscreteActionMasks
in docs/Learning-Environment-Design-Agents.md

@chriselion chriselion merged commit a2d6d79 into v2-staging Mar 8, 2021
@delete-merged-branch delete-merged-branch bot deleted the v-staging-remove-obsolete branch March 8, 2021 21:22
surfnerd pushed a commit that referenced this pull request Mar 18, 2021
* Removing Obsolete methods from the package

* Missing depecration and modified changelog

* Readding the obsolete BrainParameter methods, will need a larger discussion on these

* Removing Action Masker, readding the warining when using a non-implemented Heuristic, Removing NumAction from Brain Parameters

* removing documentation and some calls to deprecated methods in the extensions package

* Editing the Changelog to put the unreleased on top
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 9, 2022
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