Search in sources :

Example 1 with ContainerSpec

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

the class GetModelSample method getModelSample.

static void getModelSample(String project, String modelId) throws IOException {
    ModelServiceSettings modelServiceSettings = ModelServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (ModelServiceClient modelServiceClient = ModelServiceClient.create(modelServiceSettings)) {
        String location = "us-central1";
        ModelName modelName = ModelName.of(project, location, modelId);
        Model modelResponse = modelServiceClient.getModel(modelName);
        System.out.println("Get Model response");
        System.out.format("\tName: %s\n", modelResponse.getName());
        System.out.format("\tDisplay Name: %s\n", modelResponse.getDisplayName());
        System.out.format("\tDescription: %s\n", modelResponse.getDescription());
        System.out.format("\tMetadata Schema Uri: %s\n", modelResponse.getMetadataSchemaUri());
        System.out.format("\tMetadata: %s\n", modelResponse.getMetadata());
        System.out.format("\tTraining Pipeline: %s\n", modelResponse.getTrainingPipeline());
        System.out.format("\tArtifact Uri: %s\n", modelResponse.getArtifactUri());
        System.out.format("\tSupported Deployment Resources Types: %s\n", modelResponse.getSupportedDeploymentResourcesTypesList());
        System.out.format("\tSupported Input Storage Formats: %s\n", modelResponse.getSupportedInputStorageFormatsList());
        System.out.format("\tSupported Output Storage Formats: %s\n", modelResponse.getSupportedOutputStorageFormatsList());
        System.out.format("\tCreate Time: %s\n", modelResponse.getCreateTime());
        System.out.format("\tUpdate Time: %s\n", modelResponse.getUpdateTime());
        System.out.format("\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 (ExportFormat exportFormat : modelResponse.getSupportedExportFormatsList()) {
            System.out.println("\tSupported Export Format");
            System.out.format("\t\tId: %s\n", exportFormat.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());
        }
    }
}
Also used : PredictSchemata(com.google.cloud.aiplatform.v1.PredictSchemata) ModelName(com.google.cloud.aiplatform.v1.ModelName) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) ModelServiceSettings(com.google.cloud.aiplatform.v1.ModelServiceSettings) Port(com.google.cloud.aiplatform.v1.Port) DeployedModelRef(com.google.cloud.aiplatform.v1.DeployedModelRef) Model(com.google.cloud.aiplatform.v1.Model) EnvVar(com.google.cloud.aiplatform.v1.EnvVar) ExportFormat(com.google.cloud.aiplatform.v1.Model.ExportFormat) ModelServiceClient(com.google.cloud.aiplatform.v1.ModelServiceClient)

Example 2 with ContainerSpec

use of com.google.cloud.aiplatform.v1.ContainerSpec 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 3 with ContainerSpec

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

the class CreateHyperparameterTuningJobSample method createHyperparameterTuningJobSample.

static void createHyperparameterTuningJobSample(String project, String displayName, String containerImageUri) throws IOException {
    JobServiceSettings settings = JobServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    String location = "us-central1";
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient client = JobServiceClient.create(settings)) {
        StudySpec.MetricSpec metric0 = StudySpec.MetricSpec.newBuilder().setMetricId("accuracy").setGoal(StudySpec.MetricSpec.GoalType.MAXIMIZE).build();
        StudySpec.ParameterSpec.DoubleValueSpec doubleValueSpec = StudySpec.ParameterSpec.DoubleValueSpec.newBuilder().setMinValue(0.001).setMaxValue(0.1).build();
        StudySpec.ParameterSpec parameter0 = StudySpec.ParameterSpec.newBuilder().setParameterId("lr").setDoubleValueSpec(doubleValueSpec).build();
        StudySpec studySpec = StudySpec.newBuilder().addMetrics(metric0).addParameters(parameter0).build();
        MachineSpec machineSpec = MachineSpec.newBuilder().setMachineType("n1-standard-4").setAcceleratorType(AcceleratorType.NVIDIA_TESLA_K80).setAcceleratorCount(1).build();
        ContainerSpec containerSpec = ContainerSpec.newBuilder().setImageUri(containerImageUri).build();
        WorkerPoolSpec workerPoolSpec0 = WorkerPoolSpec.newBuilder().setMachineSpec(machineSpec).setReplicaCount(1).setContainerSpec(containerSpec).build();
        CustomJobSpec trialJobSpec = CustomJobSpec.newBuilder().addWorkerPoolSpecs(workerPoolSpec0).build();
        HyperparameterTuningJob hyperparameterTuningJob = HyperparameterTuningJob.newBuilder().setDisplayName(displayName).setMaxTrialCount(2).setParallelTrialCount(1).setMaxFailedTrialCount(1).setStudySpec(studySpec).setTrialJobSpec(trialJobSpec).build();
        LocationName parent = LocationName.of(project, location);
        HyperparameterTuningJob response = client.createHyperparameterTuningJob(parent, hyperparameterTuningJob);
        System.out.format("response: %s\n", response);
        System.out.format("Name: %s\n", response.getName());
    }
}
Also used : JobServiceSettings(com.google.cloud.aiplatform.v1.JobServiceSettings) StudySpec(com.google.cloud.aiplatform.v1.StudySpec) ContainerSpec(com.google.cloud.aiplatform.v1.ContainerSpec) JobServiceClient(com.google.cloud.aiplatform.v1.JobServiceClient) CustomJobSpec(com.google.cloud.aiplatform.v1.CustomJobSpec) MachineSpec(com.google.cloud.aiplatform.v1.MachineSpec) LocationName(com.google.cloud.aiplatform.v1.LocationName) HyperparameterTuningJob(com.google.cloud.aiplatform.v1.HyperparameterTuningJob) WorkerPoolSpec(com.google.cloud.aiplatform.v1.WorkerPoolSpec)

Example 4 with ContainerSpec

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

the class CreateTrainingPipelineCustomTrainingManagedDatasetSample method createTrainingPipelineCustomTrainingManagedDatasetSample.

static void createTrainingPipelineCustomTrainingManagedDatasetSample(String project, String displayName, String modelDisplayName, String datasetId, String annotationSchemaUri, String trainingContainerSpecImageUri, String modelContainerSpecImageUri, String baseOutputUriPrefix) throws IOException {
    PipelineServiceSettings settings = PipelineServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    String location = "us-central1";
    // the "close" method on the client to safely clean up any remaining background resources.
    try (PipelineServiceClient client = PipelineServiceClient.create(settings)) {
        JsonArray jsonArgs = new JsonArray();
        jsonArgs.add("--model-dir=$(AIP_MODEL_DIR)");
        // training_task_inputs
        JsonObject jsonTrainingContainerSpec = new JsonObject();
        jsonTrainingContainerSpec.addProperty("imageUri", trainingContainerSpecImageUri);
        // AIP_MODEL_DIR is set by the service according to baseOutputDirectory.
        jsonTrainingContainerSpec.add("args", jsonArgs);
        JsonObject jsonMachineSpec = new JsonObject();
        jsonMachineSpec.addProperty("machineType", "n1-standard-8");
        JsonObject jsonTrainingWorkerPoolSpec = new JsonObject();
        jsonTrainingWorkerPoolSpec.addProperty("replicaCount", 1);
        jsonTrainingWorkerPoolSpec.add("machineSpec", jsonMachineSpec);
        jsonTrainingWorkerPoolSpec.add("containerSpec", jsonTrainingContainerSpec);
        JsonArray jsonWorkerPoolSpecs = new JsonArray();
        jsonWorkerPoolSpecs.add(jsonTrainingWorkerPoolSpec);
        JsonObject jsonBaseOutputDirectory = new JsonObject();
        jsonBaseOutputDirectory.addProperty("outputUriPrefix", baseOutputUriPrefix);
        JsonObject jsonTrainingTaskInputs = new JsonObject();
        jsonTrainingTaskInputs.add("workerPoolSpecs", jsonWorkerPoolSpecs);
        jsonTrainingTaskInputs.add("baseOutputDirectory", jsonBaseOutputDirectory);
        Value.Builder trainingTaskInputsBuilder = Value.newBuilder();
        JsonFormat.parser().merge(jsonTrainingTaskInputs.toString(), trainingTaskInputsBuilder);
        Value trainingTaskInputs = trainingTaskInputsBuilder.build();
        // model_to_upload
        ModelContainerSpec modelContainerSpec = ModelContainerSpec.newBuilder().setImageUri(modelContainerSpecImageUri).build();
        Model model = Model.newBuilder().setDisplayName(modelDisplayName).setContainerSpec(modelContainerSpec).build();
        GcsDestination gcsDestination = GcsDestination.newBuilder().setOutputUriPrefix(baseOutputUriPrefix).build();
        // input_data_config
        InputDataConfig inputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).setAnnotationSchemaUri(annotationSchemaUri).setGcsDestination(gcsDestination).build();
        // training_task_definition
        String customTaskDefinition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/custom_task_1.0.0.yaml";
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(displayName).setInputDataConfig(inputDataConfig).setTrainingTaskDefinition(customTaskDefinition).setTrainingTaskInputs(trainingTaskInputs).setModelToUpload(model).build();
        LocationName parent = LocationName.of(project, location);
        TrainingPipeline response = client.createTrainingPipeline(parent, trainingPipeline);
        System.out.format("response: %s\n", response);
        System.out.format("Name: %s\n", response.getName());
    }
}
Also used : TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) JsonObject(com.google.gson.JsonObject) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName) JsonArray(com.google.gson.JsonArray) ModelContainerSpec(com.google.cloud.aiplatform.v1.ModelContainerSpec) Value(com.google.protobuf.Value) Model(com.google.cloud.aiplatform.v1.Model) PipelineServiceSettings(com.google.cloud.aiplatform.v1.PipelineServiceSettings) PipelineServiceClient(com.google.cloud.aiplatform.v1.PipelineServiceClient) GcsDestination(com.google.cloud.aiplatform.v1.GcsDestination)

Example 5 with ContainerSpec

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

the class CreateTrainingPipelineTabularClassificationSample method createTrainingPipelineTableClassification.

static void createTrainingPipelineTableClassification(String project, String modelDisplayName, String datasetId, String targetColumn) 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";
        LocationName locationName = LocationName.of(project, location);
        String trainingTaskDefinition = "gs://google-cloud-aiplatform/schema/trainingjob/definition/automl_tables_1.0.0.yaml";
        // Set the columns used for training and their data types
        Transformation transformation1 = Transformation.newBuilder().setAuto(AutoTransformation.newBuilder().setColumnName("sepal_width").build()).build();
        Transformation transformation2 = Transformation.newBuilder().setAuto(AutoTransformation.newBuilder().setColumnName("sepal_length").build()).build();
        Transformation transformation3 = Transformation.newBuilder().setAuto(AutoTransformation.newBuilder().setColumnName("petal_length").build()).build();
        Transformation transformation4 = Transformation.newBuilder().setAuto(AutoTransformation.newBuilder().setColumnName("petal_width").build()).build();
        ArrayList<Transformation> transformationArrayList = new ArrayList<>();
        transformationArrayList.add(transformation1);
        transformationArrayList.add(transformation2);
        transformationArrayList.add(transformation3);
        transformationArrayList.add(transformation4);
        AutoMlTablesInputs autoMlTablesInputs = AutoMlTablesInputs.newBuilder().setTargetColumn(targetColumn).setPredictionType("classification").addAllTransformations(transformationArrayList).setTrainBudgetMilliNodeHours(8000).build();
        FractionSplit fractionSplit = FractionSplit.newBuilder().setTrainingFraction(0.8).setValidationFraction(0.1).setTestFraction(0.1).build();
        InputDataConfig inputDataConfig = InputDataConfig.newBuilder().setDatasetId(datasetId).setFractionSplit(fractionSplit).build();
        Model modelToUpload = Model.newBuilder().setDisplayName(modelDisplayName).build();
        TrainingPipeline trainingPipeline = TrainingPipeline.newBuilder().setDisplayName(modelDisplayName).setTrainingTaskDefinition(trainingTaskDefinition).setTrainingTaskInputs(ValueConverter.toValue(autoMlTablesInputs)).setInputDataConfig(inputDataConfig).setModelToUpload(modelToUpload).build();
        TrainingPipeline trainingPipelineResponse = pipelineServiceClient.createTrainingPipeline(locationName, trainingPipeline);
        System.out.println("Create Training Pipeline Tabular Classification 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 inputDataConfigResponse = trainingPipelineResponse.getInputDataConfig();
        System.out.println("\tInput Data Config");
        System.out.format("\t\tDataset Id: %s\n", inputDataConfigResponse.getDatasetId());
        System.out.format("\t\tAnnotations Filter: %s\n", inputDataConfigResponse.getAnnotationsFilter());
        FractionSplit fractionSplitResponse = inputDataConfigResponse.getFractionSplit();
        System.out.println("\t\tFraction Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", fractionSplitResponse.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", fractionSplitResponse.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", fractionSplitResponse.getTestFraction());
        FilterSplit filterSplit = inputDataConfigResponse.getFilterSplit();
        System.out.println("\t\tFilter Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", filterSplit.getTrainingFilter());
        System.out.format("\t\t\tValidation Fraction: %s\n", filterSplit.getValidationFilter());
        System.out.format("\t\t\tTest Fraction: %s\n", filterSplit.getTestFilter());
        PredefinedSplit predefinedSplit = inputDataConfigResponse.getPredefinedSplit();
        System.out.println("\t\tPredefined Split");
        System.out.format("\t\t\tKey: %s\n", predefinedSplit.getKey());
        TimestampSplit timestampSplit = inputDataConfigResponse.getTimestampSplit();
        System.out.println("\t\tTimestamp Split");
        System.out.format("\t\t\tTraining Fraction: %s\n", timestampSplit.getTrainingFraction());
        System.out.format("\t\t\tValidation Fraction: %s\n", timestampSplit.getValidationFraction());
        System.out.format("\t\t\tTest Fraction: %s\n", timestampSplit.getTestFraction());
        System.out.format("\t\t\tKey: %s\n", timestampSplit.getKey());
        Model modelResponse = trainingPipelineResponse.getModelToUpload();
        System.out.println("\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\tLables: %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) Transformation(com.google.cloud.aiplatform.v1.schema.trainingjob.definition.AutoMlTablesInputs.Transformation) AutoTransformation(com.google.cloud.aiplatform.v1.schema.trainingjob.definition.AutoMlTablesInputs.Transformation.AutoTransformation) TrainingPipeline(com.google.cloud.aiplatform.v1.TrainingPipeline) TimestampSplit(com.google.cloud.aiplatform.v1.TimestampSplit) Port(com.google.cloud.aiplatform.v1.Port) ArrayList(java.util.ArrayList) InputDataConfig(com.google.cloud.aiplatform.v1.InputDataConfig) LocationName(com.google.cloud.aiplatform.v1.LocationName) 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) AutoMlTablesInputs(com.google.cloud.aiplatform.v1.schema.trainingjob.definition.AutoMlTablesInputs) 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)

Aggregations

Model (com.google.cloud.aiplatform.v1.Model)6 ModelContainerSpec (com.google.cloud.aiplatform.v1.ModelContainerSpec)6 LocationName (com.google.cloud.aiplatform.v1.LocationName)5 PipelineServiceClient (com.google.cloud.aiplatform.v1.PipelineServiceClient)5 PipelineServiceSettings (com.google.cloud.aiplatform.v1.PipelineServiceSettings)5 TrainingPipeline (com.google.cloud.aiplatform.v1.TrainingPipeline)5 DeployedModelRef (com.google.cloud.aiplatform.v1.DeployedModelRef)4 EnvVar (com.google.cloud.aiplatform.v1.EnvVar)4 InputDataConfig (com.google.cloud.aiplatform.v1.InputDataConfig)4 Port (com.google.cloud.aiplatform.v1.Port)4 PredictSchemata (com.google.cloud.aiplatform.v1.PredictSchemata)4 FilterSplit (com.google.cloud.aiplatform.v1.FilterSplit)3 FractionSplit (com.google.cloud.aiplatform.v1.FractionSplit)3 PredefinedSplit (com.google.cloud.aiplatform.v1.PredefinedSplit)3 TimestampSplit (com.google.cloud.aiplatform.v1.TimestampSplit)3 Status (com.google.rpc.Status)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 ArrayList (java.util.ArrayList)2 ContainerSpec (com.google.cloud.aiplatform.v1.ContainerSpec)1