Search in sources :

Example 1 with TrainingPipelineName

use of com.google.cloud.aiplatform.v1.TrainingPipelineName in project java-aiplatform by googleapis.

the class GetTrainingPipelineSample method getTrainingPipeline.

static void getTrainingPipeline(String project, String trainingPipelineId) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        TrainingPipelineName trainingPipelineName = TrainingPipelineName.of(project, location, trainingPipelineId);
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.getTrainingPipeline(trainingPipelineName);
        System.out.println("Get Training Pipeline Response");
        System.out.format("\tName: %s\n", trainingPipelineResponse.getName());
        System.out.format("\tDisplay Name: %s\n", trainingPipelineResponse.getDisplayName());
        System.out.format("\tTraining Task Definition: %s\n", trainingPipelineResponse.getTrainingTaskDefinition());
        System.out.format("\tTraining Task Inputs: %s\n", trainingPipelineResponse.getTrainingTaskInputs());
        System.out.format("\tTraining Task Metadata: %s\n", trainingPipelineResponse.getTrainingTaskMetadata());
        System.out.format("\tState: %s\n", trainingPipelineResponse.getState());
        System.out.format("\tCreate Time: %s\n", trainingPipelineResponse.getCreateTime());
        System.out.format("\tStart Time: %s\n", trainingPipelineResponse.getStartTime());
        System.out.format("\tEnd Time: %s\n", trainingPipelineResponse.getEndTime());
        System.out.format("\tUpdate Time: %s\n", trainingPipelineResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", trainingPipelineResponse.getLabelsMap());
        InputDataConfig inputDataConfig = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s\n", inputDataConfig.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfig.getAnnotationsFilter());
        FractionSplit fractionSplit = inputDataConfig.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplit.getTestFraction());
        FilterSplit filterSplit = inputDataConfig.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Filter: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Filter: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Filter: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfig.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfig.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\t\tModel to upload");
        System.out.format("\t\tName: %s\n", modelResponse.getName());
        System.out.format("\t\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\t\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\t\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\t\tMeta Data: %s\n", modelResponse.getMetadata());
        System.out.format("\t\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\t\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\t\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList().toString());
        System.out.format("\t\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList().toString());
        System.out.format("\t\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList().toString());
        System.out.format("\t\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\t\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\t\tLabels: %s\n", modelResponse.getLabelsMap());
        PredictSchemata predictSchemata = modelResponse.getPredictSchemata();
        System.out.println("\tPredict Schemata");
        System.out.format("\t\tInstance Schema Uri: %s\n", predictSchemata.getInstanceSchemaUri());
        System.out.format("\t\tParameters Schema Uri: %s\n", predictSchemata.getParametersSchemaUri());
        System.out.format("\t\tPrediction Schema Uri: %s\n", predictSchemata.getPredictionSchemaUri());
        for (Model.ExportFormat supportedExportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\tSupported Export Format");
            System.out.format("\t\tId: %s\n", supportedExportFormat.getId());
        }
        ModelContainerSpec containerSpec = modelResponse.getContainerSpec();
        System.out.println("\tContainer Spec");
        System.out.format("\t\tImage Uri: %s\n", containerSpec.getImageUri());
        System.out.format("\t\tCommand: %s\n", containerSpec.getCommandList());
        System.out.format("\t\tArgs: %s\n", containerSpec.getArgsList());
        System.out.format("\t\tPredict Route: %s\n", containerSpec.getPredictRoute());
        System.out.format("\t\tHealth Route: %s\n", containerSpec.getHealthRoute());
        for (EnvVar envVar : containerSpec.getEnvList()) {
            System.out.println("\t\tEnv");
            System.out.format("\t\t\tName: %s\n", envVar.getName());
            System.out.format("\t\t\tValue: %s\n", envVar.getValue());
        }
        for (Port port : containerSpec.getPortsList()) {
            System.out.println("\t\tPort");
            System.out.format("\t\t\tContainer Port: %s\n", port.getContainerPort());
        }
        for (DeployedModelRef deployedModelRef : modelResponse.getDeployedModelsList()) {
            System.out.println("\tDeployed Model");
            System.out.format("\t\tEndpoint: %s\n", deployedModelRef.getEndpoint());
            System.out.format("\t\tDeployed Model Id: %s\n", deployedModelRef.getDeployedModelId());
        }
        Status status = trainingPipelineResponse.getError();
        System.out.println("\tError");
        System.out.format("\t\tCode: %s\n", status.getCode());
        System.out.format("\t\tMessage: %s\n", status.getMessage());
    }
}
Also used : Status(com.google.rpc.Status) PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) TrainingPipelineName(com.google.cloud.aiplatform.v1.TrainingPipelineName) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Port(com.google.cloud.aiplatform.v1.Port) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) PredefinedSplit(com.google.cloud.aiplatform.v1.PredefinedSplit) FilterSplit(com.google.cloud.aiplatform.v1.FilterSplit) FractionSplit(com.google.cloud.aiplatform.v1.FractionSplit) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient)

Example 2 with TrainingPipelineName

use of com.google.cloud.aiplatform.v1.TrainingPipelineName in project java-aiplatform by googleapis.

the class CreateTrainingPipelineTabularClassificationSampleTest method tearDown.

@After
public void tearDown() throws InterruptedException, ExecutionException, IOException, TimeoutException {
    // Cancel the Training Pipeline
    CancelTrainingPipelineSample.cancelTrainingPipelineSample(PROJECT, trainingPipelineId);
    // Assert
    String cancelResponse = bout.toString();
    assertThat(cancelResponse).contains("Cancelled the Training Pipeline");
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        TrainingPipelineName trainingPipelineName = TrainingPipelineName.of(PROJECT, location, trainingPipelineId);
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.getTrainingPipeline(trainingPipelineName);
        while (!trainingPipelineResponse.getState().name().contains("STATE_CANCELLED")) {
            TimeUnit.SECONDS.sleep(30);
            trainingPipelineResponse = pipelineServiceClient.getTrainingPipeline(trainingPipelineName);
        }
    }
    // Delete the Training Pipeline
    DeleteTrainingPipelineSample.deleteTrainingPipelineSample(PROJECT, trainingPipelineId);
    // Assert
    String deleteResponse = bout.toString();
    assertThat(deleteResponse).contains("Deleted Training Pipeline.");
    System.out.flush();
    System.setOut(originalPrintStream);
}
Also used : TrainingPipelineName(com.google.cloud.aiplatform.v1.TrainingPipelineName) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient) After(org.junit.After)

Example 3 with TrainingPipelineName

use of com.google.cloud.aiplatform.v1.TrainingPipelineName in project java-aiplatform by googleapis.

the class DeleteTrainingPipelineSample method deleteTrainingPipelineSample.

static void deleteTrainingPipelineSample(String project, String trainingPipelineId) throws IOException, InterruptedException, ExecutionException, TimeoutException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        TrainingPipelineName trainingPipelineName = TrainingPipelineName.of(project, location, trainingPipelineId);
        OperationFuture<Empty, DeleteOperationMetadata> operationFuture = pipelineServiceClient.deleteTrainingPipelineAsync(trainingPipelineName);
        System.out.format("Operation name: %s\n", operationFuture.getInitialFuture().get().getName());
        System.out.println("Waiting for operation to finish...");
        operationFuture.get(300, TimeUnit.SECONDS);
        System.out.format("Deleted Training Pipeline.");
    }
}
Also used : TrainingPipelineName(com.google.cloud.aiplatform.v1.TrainingPipelineName) Empty(com.google.protobuf.Empty) DeleteOperationMetadata(com.google.cloud.aiplatform.v1.DeleteOperationMetadata) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient)

Example 4 with TrainingPipelineName

use of com.google.cloud.aiplatform.v1.TrainingPipelineName in project java-aiplatform by googleapis.

the class CancelTrainingPipelineSample method cancelTrainingPipelineSample.

static void cancelTrainingPipelineSample(String project, String trainingPipelineId) throws IOException {
    PipelineServiceSettings pipelineServiceSettings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient pipelineServiceClient = PipelineServiceClient.create(pipelineServiceSettings)) {
        String location = "us-central1";
        TrainingPipelineName trainingPipelineName = TrainingPipelineName.of(project, location, trainingPipelineId);
        pipelineServiceClient.cancelTrainingPipeline(trainingPipelineName);
        System.out.println("Cancelled the Training Pipeline");
    }
}
Also used : TrainingPipelineName(com.google.cloud.aiplatform.v1.TrainingPipelineName) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient)

Aggregations

PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)4 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)4 TrainingPipelineName (com.google.cloud.aiplatform.v1.TrainingPipelineName)4 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)2 DeleteOperationMetadata (com.google.cloud.aiplatform.v1.DeleteOperationMetadata)1 DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)1 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)1 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)1 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)1 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)1 Model (com.google.cloud.aiplatform.v1.Model)1 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)1 Port (com.google.cloud.aiplatform.v1.Port)1 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)1 PredictSchemata (com.google.cloud.aiplatform.v1.PredictSchemata)1 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)1 Empty (com.google.protobuf.Empty)1 Status (com.google.rpc.Status)1 After (org.junit.After)1