/// <summary>Snippet for BatchPredictAsync</summary> public async Task BatchPredictRequestObjectAsync() { // Snippet: BatchPredictAsync(BatchPredictRequest, CallSettings) // Additional: BatchPredictAsync(BatchPredictRequest, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) BatchPredictRequest request = new BatchPredictRequest { ModelName = ModelName.FromProjectLocationModel("[PROJECT]", "[LOCATION]", "[MODEL]"), InputConfig = new BatchPredictInputConfig(), OutputConfig = new BatchPredictOutputConfig(), Params = { { "", "" }, }, }; // Make the request Operation <BatchPredictResult, OperationMetadata> response = await predictionServiceClient.BatchPredictAsync(request); // Poll until the returned long-running operation is complete Operation <BatchPredictResult, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result BatchPredictResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchPredictResult, OperationMetadata> retrievedResponse = await predictionServiceClient.PollOnceBatchPredictAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchPredictResult retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for BatchPredictAsync</summary> public async Task BatchPredictAsync() { // Snippet: BatchPredictAsync(ModelName,BatchPredictInputConfig,BatchPredictOutputConfig,IDictionary<string, string>,CallSettings) // Additional: BatchPredictAsync(ModelName,BatchPredictInputConfig,BatchPredictOutputConfig,IDictionary<string, string>,CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) ModelName name = new ModelName("[PROJECT]", "[LOCATION]", "[MODEL]"); BatchPredictInputConfig inputConfig = new BatchPredictInputConfig(); BatchPredictOutputConfig outputConfig = new BatchPredictOutputConfig(); IDictionary <string, string> @params = new Dictionary <string, string>(); // Make the request Operation <BatchPredictResult, OperationMetadata> response = await predictionServiceClient.BatchPredictAsync(name, inputConfig, outputConfig, @params); // Poll until the returned long-running operation is complete Operation <BatchPredictResult, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result BatchPredictResult result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <BatchPredictResult, OperationMetadata> retrievedResponse = await predictionServiceClient.PollOnceBatchPredictAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result BatchPredictResult retrievedResult = retrievedResponse.Result; } // End snippet }
/// <summary>Snippet for PredictAsync</summary> public async Task PredictRequestObjectAsync() { // Snippet: PredictAsync(PredictRequest, CallSettings) // Additional: PredictAsync(PredictRequest, CancellationToken) // Create client PredictionServiceClient predictionServiceClient = await PredictionServiceClient.CreateAsync(); // Initialize request argument(s) PredictRequest request = new PredictRequest { Placement = "", UserEvent = new UserEvent(), PageSize = 0, PageToken = "", Filter = "", ValidateOnly = false, Params = { { "", new Value() }, }, Labels = { { "", "" }, }, }; // Make the request PredictResponse response = await predictionServiceClient.PredictAsync(request); // End snippet }