Skip to content

Commit

Permalink
samples: updates samples to v1 (5 of 10) (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
telpirion authored Apr 26, 2021
1 parent 2a0bbdc commit aaeb060
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
// [START aiplatform_export_model_sample]

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1beta1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1beta1.ExportModelRequest;
import com.google.cloud.aiplatform.v1beta1.ExportModelResponse;
import com.google.cloud.aiplatform.v1beta1.GcsDestination;
import com.google.cloud.aiplatform.v1beta1.ModelName;
import com.google.cloud.aiplatform.v1beta1.ModelServiceClient;
import com.google.cloud.aiplatform.v1beta1.ModelServiceSettings;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
// [START aiplatform_export_model_tabular_classification_sample]

import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1beta1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1beta1.ExportModelRequest;
import com.google.cloud.aiplatform.v1beta1.ExportModelResponse;
import com.google.cloud.aiplatform.v1beta1.GcsDestination;
import com.google.cloud.aiplatform.v1beta1.ModelName;
import com.google.cloud.aiplatform.v1beta1.ModelServiceClient;
import com.google.cloud.aiplatform.v1beta1.ModelServiceSettings;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

// [START aiplatform_export_model_video_action_recognition_sample]
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1beta1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1beta1.ExportModelRequest;
import com.google.cloud.aiplatform.v1beta1.ExportModelResponse;
import com.google.cloud.aiplatform.v1beta1.GcsDestination;
import com.google.cloud.aiplatform.v1beta1.ModelName;
import com.google.cloud.aiplatform.v1beta1.ModelServiceClient;
import com.google.cloud.aiplatform.v1beta1.ModelServiceSettings;
import com.google.cloud.aiplatform.v1.ExportModelOperationMetadata;
import com.google.cloud.aiplatform.v1.ExportModelRequest;
import com.google.cloud.aiplatform.v1.ExportModelResponse;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@

// [START aiplatform_get_batch_prediction_job_sample]

import com.google.cloud.aiplatform.v1beta1.BatchPredictionJob;
import com.google.cloud.aiplatform.v1beta1.BatchPredictionJob.InputConfig;
import com.google.cloud.aiplatform.v1beta1.BatchPredictionJob.OutputConfig;
import com.google.cloud.aiplatform.v1beta1.BatchPredictionJob.OutputInfo;
import com.google.cloud.aiplatform.v1beta1.BatchPredictionJobName;
import com.google.cloud.aiplatform.v1beta1.BigQueryDestination;
import com.google.cloud.aiplatform.v1beta1.BigQuerySource;
import com.google.cloud.aiplatform.v1beta1.CompletionStats;
import com.google.cloud.aiplatform.v1beta1.GcsDestination;
import com.google.cloud.aiplatform.v1beta1.GcsSource;
import com.google.cloud.aiplatform.v1beta1.JobServiceClient;
import com.google.cloud.aiplatform.v1beta1.JobServiceSettings;
import com.google.cloud.aiplatform.v1beta1.ResourcesConsumed;
import com.google.cloud.aiplatform.v1.BatchPredictionJob;
import com.google.cloud.aiplatform.v1.BatchPredictionJob.InputConfig;
import com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputConfig;
import com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputInfo;
import com.google.cloud.aiplatform.v1.BatchPredictionJobName;
import com.google.cloud.aiplatform.v1.BigQueryDestination;
import com.google.cloud.aiplatform.v1.BigQuerySource;
import com.google.cloud.aiplatform.v1.CompletionStats;
import com.google.cloud.aiplatform.v1.GcsDestination;
import com.google.cloud.aiplatform.v1.GcsSource;
import com.google.cloud.aiplatform.v1.JobServiceClient;
import com.google.cloud.aiplatform.v1.JobServiceSettings;
import com.google.cloud.aiplatform.v1.ResourcesConsumed;
import com.google.protobuf.Any;
import com.google.rpc.Status;
import java.io.IOException;
Expand Down Expand Up @@ -69,8 +69,6 @@ static void getBatchPredictionJobSample(String project, String batchPredictionJo
System.out.format("\tModel: %s\n", batchPredictionJob.getModel());

System.out.format("\tModel Parameters: %s\n", batchPredictionJob.getModelParameters());
System.out.format(
"\tGenerate Explanation: %s\n", batchPredictionJob.getGenerateExplanation());
System.out.format("\tState: %s\n", batchPredictionJob.getState());

System.out.format("\tCreate Time: %s\n", batchPredictionJob.getCreateTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package aiplatform;

// [START aiplatform_get_hyperparameter_tuning_job_sample]
import com.google.cloud.aiplatform.v1beta1.HyperparameterTuningJob;
import com.google.cloud.aiplatform.v1beta1.HyperparameterTuningJobName;
import com.google.cloud.aiplatform.v1beta1.JobServiceClient;
import com.google.cloud.aiplatform.v1beta1.JobServiceSettings;
import com.google.cloud.aiplatform.v1.HyperparameterTuningJob;
import com.google.cloud.aiplatform.v1.HyperparameterTuningJobName;
import com.google.cloud.aiplatform.v1.JobServiceClient;
import com.google.cloud.aiplatform.v1.JobServiceSettings;
import java.io.IOException;

public class GetHyperparameterTuningJobSample {
Expand Down
20 changes: 10 additions & 10 deletions aiplatform/snippets/src/main/java/aiplatform/GetModelSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@

// [START aiplatform_get_model_sample]

import com.google.cloud.aiplatform.v1beta1.DeployedModelRef;
import com.google.cloud.aiplatform.v1beta1.EnvVar;
import com.google.cloud.aiplatform.v1beta1.Model;
import com.google.cloud.aiplatform.v1beta1.Model.ExportFormat;
import com.google.cloud.aiplatform.v1beta1.ModelContainerSpec;
import com.google.cloud.aiplatform.v1beta1.ModelName;
import com.google.cloud.aiplatform.v1beta1.ModelServiceClient;
import com.google.cloud.aiplatform.v1beta1.ModelServiceSettings;
import com.google.cloud.aiplatform.v1beta1.Port;
import com.google.cloud.aiplatform.v1beta1.PredictSchemata;
import com.google.cloud.aiplatform.v1.DeployedModelRef;
import com.google.cloud.aiplatform.v1.EnvVar;
import com.google.cloud.aiplatform.v1.Model;
import com.google.cloud.aiplatform.v1.Model.ExportFormat;
import com.google.cloud.aiplatform.v1.ModelContainerSpec;
import com.google.cloud.aiplatform.v1.ModelName;
import com.google.cloud.aiplatform.v1.ModelServiceClient;
import com.google.cloud.aiplatform.v1.ModelServiceSettings;
import com.google.cloud.aiplatform.v1.Port;
import com.google.cloud.aiplatform.v1.PredictSchemata;
import java.io.IOException;

public class GetModelSample {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,21 @@

// [START aiplatform_get_training_pipeline_sample]

import com.google.cloud.aiplatform.v1beta1.DeployedModelRef;
import com.google.cloud.aiplatform.v1beta1.EnvVar;
import com.google.cloud.aiplatform.v1beta1.ExplanationMetadata;
import com.google.cloud.aiplatform.v1beta1.ExplanationParameters;
import com.google.cloud.aiplatform.v1beta1.ExplanationSpec;
import com.google.cloud.aiplatform.v1beta1.FilterSplit;
import com.google.cloud.aiplatform.v1beta1.FractionSplit;
import com.google.cloud.aiplatform.v1beta1.InputDataConfig;
import com.google.cloud.aiplatform.v1beta1.Model;
import com.google.cloud.aiplatform.v1beta1.ModelContainerSpec;
import com.google.cloud.aiplatform.v1beta1.PipelineServiceClient;
import com.google.cloud.aiplatform.v1beta1.PipelineServiceSettings;
import com.google.cloud.aiplatform.v1beta1.Port;
import com.google.cloud.aiplatform.v1beta1.PredefinedSplit;
import com.google.cloud.aiplatform.v1beta1.PredictSchemata;
import com.google.cloud.aiplatform.v1beta1.SampledShapleyAttribution;
import com.google.cloud.aiplatform.v1beta1.TimestampSplit;
import com.google.cloud.aiplatform.v1beta1.TrainingPipeline;
import com.google.cloud.aiplatform.v1beta1.TrainingPipelineName;
import com.google.cloud.aiplatform.v1.DeployedModelRef;
import com.google.cloud.aiplatform.v1.EnvVar;
import com.google.cloud.aiplatform.v1.FilterSplit;
import com.google.cloud.aiplatform.v1.FractionSplit;
import com.google.cloud.aiplatform.v1.InputDataConfig;
import com.google.cloud.aiplatform.v1.Model;
import com.google.cloud.aiplatform.v1.ModelContainerSpec;
import com.google.cloud.aiplatform.v1.PipelineServiceClient;
import com.google.cloud.aiplatform.v1.PipelineServiceSettings;
import com.google.cloud.aiplatform.v1.Port;
import com.google.cloud.aiplatform.v1.PredefinedSplit;
import com.google.cloud.aiplatform.v1.PredictSchemata;
import com.google.cloud.aiplatform.v1.TimestampSplit;
import com.google.cloud.aiplatform.v1.TrainingPipeline;
import com.google.cloud.aiplatform.v1.TrainingPipelineName;
import com.google.rpc.Status;
import java.io.IOException;

Expand Down Expand Up @@ -171,25 +167,6 @@ static void getTrainingPipeline(String project, String trainingPipelineId) throw
System.out.format("\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
}

ExplanationSpec explanationSpec = modelResponse.getExplanationSpec();
System.out.println("\tExplanation Spec");

ExplanationParameters explanationParameters = explanationSpec.getParameters();
System.out.println("\t\tParameters");

SampledShapleyAttribution sampledShapleyAttribution =
explanationParameters.getSampledShapleyAttribution();
System.out.println("\t\tSampled Shapley Attribution");
System.out.format("\t\t\tPath Count: %s\n", sampledShapleyAttribution.getPathCount());

ExplanationMetadata explanationMetadata = explanationSpec.getMetadata();
System.out.println("\t\tMetadata");
System.out.format("\t\t\tInput: %s\n", explanationMetadata.getInputsMap());
System.out.format("\t\t\tOutput: %s\n", explanationMetadata.getOutputsMap());
System.out.format(
"\t\t\tFeature Attributions Schema Uri: %s\n",
explanationMetadata.getFeatureAttributionsSchemaUri());

Status status = trainingPipelineResponse.getError();
System.out.println("\tError");
System.out.format("\t\tCode: %s\n", status.getCode());
Expand Down

0 comments on commit aaeb060

Please sign in to comment.