use of com.google.cloud.aiplatform.v1beta1.JobServiceClient 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());
}
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient 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");
}
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient 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");
}
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient in project java-talent by googleapis.
the class JobSearchCustomRankingSearch method sampleSearchJobs.
/**
* Search Jobs using custom rankings
*
* @param projectId Your Google Cloud Project ID
* @param tenantId Identifier of the Tenantd
*/
public static void sampleSearchJobs(String projectId, String tenantId) {
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
TenantOrProjectName parent = TenantName.of(projectId, tenantId);
String domain = "www.example.com";
String sessionId = "Hashed session identifier";
String userId = "Hashed user identifier";
RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
SearchJobsRequest.CustomRankingInfo.ImportanceLevel importanceLevel = SearchJobsRequest.CustomRankingInfo.ImportanceLevel.EXTREME;
String rankingExpression = "(someFieldLong + 25) * 0.25";
SearchJobsRequest.CustomRankingInfo customRankingInfo = SearchJobsRequest.CustomRankingInfo.newBuilder().setImportanceLevel(importanceLevel).setRankingExpression(rankingExpression).build();
String orderBy = "custom_ranking desc";
SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).setCustomRankingInfo(customRankingInfo).setOrderBy(orderBy).build();
for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
System.out.printf("Job summary: %s\n", responseItem.getJobSummary());
System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet());
Job job = responseItem.getJob();
System.out.printf("Job name: %s\n", job.getName());
System.out.printf("Job title: %s\n", job.getTitle());
}
} catch (Exception exception) {
System.err.println("Failed to create the client due to: " + exception);
}
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient in project java-talent by googleapis.
the class JobSearchHistogramSearch method sampleSearchJobs.
/**
* Search Jobs with histogram queries
*
* @param query Histogram query More info on histogram facets, constants, and built-in functions:
* https://godoc.org/google.golang.org/genproto/googleapis/cloud/talent/v4beta1#SearchJobsRequest
*/
public static void sampleSearchJobs(String projectId, String tenantId, String query) {
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
TenantOrProjectName parent = TenantName.of(projectId, tenantId);
String domain = "www.example.com";
String sessionId = "Hashed session identifier";
String userId = "Hashed user identifier";
RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
List<HistogramQuery> histogramQueries = Arrays.asList(histogramQueriesElement);
SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addAllHistogramQueries(histogramQueries).build();
for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
System.out.printf("Job summary: %s\n", responseItem.getJobSummary());
System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet());
Job job = responseItem.getJob();
System.out.printf("Job name: %s\n", job.getName());
System.out.printf("Job title: %s\n", job.getTitle());
}
} catch (Exception exception) {
System.err.println("Failed to create the client due to: " + exception);
}
}
Aggregations