Search in sources :

Example 21 with JobServiceSettings

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

the class CreateDataLabelingJobVideoSample method createDataLabelingJobVideo.

static void createDataLabelingJobVideo(String project, String displayName, String datasetId, String instructionUri, String annotationSpec) throws IOException {
    JobServiceSettings jobServiceSettings = JobServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create(jobServiceSettings)) {
        String location = "us-central1";
        LocationName locationName = LocationName.of(project, location);
        String jsonString = "{\"annotation_specs\": [ " + annotationSpec + "]}";
        Value.Builder annotationSpecValue = Value.newBuilder();
        JsonFormat.parser().merge(jsonString, annotationSpecValue);
        DatasetName datasetName = DatasetName.of(project, location, datasetId);
        DataLabelingJob dataLabelingJob = DataLabelingJob.newBuilder().setDisplayName(displayName).setLabelerCount(1).setInstructionUri(instructionUri).setInputsSchemaUri("gs://google-cloud-aiplatform/schema/datalabelingjob/inputs/" + "video_classification.yaml").addDatasets(datasetName.toString()).setInputs(annotationSpecValue).putAnnotationLabels("aiplatform.googleapis.com/annotation_set_name", "my_test_saved_query").build();
        DataLabelingJob dataLabelingJobResponse = jobServiceClient.createDataLabelingJob(locationName, dataLabelingJob);
        System.out.println("Create Data Labeling Job Video Response");
        System.out.format("\tName: %s\n", dataLabelingJobResponse.getName());
        System.out.format("\tDisplay Name: %s\n", dataLabelingJobResponse.getDisplayName());
        System.out.format("\tDatasets: %s\n", dataLabelingJobResponse.getDatasetsList());
        System.out.format("\tLabeler Count: %s\n", dataLabelingJobResponse.getLabelerCount());
        System.out.format("\tInstruction Uri: %s\n", dataLabelingJobResponse.getInstructionUri());
        System.out.format("\tInputs Schema Uri: %s\n", dataLabelingJobResponse.getInputsSchemaUri());
        System.out.format("\tInputs: %s\n", dataLabelingJobResponse.getInputs());
        System.out.format("\tState: %s\n", dataLabelingJobResponse.getState());
        System.out.format("\tLabeling Progress: %s\n", dataLabelingJobResponse.getLabelingProgress());
        System.out.format("\tCreate Time: %s\n", dataLabelingJobResponse.getCreateTime());
        System.out.format("\tUpdate Time: %s\n", dataLabelingJobResponse.getUpdateTime());
        System.out.format("\tLabels: %s\n", dataLabelingJobResponse.getLabelsMap());
        System.out.format("\tSpecialist Pools: %s\n", dataLabelingJobResponse.getSpecialistPoolsList());
        for (Map.Entry<String, String> annotationLabelMap : dataLabelingJobResponse.getAnnotationLabelsMap().entrySet()) {
            System.out.println("\tAnnotation Level");
            System.out.format("\t\tkey: %s\n", annotationLabelMap.getKey());
            System.out.format("\t\tvalue: %s\n", annotationLabelMap.getValue());
        }
        Money money = dataLabelingJobResponse.getCurrentSpend();
        System.out.println("\tCurrent Spend");
        System.out.format("\t\tCurrency Code: %s\n", money.getCurrencyCode());
        System.out.format("\t\tUnits: %s\n", money.getUnits());
        System.out.format("\t\tNanos: %s\n", money.getNanos());
    }
}
Also used : Money(com.google.type.Money) JobServiceSettings(com.google.cloud.aiplatform.v1.JobServiceSettings) DatasetName(com.google.cloud.aiplatform.v1.DatasetName) Value(com.google.protobuf.Value) JobServiceClient(com.google.cloud.aiplatform.v1.JobServiceClient) DataLabelingJob(com.google.cloud.aiplatform.v1.DataLabelingJob) Map(java.util.Map) LocationName(com.google.cloud.aiplatform.v1.LocationName)

Example 22 with JobServiceSettings

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

the class CancelBatchPredictionJobSample method cancelBatchPredictionJobSample.

static void cancelBatchPredictionJobSample(String project, String batchPredictionJobId) throws IOException {
    JobServiceSettings jobServiceSettings = JobServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create(jobServiceSettings)) {
        String location = "us-central1";
        BatchPredictionJobName batchPredictionJobName = BatchPredictionJobName.of(project, location, batchPredictionJobId);
        jobServiceClient.cancelBatchPredictionJob(batchPredictionJobName);
        System.out.println("Cancelled the Batch Prediction Job");
    }
}
Also used : JobServiceSettings(com.google.cloud.aiplatform.v1.JobServiceSettings) BatchPredictionJobName(com.google.cloud.aiplatform.v1.BatchPredictionJobName) JobServiceClient(com.google.cloud.aiplatform.v1.JobServiceClient)

Example 23 with JobServiceSettings

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

the class CancelDataLabelingJobSample method cancelDataLabelingJob.

static void cancelDataLabelingJob(String project, String dataLabelingJobId) throws IOException {
    JobServiceSettings jobServiceSettings = JobServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
    // the "close" method on the client to safely clean up any remaining background resources.
    try (JobServiceClient jobServiceClient = JobServiceClient.create(jobServiceSettings)) {
        String location = "us-central1";
        DataLabelingJobName dataLabelingJobName = DataLabelingJobName.of(project, location, dataLabelingJobId);
        jobServiceClient.cancelDataLabelingJob(dataLabelingJobName);
        System.out.println("Cancelled Data labeling job");
    }
}
Also used : JobServiceSettings(com.google.cloud.aiplatform.v1.JobServiceSettings) JobServiceClient(com.google.cloud.aiplatform.v1.JobServiceClient) DataLabelingJobName(com.google.cloud.aiplatform.v1.DataLabelingJobName)

Aggregations

JobServiceClient (com.google.cloud.aiplatform.v1.JobServiceClient)21 JobServiceSettings (com.google.cloud.aiplatform.v1.JobServiceSettings)21 LocationName (com.google.cloud.aiplatform.v1.LocationName)15 Value (com.google.protobuf.Value)10 BatchPredictionJob (com.google.cloud.aiplatform.v1.BatchPredictionJob)9 GcsDestination (com.google.cloud.aiplatform.v1.GcsDestination)8 GcsSource (com.google.cloud.aiplatform.v1.GcsSource)8 DataLabelingJob (com.google.cloud.aiplatform.v1.DataLabelingJob)5 MachineSpec (com.google.cloud.aiplatform.v1.MachineSpec)5 BigQueryDestination (com.google.cloud.aiplatform.v1.BigQueryDestination)4 BigQuerySource (com.google.cloud.aiplatform.v1.BigQuerySource)4 ApiException (com.google.api.gax.rpc.ApiException)3 BatchDedicatedResources (com.google.cloud.aiplatform.v1.BatchDedicatedResources)3 InputConfig (com.google.cloud.aiplatform.v1.BatchPredictionJob.InputConfig)3 OutputConfig (com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputConfig)3 OutputInfo (com.google.cloud.aiplatform.v1.BatchPredictionJob.OutputInfo)3 BatchPredictionJobName (com.google.cloud.aiplatform.v1.BatchPredictionJobName)3 CompletionStats (com.google.cloud.aiplatform.v1.CompletionStats)3 DatasetName (com.google.cloud.aiplatform.v1.DatasetName)3 HyperparameterTuningJob (com.google.cloud.aiplatform.v1.HyperparameterTuningJob)3