Skip to content

Commit

Permalink
Variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
Tparuchuri authored and johnhuang01 committed Feb 8, 2022
1 parent 43210dd commit d99d43f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PersonalizerClient
private readonly bool _isLocalInference;
private string stringEndpoint;
private string apiKey;
private float _SubsampleRate = 1.0f;
private float subsampleRate = 1.0f;

private readonly RankProcessor _rankProcessor;

Expand Down Expand Up @@ -71,15 +71,15 @@ public PersonalizerClient(Uri endpoint, TokenCredential credential, Personalizer
/// <param name="endpoint"> Supported Cognitive Services endpoint. </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="isLocalInference"> A flag to determine whether to use local inference. </param>
/// <param name="SubsampleRate"> Percentage from (0,1] determines how much percentage of interaction and observation events to consider </param>
/// <param name="subsampleRate"> Percentage from (0,1] determines how much percentage of interaction and observation events to consider </param>
/// <param name="options"> The options for configuring the client. </param>
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, float SubsampleRate = 1.0f, PersonalizerClientOptions options = null) :
public PersonalizerClient(Uri endpoint, TokenCredential credential, bool isLocalInference, float subsampleRate = 1.0f, PersonalizerClientOptions options = null) :
this(endpoint, credential, options)
{
_isLocalInference = isLocalInference;
if (isLocalInference)
{
validateAndAssignSampleRate(SubsampleRate);
validateAndAssignSampleRate(subsampleRate);
//Intialize liveModel and call Rank processor
//ToDo:TASK 13057958: Working on changes to support token authentication in RLClient
Configuration configuration = GetConfigurationForLiveModel("Token", "token");
Expand Down Expand Up @@ -125,15 +125,15 @@ public PersonalizerClient(Uri endpoint, AzureKeyCredential credential, Personali
/// <param name="endpoint"> Supported Cognitive Services endpoint. </param>
/// <param name="credential"> A credential used to authenticate to an Azure Service. </param>
/// <param name="isLocalInference"> A flag to determine whether to use local inference. </param>
/// <param name="SubsampleRate"> Percentage from (0,1] determines how much percentage of interaction and observation events to consider </param>
/// <param name="subsampleRate"> Percentage from (0,1] determines how much percentage of interaction and observation events to consider </param>
/// <param name="options"> The options for configuring the client. </param>
public PersonalizerClient(Uri endpoint, AzureKeyCredential credential, bool isLocalInference, float SubsampleRate = 1.0f, PersonalizerClientOptions options = null) :
public PersonalizerClient(Uri endpoint, AzureKeyCredential credential, bool isLocalInference, float subsampleRate = 1.0f, PersonalizerClientOptions options = null) :
this(endpoint, credential, options)
{
_isLocalInference = isLocalInference;
if (isLocalInference)
{
validateAndAssignSampleRate(SubsampleRate);
validateAndAssignSampleRate(subsampleRate);
//Intialize liveModel and Rankprocessor
Configuration configuration = GetConfigurationForLiveModel("apiKey", apiKey);
LiveModel liveModel = new LiveModel(configuration);
Expand Down Expand Up @@ -566,8 +566,8 @@ internal Configuration GetConfigurationForLiveModel(string authType, string auth
}
config["interaction.http.api.host"] = stringEndpoint + "personalizer/v1.1-preview.2/logs/interactions";
config["observation.http.api.host"] = stringEndpoint + "personalizer/v1.1-preview.2/logs/observations";
config["interaction.subsample.rate"] = Convert.ToString(_SubsampleRate, CultureInfo.InvariantCulture);
config["observation.subsample.rate"] = Convert.ToString(_SubsampleRate, CultureInfo.InvariantCulture);
config["interaction.subsample.rate"] = Convert.ToString(subsampleRate, CultureInfo.InvariantCulture);
config["observation.subsample.rate"] = Convert.ToString(subsampleRate, CultureInfo.InvariantCulture);
//ToDo: TASK 13057958 Working on changes to support model api in RL.Net
config["model.blob.uri"] = stringEndpoint + "personalizer/v1.1-preview.1/model";
config["vw.commandline"] = _personalizerPolicy.Arguments;
Expand All @@ -579,13 +579,13 @@ internal Configuration GetConfigurationForLiveModel(string authType, string auth
}

/// <summary> validate SubsampleRate input from user and throw exception if not in range </summary>
private void validateAndAssignSampleRate(float SubsampleRate)
private void validateAndAssignSampleRate(float subsampleRate)
{
if (0 >= SubsampleRate || SubsampleRate > 1)
if (0 >= subsampleRate || subsampleRate > 1)
{
throw new ArgumentOutOfRangeException(nameof(SubsampleRate), "Percentage should be between (0,1]");
throw new ArgumentOutOfRangeException(nameof(subsampleRate), "Percentage should be between (0,1]");
}
_SubsampleRate = SubsampleRate;
this.subsampleRate = subsampleRate;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public PersonalizerTestBase(bool isAsync) : base(isAsync)
Sanitizer = new PersonalizerRecordedTestSanitizer();
}

protected async Task<PersonalizerClient> GetPersonalizerClientAsync(bool isSingleSlot = false, bool isLocalInference = false, float SubsampleRate = 1.0f)
protected async Task<PersonalizerClient> GetPersonalizerClientAsync(bool isSingleSlot = false, bool isLocalInference = false, float subsampleRate = 1.0f)
{
string endpoint = isSingleSlot ? TestEnvironment.SingleSlotEndpoint : TestEnvironment.MultiSlotEndpoint;
string apiKey = isSingleSlot ? TestEnvironment.SingleSlotApiKey : TestEnvironment.MultiSlotApiKey;
Expand All @@ -32,7 +32,7 @@ protected async Task<PersonalizerClient> GetPersonalizerClientAsync(bool isSingl
PersonalizerClient personalizerClient = null;
if (isLocalInference)
{
personalizerClient = new PersonalizerClient(new Uri(endpoint), credential, true, options: options, SubsampleRate: SubsampleRate);
personalizerClient = new PersonalizerClient(new Uri(endpoint), credential, true, options: options, subsampleRate: subsampleRate);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public async Task MultiSlotTest()
[Test]
public async Task MultiSlotLocalInferenceTest()
{
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, SubsampleRate: 1.01f));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, SubsampleRate: 0f));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, subsampleRate: 1.01f));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, subsampleRate: 0f));
PersonalizerClient client = await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true);
await MultiSlotTestInner(client);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public async Task SingleSlotRankTests()
[Test]
public async Task SingleSlotRankLocalInferenceTests()
{
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, SubsampleRate: 1.01f));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, SubsampleRate: 0f));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, subsampleRate: 1.01f));
Assert.ThrowsAsync<ArgumentOutOfRangeException>(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, subsampleRate: 0f));
PersonalizerClient client = await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true);
await SingleSlotRankTests(client);
}
Expand Down

0 comments on commit d99d43f

Please sign in to comment.