-
Notifications
You must be signed in to change notification settings - Fork 0
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
Johnhuang/12768045 rank processor #3
Johnhuang/12768045 rank processor #3
Conversation
@@ -31,7 +31,7 @@ protected EvaluationsClient() | |||
/// <param name="endpoint"> Supported Cognitive Services endpoint. </param> | |||
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param> | |||
/// <param name="options"> The options for configuring the client. </param> | |||
public EvaluationsClient(string endpoint, TokenCredential credential, PersonalizerClientOptions options = null) |
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.
All clients appear to have lost their TokenCredential
constructors. Please revert this change. TokenCredential
is required for ActiveDirectory (AD) Authentication.
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.
This is auto-generated. Let me check why this change was introduced.
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Newtonsoft.Json; |
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 rest of the code uses System.Text.Json. Can we unify on one parsing library?
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 have tried this for more than a half day and got stuck on migrating JsonRawStringListConverter. I decided to hold on this work. Also as I found other projects in azure-sdk-for-net use both System.Text.Json and Newtonsoft.Json, we should be fine to use both of them. But if you think this is highly suggested, I will create a task to work on this later.
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.
After several hours of effort, I have made it work. See the latest commit.
sdk/personalizer/Azure.AI.Personalizer/src/Models/RankProcessor.cs
Outdated
Show resolved
Hide resolved
} | ||
|
||
// Remove excluded actions in options | ||
options.Actions = options.Actions.Where(action => !excludedSet.Contains(action.Id)); |
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.
Please try to keep functions idempotent. Function parameters should not be modified unless that's the explicit intention of the function.
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.
Fixed.
rankableActions.Add(action); | ||
} | ||
++idx; | ||
} |
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.
This logic should be unnecessary. The Rank
requests supports a Lock
action parameter to handle the excluded case.
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 feel introducing "Lock" to the azure sdk is not necessary as long as the functionality is the same.
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.
Did you make manual changes in the Generated/ folder? if so, they should be reverted. No changes should be make in the generated folder. You can make changes in the /Models folder (not under generated) and use special decorators so that the code is generated as desired.
https://github.com/Azure/autorest.csharp#customizing-the-generated-code
@@ -1,6 +1,8 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFrameworks>$(RequiredTargetFrameworks);net47</TargetFrameworks> | |||
<NoWarn>$(NoWarn);SYSLIB0023</NoWarn> |
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 think we should add these to our own project files, not to the Azure.Core.TestFramework project file.
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 was not able to build this Azure.Core.TestFramework project if I don't add this line. This fix can't be in our project.
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.
Than can you address the warning on a line by line basis?
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.
Changed to only suppress the line.
@@ -32,6 +32,8 @@ | |||
|
|||
<ItemGroup> | |||
<PackageReference Include="Azure.Core" /> | |||
<PackageReference Include="Microsoft.RL" VersionOverride="1.0.18120003-INTERNAL" /> | |||
<PackageReference Include="Newtonsoft.Json" VersionOverride="10.0.3" /> |
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 are already using System.text.Json in the sdk
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.
Yes. Tyler had the similar comment. The following is my answer:
I have tried this for more than a half day and got stuck on migrating JsonRawStringListConverter. I decided to hold on this work. Also as I found other projects in azure-sdk-for-net use both System.Text.Json and Newtonsoft.Json, we should be fine to use both of them. But if you think this is highly suggested, I will create a task to work on this later.
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.
Changed.
/// <summary> Properties from url </summary> | ||
[JsonProperty("FromUrl", NullValueHandling = NullValueHandling.Ignore)] | ||
[JsonConverter(typeof(JsonRawStringListConverter))] | ||
#pragma warning disable CA2227 // Collection properties should be read only |
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] this should be moved to the project file. For my knowledge, why do we need SharedFromUrl to not be read only?
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.
sure.
namespace Azure.AI.Personalizer | ||
{ | ||
[CodeGenModel("MultiSlotClient")] |
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 CodeGenModel decorator is for renaming a class, but you are not renaming it, so it is unnecessary
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.
Right. We should probably remove this class as it is not used either.
/// <param name="options"> The options for configuring the client. </param> | ||
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, PersonalizerClientOptions options = null) : | ||
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, Configuration configuration, PersonalizerClientOptions options = null) : |
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] create constructors without default arguments as well
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.
Why do we need to define another constructor without a default argument? Would the current one cover both definitions?
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.
isLocalInference
needs a default value of false
and Configuration
should not be 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.
[Why do we need to define another constructor without a default argument? Would the current one cover both definitions?] -- the SDK team asked me to add constructors without the default arguments as part of my sdk review. They explained that it is a better experience for users to have a constructor without default arguments. The additional default argument tends to cause confusion if it is not used. This is why I added the PersonalizerClient constructors without the default argument which simply calls the other constructor.
return await RankRestClient.RankAsync(options, cancellationToken).ConfigureAwait(false); | ||
if (_isLocalInference) | ||
{ | ||
return _rankProcessor.Rank(options); |
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.
does rankProcessor not have an async method?
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 don't see an async method needed for local inference.
return Response.FromValue(value, default); | ||
} | ||
|
||
public static PersonalizerRankResult GenerateRankResult(List<PersonalizerRankableAction> originalActions, |
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] naming -- should be GenerateRankResult
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 is GenerateRankResult already. :)
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 noticed that a lot of the added code is taken from the decision service repo (converting a RankRequest into the correct format to be passed into vw and same thing for the response).
I think that a lot of that code can be improved (mainly variable names). When the SDK team reviews the code, they will want to understand it and they will have a hard time understanding class names like DecisionContextDocument or variable names like SharedFromUrl
@@ -1,6 +1,8 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFrameworks>$(RequiredTargetFrameworks);net47</TargetFrameworks> | |||
<NoWarn>$(NoWarn);SYSLIB0023</NoWarn> |
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.
Have to add this to make the build succeed
@@ -32,6 +32,8 @@ | |||
|
|||
<ItemGroup> | |||
<PackageReference Include="Azure.Core" /> | |||
<PackageReference Include="Microsoft.RL" VersionOverride="1.0.18120003-INTERNAL" /> |
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.
TODO: Need to take time to investigate whether we can remove VersionOverride in this file.
@@ -17,6 +17,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{0F88C67F-34D2-4C68-B5BF-08A547D4CC2E}" | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core", "..\core\Azure.Core\src\Azure.Core.csproj", "{CFB35402-69EB-448F-82B7-2D284730B0A6}" |
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.
Have to add this project because Azure.Core.TestFramework depends on this.
@@ -31,7 +31,7 @@ protected EvaluationsClient() | |||
/// <param name="endpoint"> Supported Cognitive Services endpoint. </param> | |||
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param> | |||
/// <param name="options"> The options for configuring the client. </param> | |||
public EvaluationsClient(string endpoint, TokenCredential credential, PersonalizerClientOptions options = null) |
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.
This is auto-generated. Let me check why this change was introduced.
rankableActions.Add(action); | ||
} | ||
++idx; | ||
} |
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 feel introducing "Lock" to the azure sdk is not necessary as long as the functionality is the same.
return Response.FromValue(value, default); | ||
} | ||
|
||
public static PersonalizerRankResult GenerateRankResult(List<PersonalizerRankableAction> originalActions, |
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 is GenerateRankResult already. :)
return await RankRestClient.RankAsync(options, cancellationToken).ConfigureAwait(false); | ||
if (_isLocalInference) | ||
{ | ||
return _rankProcessor.Rank(options); |
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 don't see an async method needed for local inference.
/// <param name="options"> The options for configuring the client. </param> | ||
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, PersonalizerClientOptions options = null) : | ||
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, Configuration configuration, PersonalizerClientOptions options = null) : |
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.
Why do we need to define another constructor without a default argument? Would the current one cover both definitions?
namespace Azure.AI.Personalizer | ||
{ | ||
[CodeGenModel("MultiSlotClient")] |
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.
Right. We should probably remove this class as it is not used either.
Added a RlObjectConverter to address the comment. |
NuGet.Config
Outdated
@@ -10,6 +10,7 @@ | |||
Used for azure-sdk-tools repo until issue https://github.com/Azure/azure-sdk-tools/issues/1329 is addressed | |||
--> | |||
<add key="azure-sdk-tools" value="https://azuresdkartifacts.blob.core.windows.net/azure-sdk-tools/index.json" /> | |||
<add key="air-msrai-decisionservice-Consumption" value="https://msazure.pkgs.visualstudio.com/one/_packaging/air-msrai-decisionservice-Consumption/nuget/v3/index.json" /> |
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.
[revert] We are not to have multiple NuGet sources in a build. Please make RLNet a downstream consumption of azure-sdk-tools.
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 are not there yet. We need to first build the Nuget package and provide the package file to dotNet team. Then they can put it under their dev feed: https://dev.azure.com/azure-sdk/public/_packaging?_a=feed&feed=azure-sdk-for-net. Then we will update this line to point to the dev feed. Currently we still don't have a good Nuget package. This is still a temporary location just to make sure we can continue our implementation.
@@ -1,6 +1,8 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<TargetFrameworks>$(RequiredTargetFrameworks);net47</TargetFrameworks> | |||
<NoWarn>$(NoWarn);SYSLIB0023</NoWarn> |
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.
Than can you address the warning on a line by line basis?
@@ -32,6 +32,8 @@ | |||
|
|||
<ItemGroup> | |||
<PackageReference Include="Azure.Core" /> | |||
<PackageReference Include="Microsoft.RL" VersionOverride="1.0.18120003-INTERNAL" /> | |||
<PackageReference Include="System.Text.Json" VersionOverride="6.0.1" /> |
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.
Is System.Text.Json
necessary? I thought this was already included?
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 default is old 4.* version. But it won't support [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]. So I have to override the version to a higher one.
@@ -4,3 +4,5 @@ | |||
using System.Diagnostics.CodeAnalysis; | |||
|
|||
[assembly: SuppressMessage("Usage", "AZC0016:Invalid ServiceVersion member name.", Justification = "Generated code: https://github.com/Azure/autorest.csharp/issues/1524", Scope = "type", Target = "~T:Azure.AI.Personalizer.PersonalizerClientOptions.ServiceVersion")] | |||
[assembly: SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "<Pending>", Scope = "member", Target = "~P:Azure.AI.Personalizer.DecisionContext.SharedFromUrl")] |
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.
Can you point me to the lines of code that require suppression? Warnings are generally there for a reason.
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 have removed this line as I don't need it. You will see it in my next commit.
/// <param name="options"> The options for configuring the client. </param> | ||
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, PersonalizerClientOptions options = null) : | ||
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, Configuration configuration, PersonalizerClientOptions options = null) : |
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.
isLocalInference
needs a default value of false
and Configuration
should not be a parameter.
@@ -27,7 +27,7 @@ public partial class PersonalizerRankOptions | |||
/// should match the sequence your application would have used to display them. | |||
/// The first item in the array will be used as Baseline item in Offline Evaluations. | |||
/// </summary> | |||
public IEnumerable<PersonalizerRankableAction> Actions { get; } | |||
public IEnumerable<PersonalizerRankableAction> Actions { get; set; } |
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.
revert
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 is not needed either. Reverted.
{ | ||
if (String.IsNullOrEmpty(options.EventId)) | ||
{ | ||
options.EventId = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture); |
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.
Do not modify the input parameters.
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.
Fixed.
int idx = 0; | ||
foreach (var action in options.Actions) | ||
{ | ||
action.Index = idx; |
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.
Do not modify the input parameters.
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.
fixed
return GenerateRankResponse(originalActions, rankableActions, excludedActions, rankedIndices, rankingProbabilities, eventId); | ||
} | ||
|
||
private static PersonalizerRankResult GenerateRankResponse(List<PersonalizerRankableAction> originalActions, |
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.
GenerateRankResponse
and GenerateRankResult
should have the same name. It's confusing otherwise. Also, I don't see the benefit of the two methods. Why can't all the logic be done in GenerateRankeResult
?
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 changed the GenerateRankResponse to GenerateRankResultInner. I don't want to combine the 2 methods as my next PR for multi-slot will call GenerateRankResultInner with different parameters.
@@ -196,10 +196,12 @@ public TestRandom Random | |||
#if NET6_0_OR_GREATER | |||
var liveSeed = RandomNumberGenerator.GetInt32(int.MaxValue); | |||
#else | |||
#pragma warning disable SYSLIB0023 |
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.
This is external code, I dont think we should be changing it
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.
Unfortunately, without this change, building will fail.
List<PersonalizerRankableAction> rankableActions = new List<PersonalizerRankableAction>(); | ||
List<PersonalizerRankableAction> excludedActions = new List<PersonalizerRankableAction>(); | ||
int idx = 0; | ||
foreach (var action in options.Actions) |
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] I think it would be cleaner if the logic of populating originalActions, rankableActions, excludedActions was moved to a helper method
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 feel this is ok as the whole method is less than 50 lines.
/// <param name="rankRequest"> Personalizer Rank Options </param> | ||
public DecisionContext(PersonalizerRankOptions rankRequest) | ||
{ | ||
List<string> jsonFeatures = rankRequest.ContextFeatures.Select(f => JsonSerializer.Serialize(f)).ToList(); |
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.
[naming] these are the context features, so I think a better name would be contextFeatures
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 did some refactoring for this method so that the local variable does not exist any more. But I renamed the other places. Will push the comment very soon.
this.Documents = rankableActions | ||
.Select(action => | ||
{ | ||
List<string> jsonFeatures = action.Features.Select(f => JsonSerializer.Serialize(f)).ToList(); |
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][naming] action features
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.
ok
[JsonPropertyName("FromUrl")] | ||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] | ||
[JsonConverter(typeof(JsonRawStringListConverter))] | ||
public List<string> SharedFromUrl { get; } |
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.
"FromUrl" is the default context feature namespace we add. This namespace contains all context features which are passed in by the user. I think this property should be called ContextFeatures
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.
agreed
/// <summary> | ||
/// Convert PersonalizerRankOptions object to a json context string for Rl.Net | ||
/// </summary> | ||
public static string ConvertToContextJson(PersonalizerRankOptions personalizerRankOptions) |
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.
DecisionContext contains information about the entire rank request, context and actions. I think you should change the name to ConvertToDecisionContext for clarity
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.
This is actually matching the parameter name of the method definition in LiveModel:
public RankingResponse ChooseRank(string eventId, string contextJson, ActionFlags flags);
So I feel this is better.
} | ||
|
||
// Convert options to the compatible parameter for ChooseRank | ||
var contextJson = RlObjectConverter.ConvertToContextJson(options); |
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 looks like you are computing RankableActions in two places.
- in ConvertToContextJson you are creating a DecisionContext which has the rankable actions
- in this method
I think you can split the ConvertToContextJson method so that you maintain an unserialized DecisionContext and then you will not need to recompute the Rankable and excluded action 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.
We discussed offline. I will take a different approach by defining a different constructor for DecisionContext:
public DecisionContext(IEnumerable contextFeatures, List rankableActions)
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Text.Json; |
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.
Did you add unit tests for the converter and other classes you added which can be tested in isolation?
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.
Added unit tests for RlObjectConverter, DecisionContext, JsonRawStringListConverter. Please take a look when you have time.
962214f
to
4f4bbb9
Compare
"}"; | ||
Assert.IsTrue(contextJson.Equals(expectedJson)); | ||
} | ||
} |
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.
Can't add any unit test for "GenerateRankResult" because a meaningful RankingResponse is not able to be created as it is seal class and all its properties are readonly and no constructor to set them.
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.
Preliminary approval as a work in progress. Multiple items such as a the Configuration logic is incorrect, but I'm assuming they will be address with further changes.
4f4bbb9
to
1610103
Compare
Add RankProcessor Remove unused file Remove some key Toggle commented codes so that most tests can pass RankProcessor is working. Still need to clean up the codes Add test json files only construct LiveModel when localInference is true Move rankprocessor to under model Add latest generated files from autorest Add autogenerated files from autorest Fix the setting in DecisionContext Remove wrong comment Revert unexpected auto-generated file changes Addressed a comment Move suppression to GlobalSuppressions.cs Remove the decoration in MultiSlotClient.cs Refactor rankProcessor so that the actions is not modified and restored; added a converter between sdk and Rl.Net; replace Newtonsoft.json with System.Text.Json Address comments Refactor RlObjuectConverter; remove some unneeded setters, etc. Added unit tests for RlObjectConverter, DecisionContext, JsonRawStringListConverter Remove unused using
1610103
to
ac6bb43
Compare
Add RankProcessor Remove unused file Remove some key Toggle commented codes so that most tests can pass RankProcessor is working. Still need to clean up the codes Add test json files only construct LiveModel when localInference is true Move rankprocessor to under model Add latest generated files from autorest Add autogenerated files from autorest Fix the setting in DecisionContext Remove wrong comment Revert unexpected auto-generated file changes Addressed a comment Move suppression to GlobalSuppressions.cs Remove the decoration in MultiSlotClient.cs Refactor rankProcessor so that the actions is not modified and restored; added a converter between sdk and Rl.Net; replace Newtonsoft.json with System.Text.Json Address comments Refactor RlObjuectConverter; remove some unneeded setters, etc. Added unit tests for RlObjectConverter, DecisionContext, JsonRawStringListConverter Remove unused using
* 12767912: Add isLocalInference in the public SDK * Rename the variable * Thick clent feature (#5) * 12767907: Add a package dependency on Microsoft.RL * Add RankProcessor * Remove unused file * Remove some key * Toggle commented codes so that most tests can pass * Getting the required config details for rankprocessor to enable livemode * Updating the wrong variable name * Cleanup * Revert "12767907: Add a package dependency on Microsoft.RL" This reverts commit c586920. * Revert "Add RankProcessor" This reverts commit 43967d3. * Revert "Remove unused file" This reverts commit 1e400a8. * Revert "Toggle commented codes so that most tests can pass" This reverts commit 7ec50ec. * Delete DisposeHelper.cs * Revert "Revert "12767907: Add a package dependency on Microsoft.RL"" This reverts commit d6df6b5. * Cleanup after reverting * generating client configuration using autorest * Revert "generating client configuration using autorest" This reverts commit 6b75695. * Configuration details for livemodel * cleanup * cleanup * Added ToDo comments * correct the version in endpoints Co-authored-by: Tejaswi Paruchuri <tparuchuri@microsoft.com> Co-authored-by: Tparuchuri <86433817+Tparuchuri@users.noreply.github.com> * 12768045: Add rank processor for single slot (#3) Add RankProcessor Remove unused file Remove some key Toggle commented codes so that most tests can pass RankProcessor is working. Still need to clean up the codes Add test json files only construct LiveModel when localInference is true Move rankprocessor to under model Add latest generated files from autorest Add autogenerated files from autorest Fix the setting in DecisionContext Remove wrong comment Revert unexpected auto-generated file changes Addressed a comment Move suppression to GlobalSuppressions.cs Remove the decoration in MultiSlotClient.cs Refactor rankProcessor so that the actions is not modified and restored; added a converter between sdk and Rl.Net; replace Newtonsoft.json with System.Text.Json Address comments Refactor RlObjuectConverter; remove some unneeded setters, etc. Added unit tests for RlObjectConverter, DecisionContext, JsonRawStringListConverter Remove unused using * 13009290: Create RankProcessor class to Azure Personalizer client library for .NET for multi slot (#7) * 13009290: Create RankProcessor class to Azure Personalizer client library for .NET for multi slot * Address comments * Subsampling * Cleanup and added tests * Cleanup and added tests * cleanup * cleanup * Single SubSample rate * Cleanup * Cleanup * Variable name * 13192221: Point to the Rl.Net nuget package from SDK dev drop (#9) * Adding test code for Model/Put api and moving to preview.3 * Johnhuang/13216589 reward activate local inference api (#10) * Update API view file * 13216589: Add local inference reward api 13216590: Add local inference activate api * Fix the comments * Remove IsDisposed method * Revert "Update API view file" This reverts commit 0a4dcbf. * Remove MultiSlotClient class as it is never used * Add more change after other PRs were merged * Revert "Add more change after other PRs were merged" This reverts commit 35a3120. * 13225147: Update API view file for thick client (#11) * 13225147: Update API view file for thick client * Remove some suppressing warning * Add more changes after 2 PRs were merged * lazy load rank processor, refresh config and relaod token on expiry (#12) * lazy load rank processor, refresh config and relaod token on expiry * Comments & Cleanup * Cleanup * Addressed comments * Cleanup * Fix conflict Co-authored-by: John Huang <johnhuang@microsoft.com> * 13309375: Improve the tests by mocking LiveModel when test mode is (#14) * 13309375: Improve the tests by mocking LiveModel when test mode is Playback but using real LiveModel when test mode is Live * Change some public classes to private * Address those comments in the main PR * Update Microsoft.RL version * Rename some properties * Update Microsoft.RL version * Fix spelling check * Remove the unneeded warning * Update live model config * Use similar method names for export and import apis * Johnhuang/13170630 address thick client sdk review (#18) * 13170630: Address comments from SDK review * Update API view file * Remove unnecessary file under Gerated folder * Add more test for RLObjectConverter * Remove unused parameter * Remove unneeded comment * Update recording sessions for tests that were changed in earlier commit. (#19) Co-authored-by: Personalizer Team <personalizer@microsoft.com> * Update api view file after model api change (#20) * Rename modelStream to modelBody (#21) * Update Microsoft.RL version * 13678440: Some cosmetic change to address comments from DotNet team (#22) * Update method names for Export/Import models as per suggestions. (#23) * Update method names for Export/Import models as per suggestions. * Updates after running codecheck.ps1 script Co-authored-by: Personalizer Team <personalizer@microsoft.com> Co-authored-by: Tejaswi Paruchuri <tparuchuri@microsoft.com> Co-authored-by: Tparuchuri <86433817+Tparuchuri@users.noreply.github.com> Co-authored-by: Personalizer Team <personalizer@microsoft.com> Co-authored-by: Sharath Malladi <msharath@live.com>
All SDK Contribution checklist:
This checklist is used to make sure that common guidelines for a pull request are followed.
Draft
mode if it is:General Guidelines and Best Practices
Testing Guidelines
SDK Generation Guidelines
*.csproj
andAssemblyInfo.cs
files have been updated with the new version of the SDK. Please double check nuget.org current release version.Additional management plane SDK specific contribution checklist:
Note: Only applies to
Microsoft.Azure.Management.[RP]
orAzure.ResourceManager.[RP]
Management plane SDK Troubleshooting
If this is very first SDK for a services and you are adding new service folders directly under /SDK, please add
new service
label and/or contact assigned reviewer.If the check fails at the
Verify Code Generation
step, please ensure:generate.ps1/cmd
to generate this PR instead of callingautorest
directly.Please pay attention to the @microsoft.csharp version output after running
generate.ps1
. If it is lower than current released version (2.3.82), please run it again as it should pull down the latest version.Note: We have recently updated the PSH module called by
generate.ps1
to emit additional data. This would help reduce/eliminate the Code Verification check error. Please run following command:Old outstanding PR cleanup
Please note:
If PRs (including draft) has been out for more than 60 days and there are no responses from our query or followups, they will be closed to maintain a concise list for our reviewers.