示例#1
0
        /// <summary>Snippet for BatchPredict</summary>
        public void BatchPredictRequestObject()
        {
            // Snippet: BatchPredict(BatchPredictRequest, CallSettings)
            // Create client
            PredictionServiceClient predictionServiceClient = PredictionServiceClient.Create();
            // 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 = predictionServiceClient.BatchPredict(request);

            // Poll until the returned long-running operation is complete
            Operation <BatchPredictResult, OperationMetadata> completedResponse = response.PollUntilCompleted();
            // 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 = predictionServiceClient.PollOnceBatchPredict(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
        }
示例#2
0
        /// <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
            {
                Name         = "",
                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
        }