diff --git a/sdk/personalizer/Azure.AI.Personalizer/src/Models/PersonalizerClient.cs b/sdk/personalizer/Azure.AI.Personalizer/src/Models/PersonalizerClient.cs index 6773e6c19e29..95e8907760b1 100644 --- a/sdk/personalizer/Azure.AI.Personalizer/src/Models/PersonalizerClient.cs +++ b/sdk/personalizer/Azure.AI.Personalizer/src/Models/PersonalizerClient.cs @@ -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; @@ -71,15 +71,15 @@ public PersonalizerClient(Uri endpoint, TokenCredential credential, Personalizer /// Supported Cognitive Services endpoint. /// A credential used to authenticate to an Azure Service. /// A flag to determine whether to use local inference. - /// Percentage from (0,1] determines how much percentage of interaction and observation events to consider + /// Percentage from (0,1] determines how much percentage of interaction and observation events to consider /// The options for configuring the client. - 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"); @@ -125,15 +125,15 @@ public PersonalizerClient(Uri endpoint, AzureKeyCredential credential, Personali /// Supported Cognitive Services endpoint. /// A credential used to authenticate to an Azure Service. /// A flag to determine whether to use local inference. - /// Percentage from (0,1] determines how much percentage of interaction and observation events to consider + /// Percentage from (0,1] determines how much percentage of interaction and observation events to consider /// The options for configuring the client. - 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); @@ -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; @@ -579,13 +579,13 @@ internal Configuration GetConfigurationForLiveModel(string authType, string auth } /// validate SubsampleRate input from user and throw exception if not in range - 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; } } } diff --git a/sdk/personalizer/Azure.AI.Personalizer/tests/Infrastructure/PersonalizerTestBase.cs b/sdk/personalizer/Azure.AI.Personalizer/tests/Infrastructure/PersonalizerTestBase.cs index 76ed6a3cb8a6..58ede423a35c 100644 --- a/sdk/personalizer/Azure.AI.Personalizer/tests/Infrastructure/PersonalizerTestBase.cs +++ b/sdk/personalizer/Azure.AI.Personalizer/tests/Infrastructure/PersonalizerTestBase.cs @@ -18,7 +18,7 @@ public PersonalizerTestBase(bool isAsync) : base(isAsync) Sanitizer = new PersonalizerRecordedTestSanitizer(); } - protected async Task GetPersonalizerClientAsync(bool isSingleSlot = false, bool isLocalInference = false, float SubsampleRate = 1.0f) + protected async Task 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; @@ -32,7 +32,7 @@ protected async Task 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 { diff --git a/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/MultiSlotTests.cs b/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/MultiSlotTests.cs index 3afb53b35284..d864bdac32aa 100644 --- a/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/MultiSlotTests.cs +++ b/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/MultiSlotTests.cs @@ -83,8 +83,8 @@ public async Task MultiSlotTest() [Test] public async Task MultiSlotLocalInferenceTest() { - Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, SubsampleRate: 1.01f)); - Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, SubsampleRate: 0f)); + Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, subsampleRate: 1.01f)); + Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true, subsampleRate: 0f)); PersonalizerClient client = await GetPersonalizerClientAsync(isSingleSlot: false, isLocalInference: true); await MultiSlotTestInner(client); } diff --git a/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/RankTests.cs b/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/RankTests.cs index 6b6b070060d3..85ee4a05be5d 100644 --- a/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/RankTests.cs +++ b/sdk/personalizer/Azure.AI.Personalizer/tests/Personalizer/RankTests.cs @@ -24,8 +24,8 @@ public async Task SingleSlotRankTests() [Test] public async Task SingleSlotRankLocalInferenceTests() { - Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, SubsampleRate: 1.01f)); - Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, SubsampleRate: 0f)); + Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, subsampleRate: 1.01f)); + Assert.ThrowsAsync(async () => await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true, subsampleRate: 0f)); PersonalizerClient client = await GetPersonalizerClientAsync(isSingleSlot: true, isLocalInference: true); await SingleSlotRankTests(client); }