public void FuzzyMatchingClientPerfomanceTest(List <string> dataset, int[] testDataSizes, string testSentence) { foreach (var dataSize in testDataSizes) { // read dataset var tmp = dataset.Take(dataSize).ToList(); // initialize clients var preprocessorClient = new PreprocessorClient(); var runtimeClient = new RuntimeClient(); // process dataset var processedDataset = preprocessorClient.ProcessDataset(tmp); // performance test var start = DateTime.Now; runtimeClient.MatchEntities(processedDataset, dataset, testSentence, MatchingMethod.NoMatchIndices); var end = DateTime.Now; var ts = end - start; // print time Console.WriteLine("Elapsed Time for the program with size {0} is {1} s", dataSize, ts.TotalSeconds); } }
void Start() { logger = new AQALogger(); if (AutomatedQARuntimeSettings.hostPlatform == HostPlatform.Cloud && AutomatedQARuntimeSettings.buildType == BuildType.FullBuild) { DontDestroyOnLoad(this.gameObject); RecordedPlaybackPersistentData.SetRecordingMode(RecordingMode.Playback); DeviceFarmConfig dfConf = CloudTestManager.Instance.GetDeviceFarmConfig(); Application.quitting += () => { # if UNITY_EDITOR logger.Log($"Counters generated - {CloudTestManager.Instance.GetTestResults().ToString()}"); #else CloudTestManager.UploadCounters(); #endif RuntimeClient.LogTestCompletion(dfConf.testName); }; // Optionally us a settings json file other than the default. TextAsset settings = Resources.Load <TextAsset>(Path.GetFileNameWithoutExtension(dfConf.settingsFileToLoad)); if (!string.IsNullOrEmpty(dfConf.settingsFileToLoad) && settings != null && !string.IsNullOrEmpty(settings.text)) { logger.Log($"Updating default Automated QA settings file to {dfConf.settingsFileToLoad}"); AutomatedQARuntimeSettings.AutomatedQaSettingsFileName = dfConf.settingsFileToLoad; AutomatedQARuntimeSettings.RefreshConfig(); } RunTest(dfConf.testName); }
/// <summary> /// Setup test with cloud recordings and prepare play back /// </summary> /// <param name="testName"></param> public static void SetupCloudUTFTests(string testName) { if (AutomatedQARuntimeSettings.hostPlatform == HostPlatform.Cloud && AutomatedQARuntimeSettings.buildType == BuildType.UnityTestRunner) { // testName and recordingName have a 1-1 mapping. RecordedPlaybackPersistentData.SetRecordingMode(RecordingMode.Playback); RuntimeClient.DownloadRecording(testName, RecordedPlaybackPersistentData.GetRecordingDataFilePath()); } }
public SerializationTestEnvironment(Action <IClientBuilder> configureClientBuilder = null) { var host = new HostBuilder() .UseOrleansClient((ctx, clientBuilder) => { clientBuilder.UseLocalhostClustering(); configureClientBuilder?.Invoke(clientBuilder); }).Build(); this.Client = host.Services.GetRequiredService <IClusterClient>(); this.RuntimeClient = this.Client.ServiceProvider.GetRequiredService <OutsideRuntimeClient>(); RuntimeClient.ConsumeServices(); }
public void MultipleMatchTest(List <string> dataset, List <string> testSentencesList, List <MatchResult> expected) { // initialize clients var preprocessorClient = new PreprocessorClient(); var runtimeClient = new RuntimeClient(); // process dataset var processedDataset = preprocessorClient.ProcessDataset(dataset); // exact matches var index = 0; for (; index < 3; index++) { var resultList = runtimeClient.MatchEntities(processedDataset, dataset, testSentencesList[index], MatchingMethod.NoMatchIndices, threshold: 0.8f); var result = resultList[0]; Assert.Equal(1f, result.SimilarityScore, 4); } // altering sentence to decrease similarity scores testSentencesList[3] = testSentencesList[3].Remove(testSentencesList[3].Length - 2, 2).Insert(0, "Testing ") + " last word"; testSentencesList[4] = testSentencesList[4].Insert(0, "The "); testSentencesList[5] = testSentencesList[5].Remove(testSentencesList[5].Length - 2, 2) + " nw"; // close matches for (; index < 6; index++) { var resultList = runtimeClient.MatchEntities(processedDataset, dataset, testSentencesList[index], MatchingMethod.NoMatchIndices, threshold: 0.8f); var result = resultList[0]; Assert.InRange(result.SimilarityScore, 0.5f, 1f); } // altering sentences heavily testSentencesList[6] = testSentencesList[6].Replace(testSentencesList[6][0], 'x').Insert(0, "Testing "); var halfLength = testSentencesList[7].Length / 2; testSentencesList[7] = testSentencesList[7].Insert(0, "The ").Insert(halfLength, "other words") + " more words"; var thirdLength = testSentencesList[8].Length / 3; testSentencesList[8] = testSentencesList[8].Remove(0, thirdLength) + " added words."; // far matches for (; index < 9; index++) { var resultList = runtimeClient.MatchEntities(processedDataset, dataset, testSentencesList[index], MatchingMethod.NoMatchIndices, threshold: 0.5f); var result = resultList[0]; Assert.InRange(result.SimilarityScore, 0f, 1f); } }
private static ServiceProvider StartNew <TConnection>( TConnection connection, out ConnectionHandler connectionHandler, out RuntimeClient runtimeClient) where TConnection : IDuplexPipe { var chan = Channel.CreateUnbounded <Message>(); var services = new ServiceCollection() .AddHagar(hagar => hagar.AddAssembly(typeof(Program).Assembly)) .AddSingleton <Catalog>() .AddSingleton <ProxyFactory>() .AddSingleton(sp => ActivatorUtilities.CreateInstance <ConnectionHandler>(sp, connection, chan.Writer)) .AddSingleton(sp => ActivatorUtilities.CreateInstance <RuntimeClient>(sp, chan.Reader)) .AddSingleton <IRuntimeClient>(sp => sp.GetRequiredService <RuntimeClient>()) .BuildServiceProvider(); connectionHandler = services.GetRequiredService <ConnectionHandler>(); runtimeClient = services.GetRequiredService <RuntimeClient>(); return(services); }
public void SingleMatchTest(List <string> dataset, string sentenceToMatch, MatchResult expected) { // initialize clients var preprocessorClient = new PreprocessorClient(); var runtimeClient = new RuntimeClient(); // process dataset var processedDataset = preprocessorClient.ProcessDataset(dataset); // runtime var resultList = runtimeClient.MatchEntities(processedDataset, dataset, sentenceToMatch, MatchingMethod.NoMatchIndices); var result = resultList[0]; // assert Assert.Equal(result.DatabaseMatchInfo.MatchText, expected.DatabaseMatchInfo.MatchText); Assert.Equal(result.DatabaseMatchInfo.MatchIndex, expected.DatabaseMatchInfo.MatchIndex); // print result Console.WriteLine("sentence to match : {0}", sentenceToMatch); Console.WriteLine("Matched Sentence : {0}", result.DatabaseMatchInfo.MatchText); Console.WriteLine("Matched Sentence Score : {0}", result.SimilarityScore); Console.WriteLine("Matched Sentence Index : {0}", result.DatabaseMatchInfo.MatchIndex); }
public void TokenMatchingTest(List <string> dataset, string testSentence, MatchResult expected) { // initialize clients var preprocessorClient = new PreprocessorClient(); var runtimeClient = new RuntimeClient(); // process dataset var processedDataset = preprocessorClient.ProcessDataset(dataset); // runtime var resultList = runtimeClient.MatchEntities(processedDataset, dataset, testSentence, MatchingMethod.PreprocessInputSentence, threshold: 0.80f); var result = resultList.OrderByDescending(r => r.SimilarityScore).FirstOrDefault(); // asserting that the right entity was correctly found // This is not a perfect test for this dataset since some entities are subsets of each other Assert.Equal(result.DatabaseMatchInfo.MatchText, expected.DatabaseMatchInfo.MatchText); Assert.Equal(result.DatabaseMatchInfo.MatchIndex, expected.DatabaseMatchInfo.MatchIndex); // print result Console.WriteLine("sentence to match : {0}", testSentence); Console.WriteLine("Matched Sentence : {0}", result.DatabaseMatchInfo.MatchText); Console.WriteLine("Matched Sentence Score : {0}", result.SimilarityScore); Console.WriteLine("Matched Sentence Index : {0}", result.DatabaseMatchInfo.MatchIndex); }
/// <summary> /// Get a timeout of responses on this Orleans client. /// </summary> /// <returns>The response timeout.</returns> /// <exception cref="InvalidOperationException">Thrown if Orleans runtime is not correctly initialized before this call.</exception> public static TimeSpan GetResponseTimeout() { CheckInitialized(); return(RuntimeClient.GetResponseTimeout()); }
/// <summary> /// Set a timeout for responses on this Orleans client. /// </summary> /// <param name="timeout"></param> /// <exception cref="InvalidOperationException">Thrown if Orleans runtime is not correctly initialized before this call.</exception> public static void SetResponseTimeout(TimeSpan timeout) { CheckInitialized(); RuntimeClient.SetResponseTimeout(timeout); }
public void SendRequest(GrainReference target, InvokeMethodRequest request, TaskCompletionSource <object> context, Action <Message, TaskCompletionSource <object> > callback, string debugContext = null, InvokeMethodOptions options = InvokeMethodOptions.None, string genericArguments = null) { var message = RuntimeClient.CreateMessage(request, options); SendRequestMessage(target, message, context, callback, debugContext, options, genericArguments); }
public MatchIndexResolutionTests() { _preprocessorClient = new PreprocessorClient(); _runtimeClient = new RuntimeClient(); }
async Task InvokeBatchExecutionService(string accountNameInput, string accountKeyInput, string containerInput, string inputBlobName, string inputFileName, OutputObject outputObj) { // Upload file to Blob if pathFile given if (isHasInput && input_radio_File.Checked) { accountNameInput = outputObj.AccountName; if (string.IsNullOrEmpty(accountNameInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Account Name"); return; } accountKeyInput = outputObj.AccountKey; if (string.IsNullOrEmpty(accountKeyInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Account Key"); return; } containerInput = outputObj.Container; if (string.IsNullOrEmpty(containerInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Container Name"); return; } if (string.IsNullOrEmpty(_fileUpload.FileName)) { //Console.WriteLine("Upload Error"); ShowError("Please choose input file"); return; } inputBlobName = inputFileName; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "disable", "$(\"#btnclear\").prop(\"disabled\",true);", true); bool uploadresult = await uploadBigFile(accountNameInput, accountKeyInput, containerInput, inputFileName); //$("#btnclear").prop("disabled",true) if (!uploadresult) { //Console.WriteLine("Upload Error"); ShowError("Upload Error"); return; } } // First collect and fill in the URI and access key for your web service endpoint. // These are available on your service's API help page. var endpointUri = paramObj.Url; string accessKey = Crypto.DecryptStringAES(paramObj.APIKey); // Create an Azure Machine Learning runtime client for this endpoint var runtimeClient = new RuntimeClient(endpointUri, accessKey); // Define the request information for your batch job. This information can contain: // -- A reference to the AzureBlob containing the input for your job run // -- A set of values for global parameters defined as part of your experiment and service // -- A set of output blob locations that allow you to redirect the job's results // NOTE: This sample is applicable, as is, for a service with explicit input port and // potential global parameters. Also, we choose to also demo how you could override the // location of one of the output blobs that could be generated by your service. You might // need to tweak these features to adjust the sample to your service. // // All of these properties of a BatchJobRequest shown below can be optional, depending on // your service, so it is not required to specify all with any request. If you do not want to // use any of the parameters, a null value should be passed in its place. // Define the reference to the blob containing your input data. You can refer to this blob by its // connection string / container / blob name values; alternatively, we also support references // based on a blob SAS URI string ext = ".csv";//inputBlobName.Substring(inputBlobName.LastIndexOf(".")); BlobReference inputBlob; if (isHasInput) { inputBlob = BlobReference.CreateFromConnectionStringData( connectionString: string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", accountNameInput, accountKeyInput), containerName: containerInput, blobName: inputBlobName); ext = inputBlobName.Substring(inputBlobName.LastIndexOf(".")); } else inputBlob = null; // If desired, one can override the location where the job outputs are to be stored, by passing in // the storage account details and name of the blob where we want the output to be redirected to. var outputLocations = new Dictionary<string, BlobReference>(); foreach (var keyvalue in outputObj.NodeOutputName) { outputLocations.Add( keyvalue.Key, BlobReference.CreateFromConnectionStringData( connectionString: string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", outputObj.AccountName, outputObj.AccountKey), containerName: outputObj.Container, blobName: !outputObj.isAddTime ? keyvalue.Value + "_" + DateTime.Now.ToString("MMddyy_hhmmss") + ext : keyvalue.Value + ext )); }; // If applicable, you can also set the global parameters for your service var globalParameters = new Dictionary<string, string>(); foreach(var global in paramObj.listGlobalParameter) { string columnValue = ""; var control = FindControl(global.Name); if (control is TextBox) { TextBox txt = control as TextBox; if (txt.Text != "") columnValue = txt.Text; } else if (control is DropDownList) { DropDownList lb = control as DropDownList; if (lb.SelectedIndex != -1) columnValue = lb.SelectedValue; } if (control is RadioButtonList) { RadioButtonList ct = control as RadioButtonList; if (ct.SelectedIndex != -1) columnValue = ct.SelectedValue; } globalParameters.Add(global.Name, columnValue); } var jobRequest = new BatchJobRequest { Input = inputBlob, GlobalParameters = globalParameters, Outputs = outputLocations }; try { // Register the batch job with the system, which will grant you access to a job object BatchJob job = await runtimeClient.RegisterBatchJobAsync(jobRequest); AddJobIdCookie(job.Id, job.CreatedAt.ToLocalTime().ToString()); // Start the job to allow it to be scheduled in the running queue await job.StartAsync(); //ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('Status.aspx?jobid=" + job.Id + "');", true); Response.Redirect("Status.aspx?jobid=" + job.Id); // Wait for the job's completion and handle the output //BatchJobStatus jobStatus = await job.WaitForCompletionAsync(); //while (job.CheckStatus().JobState != JobState.Finished && job.CheckStatus().JobState != JobState.Failed) //{ // Console.WriteLine(job.Id + ":" + job.CreatedAt.ToLocalTime() + job.CheckStatus().JobState); //} //BatchJobStatus jobStatus = job.CheckStatus(); ////job.CreatedAt //if (jobStatus.JobState == JobState.Finished) //{ // // Process job outputs // //Console.WriteLine(@"Job {0} has completed successfully and returned {1} outputs", job.Id, jobStatus.Results.Count); // lblJobIdSuccess.Text = job.Id; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "CompleteSuccess", "$('#CompleteSuccess').modal();", true); // foreach (var output in jobStatus.Results) // { // //Console.WriteLine(@"\t{0}: {1}", output.Key, output.Value.AbsoluteUri); // Response.Redirect(output.Value.AbsoluteUri); // } //} //else if (jobStatus.JobState == JobState.Failed) //{ // // Handle job failure // //Console.WriteLine(@"Job {0} has failed with this error: {1}", job.Id, jobStatus.Details); // txtresultModal.Text = jobStatus.Details; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); //} } catch (ArgumentException ex) { //Console.WriteLine("Argument {0} is invalid: {1}", aex.ParamName, aex.Message); //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } catch (RuntimeException runtimeError) { //Console.WriteLine("Runtime error occurred: {0} - {1}", runtimeError.ErrorCode, runtimeError.Message); //Console.WriteLine("Error details:"); string error = ""; foreach (var errorDetails in runtimeError.Details) { error += string.Format("\t{0} - {1}", errorDetails.Code, errorDetails.Message); } //txtresultModal.Text = error; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(error); } catch (Exception ex) { //Console.WriteLine("Unexpected error occurred: {0} - {1}", ex.GetType().Name, ex.Message); //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } }
async Task InvokeBatchExecutionService(string accountNameInput, string accountKeyInput, string containerInput, string inputBlobName, string inputFileName, OutputObject outputObj) { // Upload file to Blob if pathFile given if (isHasInput && input_radio_File.Checked) { accountNameInput = outputObj.AccountName; if (string.IsNullOrEmpty(accountNameInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Account Name"); return; } accountKeyInput = outputObj.AccountKey; if (string.IsNullOrEmpty(accountKeyInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Account Key"); return; } containerInput = outputObj.Container; if (string.IsNullOrEmpty(containerInput)) { //Console.WriteLine("Upload Error"); ShowError("Please enter Container Name"); return; } if (string.IsNullOrEmpty(_fileUpload.FileName)) { //Console.WriteLine("Upload Error"); ShowError("Please choose input file"); return; } inputBlobName = inputFileName; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "disable", "$(\"#btnclear\").prop(\"disabled\",true);", true); bool uploadresult = await uploadBigFile(accountNameInput, accountKeyInput, containerInput, inputFileName); //$("#btnclear").prop("disabled",true) if (!uploadresult) { //Console.WriteLine("Upload Error"); ShowError("Upload Error"); return; } } // First collect and fill in the URI and access key for your web service endpoint. // These are available on your service's API help page. var endpointUri = paramObj.Url; string accessKey = Crypto.DecryptStringAES(paramObj.APIKey); // Create an Azure Machine Learning runtime client for this endpoint var runtimeClient = new RuntimeClient(endpointUri, accessKey); // Define the request information for your batch job. This information can contain: // -- A reference to the AzureBlob containing the input for your job run // -- A set of values for global parameters defined as part of your experiment and service // -- A set of output blob locations that allow you to redirect the job's results // NOTE: This sample is applicable, as is, for a service with explicit input port and // potential global parameters. Also, we choose to also demo how you could override the // location of one of the output blobs that could be generated by your service. You might // need to tweak these features to adjust the sample to your service. // // All of these properties of a BatchJobRequest shown below can be optional, depending on // your service, so it is not required to specify all with any request. If you do not want to // use any of the parameters, a null value should be passed in its place. // Define the reference to the blob containing your input data. You can refer to this blob by its // connection string / container / blob name values; alternatively, we also support references // based on a blob SAS URI string ext = ".csv";//inputBlobName.Substring(inputBlobName.LastIndexOf(".")); BlobReference inputBlob; if (isHasInput) { inputBlob = BlobReference.CreateFromConnectionStringData( connectionString: string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", accountNameInput, accountKeyInput), containerName: containerInput, blobName: inputBlobName); ext = inputBlobName.Substring(inputBlobName.LastIndexOf(".")); } else { inputBlob = null; } // If desired, one can override the location where the job outputs are to be stored, by passing in // the storage account details and name of the blob where we want the output to be redirected to. var outputLocations = new Dictionary <string, BlobReference>(); foreach (var keyvalue in outputObj.NodeOutputName) { outputLocations.Add( keyvalue.Key, BlobReference.CreateFromConnectionStringData( connectionString: string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", outputObj.AccountName, outputObj.AccountKey), containerName: outputObj.Container, blobName: !outputObj.isAddTime ? keyvalue.Value + "_" + DateTime.Now.ToString("MMddyy_hhmmss") + ext : keyvalue.Value + ext )); } ; // If applicable, you can also set the global parameters for your service var globalParameters = new Dictionary <string, string>(); foreach (var global in paramObj.listGlobalParameter) { string columnValue = ""; var control = FindControl(global.Name); if (control is TextBox) { TextBox txt = control as TextBox; if (txt.Text != "") { columnValue = txt.Text; } } else if (control is DropDownList) { DropDownList lb = control as DropDownList; if (lb.SelectedIndex != -1) { columnValue = lb.SelectedValue; } } if (control is RadioButtonList) { RadioButtonList ct = control as RadioButtonList; if (ct.SelectedIndex != -1) { columnValue = ct.SelectedValue; } } globalParameters.Add(global.Name, columnValue); } var jobRequest = new BatchJobRequest { Input = inputBlob, GlobalParameters = globalParameters, Outputs = outputLocations }; try { // Register the batch job with the system, which will grant you access to a job object BatchJob job = await runtimeClient.RegisterBatchJobAsync(jobRequest); AddJobIdCookie(job.Id, job.CreatedAt.ToLocalTime().ToString()); // Start the job to allow it to be scheduled in the running queue await job.StartAsync(); //ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('Status.aspx?jobid=" + job.Id + "');", true); Response.Redirect("Status.aspx?jobid=" + job.Id); // Wait for the job's completion and handle the output //BatchJobStatus jobStatus = await job.WaitForCompletionAsync(); //while (job.CheckStatus().JobState != JobState.Finished && job.CheckStatus().JobState != JobState.Failed) //{ // Console.WriteLine(job.Id + ":" + job.CreatedAt.ToLocalTime() + job.CheckStatus().JobState); //} //BatchJobStatus jobStatus = job.CheckStatus(); ////job.CreatedAt //if (jobStatus.JobState == JobState.Finished) //{ // // Process job outputs // //Console.WriteLine(@"Job {0} has completed successfully and returned {1} outputs", job.Id, jobStatus.Results.Count); // lblJobIdSuccess.Text = job.Id; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "CompleteSuccess", "$('#CompleteSuccess').modal();", true); // foreach (var output in jobStatus.Results) // { // //Console.WriteLine(@"\t{0}: {1}", output.Key, output.Value.AbsoluteUri); // Response.Redirect(output.Value.AbsoluteUri); // } //} //else if (jobStatus.JobState == JobState.Failed) //{ // // Handle job failure // //Console.WriteLine(@"Job {0} has failed with this error: {1}", job.Id, jobStatus.Details); // txtresultModal.Text = jobStatus.Details; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); //} } catch (ArgumentException ex) { //Console.WriteLine("Argument {0} is invalid: {1}", aex.ParamName, aex.Message); //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } catch (RuntimeException runtimeError) { //Console.WriteLine("Runtime error occurred: {0} - {1}", runtimeError.ErrorCode, runtimeError.Message); //Console.WriteLine("Error details:"); string error = ""; foreach (var errorDetails in runtimeError.Details) { error += string.Format("\t{0} - {1}", errorDetails.Code, errorDetails.Message); } //txtresultModal.Text = error; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(error); } catch (Exception ex) { //Console.WriteLine("Unexpected error occurred: {0} - {1}", ex.GetType().Name, ex.Message); //txtresultModal.Text = ex.Message; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "failModal", "$('#failModal').modal();", true); ShowError(ex.Message); } }