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

[TA] Expose ActionName and enable multiple actions from same type #24619

Merged

Conversation

ZulaMostafa
Copy link
Contributor

@ZulaMostafa ZulaMostafa commented Oct 10, 2021

This PR is for exposing ActionName again as it was disabled in the issue #22311. It also includes enabling multi actions from the same type as the service supports that right now. Resolves both #24441 and #24430.

I have some concerns regarding this issue:

  • How should I deal with the breaking change that happened because of adding a new parameter to existing functions? for now I built the project with adding /p:BaselineAllAPICompatError=true. I am suggesting that we make overloaded functions for them, with validating that all actions from the same type have unique names.
  • How should the tests be maintained? Should I add a test for every type of action? I am welcoming any suggestions for that.

@ZulaMostafa ZulaMostafa marked this pull request as draft October 10, 2021 16:11
@ZulaMostafa ZulaMostafa changed the title [TA] Exposed ActionName and enabled multiple actions from same type [TA] Expose ActionName and enable multiple actions from same type Oct 11, 2021
@ZulaMostafa ZulaMostafa marked this pull request as ready for review October 11, 2021 12:12
@kinelski
Copy link
Member

How should I deal with the breaking change that happened because of adding a new parameter to existing functions?

This happens very frequently in the Model Factory as we add new properties to models, as you can see here:

/// <summary>
/// Initializes a new instance of <see cref="TextAnalytics.CategorizedEntity"/> for mocking purposes.
/// </summary>
/// <param name="text">Sets the <see cref="CategorizedEntity.Text"/> property.</param>
/// <param name="category">Sets the <see cref="CategorizedEntity.Category"/> property.</param>
/// <param name="subCategory">Sets the <see cref="CategorizedEntity.SubCategory"/> property.</param>
/// <param name="score">Sets the <see cref="CategorizedEntity.ConfidenceScore"/> property.</param>
/// <returns>A new instance of <see cref="TextAnalytics.CategorizedEntity"/> for mocking purposes.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static CategorizedEntity CategorizedEntity(string text, string category, string subCategory, double score)
{
return new CategorizedEntity(new Entity(text, category, subCategory, default, default, score));
}
/// <summary>
/// Initializes a new instance of <see cref="TextAnalytics.CategorizedEntity"/> for mocking purposes.
/// </summary>
/// <param name="text">Sets the <see cref="CategorizedEntity.Text"/> property.</param>
/// <param name="category">Sets the <see cref="CategorizedEntity.Category"/> property.</param>
/// <param name="subCategory">Sets the <see cref="CategorizedEntity.SubCategory"/> property.</param>
/// <param name="score">Sets the <see cref="CategorizedEntity.ConfidenceScore"/> property.</param>
/// <param name="offset">Sets the <see cref="CategorizedEntity.Offset"/> property.</param>
/// <param name="length">Sets the <see cref="CategorizedEntity.Length"/> property.</param>
/// <returns>A new instance of <see cref="TextAnalytics.CategorizedEntity"/> for mocking purposes.</returns>
public static CategorizedEntity CategorizedEntity(string text, string category, string subCategory, double score, int offset, int length)
{
return new CategorizedEntity(new Entity(text, category, subCategory, offset, length, score));
}

In these situations we create a new overload as you suggested, and add the [EditorBrowsable(EditorBrowsableState.Never)] attribute to the old method so it's not suggested by IntelliSense anymore, but it can still be used by customers.

Copy link
Member

@kristapratico kristapratico left a comment

Choose a reason for hiding this comment

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

Maybe update the changelog with the new feature

Copy link
Member

@deyaaeldeen deyaaeldeen left a comment

Choose a reason for hiding this comment

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

Implementation looks good!

@ZulaMostafa
Copy link
Contributor Author

Implementation looks good!

Thanks!

@ZulaMostafa
Copy link
Contributor Author

I rebased the branch and there are no conflicts now.
I've also added a single test for every action to make sure they can run multiple actions, and also to make sure that actionName gets sent and received correctly. I was also thinking about adding a test with all the actions included but with multiple ones for each of them, what do you think?

@maririos maririos requested review from jsquire and kinelski October 19, 2021 23:34
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

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

LGTM; failures seem to indicate that the recordings need to be redone to accommodate the API version change.

@ZulaMostafa
Copy link
Contributor Author

LGTM; failures seem to indicate that the recordings need to be redone to accommodate the API version change.

Should we make a separate PR to run the tests? I noticed that only 4 of them needs to be redone.

CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'Azure.AI.TextAnalytics.TextAnalyticsError.Target.get()' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'Azure.AI.TextAnalytics.TextAnalyticsWarning.Message.get()' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'Azure.AI.TextAnalytics.TextAnalyticsWarning.WarningCode.get()' in the contract but not the implementation.
Compat issues with assembly Azure.AI.TextAnalytics:
Copy link
Member

Choose a reason for hiding this comment

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

This file shouldn't be needed anymore now that you added the overloads to the TextAnalyticsModelFactory class, right?

@maririos
Copy link
Member

LGTM; failures seem to indicate that the recordings need to be redone to accommodate the API version change.

Should we make a separate PR to run the tests? I noticed that only 4 of them need to be redone.

I think the general idea is:

  • If you removed tests that had recordings, make sure the recordings are deleted (I don't think that is the case, but worth checking)
  • If you added LiveTest (which you did for every action to verify the multiple action implementation) there should be 2 recording files associated with the test (sync and async) and it looks like these were not generated/added

@ZulaMostafa
Copy link
Contributor Author

I added a new test AnalyzeOperationWithMultipleActionsOfSameType to make sure that it works well if we have multiple actions and each of them have multiple one. Whenever I run it I get an internal server error, failed to register new job.
any idea why @maririos ?

@jsquire
Copy link
Member

jsquire commented Oct 22, 2021

Should we make a separate PR to run the tests? I noticed that only 4 of them needs to be redone.

We'll want to make sure that the tests pass as part of this work; we don't want to introduce changes into the repository that break test runs.

@maririos maririos merged commit d698402 into Azure:feature/textanalytics/custom Oct 25, 2021
maririos pushed a commit to maririos/azure-sdk-for-net that referenced this pull request Oct 26, 2021
maririos added a commit that referenced this pull request Oct 26, 2021
* [TextAnalytics] Generated client from 3.2-preview.2 swagger (#23536)

* [TA] Added SingleCategoryClassify functionality (#24235)

* [TA] Added MultiCategoryClassify Functionality (#24237)

* [TA] Added RecognizeCustomEntities Functionality (#24245)

* [TA] Expose ActionName and enable multiple actions from same type (#24619)

* Rerecorded all tests excluding AAD ones (#24913)

* re-record AAD tests (#24919)

* [TA] Enable CI for live tests for custom features (#24916)

* add comments

Co-authored-by: Caio Saldanha <camaiaor@microsoft.com>
Co-authored-by: Ahmed Leithy <v-aleithy@microsoft.com>
Co-authored-by: Salah Mostafa <zulamostafa@gmail.com>
Co-authored-by: Salah Mostafa <v-samostafa@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants