use of com.google.cloud.aiplatform.v1beta1.JobServiceClient in project java-talent by googleapis.
the class JobSearchDeleteJob method sampleDeleteJob.
/**
* Delete Job
*/
public static void sampleDeleteJob(String projectId, String tenantId, String jobId) {
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
JobName name = JobWithTenantName.of(projectId, tenantId, jobId);
DeleteJobRequest request = DeleteJobRequest.newBuilder().setName(name.toString()).build();
jobServiceClient.deleteJob(request);
System.out.println("Deleted job.");
} 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 JobSearchGetJob method sampleGetJob.
/**
* Get Job
*/
public static void sampleGetJob(String projectId, String tenantId, String jobId) {
try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
JobName name = JobWithTenantName.of(projectId, tenantId, jobId);
GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
Job response = jobServiceClient.getJob(request);
System.out.printf("Job name: %s\n", response.getName());
System.out.printf("Requisition ID: %s\n", response.getRequisitionId());
System.out.printf("Title: %s\n", response.getTitle());
System.out.printf("Description: %s\n", response.getDescription());
System.out.printf("Posting language: %s\n", response.getLanguageCode());
for (String address : response.getAddressesList()) {
System.out.printf("Address: %s\n", address);
}
for (String email : response.getApplicationInfo().getEmailsList()) {
System.out.printf("Email: %s\n", email);
}
for (String websiteUri : response.getApplicationInfo().getUrisList()) {
System.out.printf("Website: %s\n", websiteUri);
}
} 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-aiplatform by googleapis.
the class GetBatchPredictionJobSample method getBatchPredictionJobSample.
static void getBatchPredictionJobSample(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);
BatchPredictionJob batchPredictionJob = jobServiceClient.getBatchPredictionJob(batchPredictionJobName);
System.out.println("Get Batch Prediction Job Response");
System.out.format("\tName: %s\n", batchPredictionJob.getName());
System.out.format("\tDisplay Name: %s\n", batchPredictionJob.getDisplayName());
System.out.format("\tModel: %s\n", batchPredictionJob.getModel());
System.out.format("\tModel Parameters: %s\n", batchPredictionJob.getModelParameters());
System.out.format("\tState: %s\n", batchPredictionJob.getState());
System.out.format("\tCreate Time: %s\n", batchPredictionJob.getCreateTime());
System.out.format("\tStart Time: %s\n", batchPredictionJob.getStartTime());
System.out.format("\tEnd Time: %s\n", batchPredictionJob.getEndTime());
System.out.format("\tUpdate Time: %s\n", batchPredictionJob.getUpdateTime());
System.out.format("\tLabels: %s\n", batchPredictionJob.getLabelsMap());
InputConfig inputConfig = batchPredictionJob.getInputConfig();
System.out.println("\tInput Config");
System.out.format("\t\tInstances Format: %s\n", inputConfig.getInstancesFormat());
GcsSource gcsSource = inputConfig.getGcsSource();
System.out.println("\t\tGcs Source");
System.out.format("\t\t\tUris: %s\n", gcsSource.getUrisList());
BigQuerySource bigquerySource = inputConfig.getBigquerySource();
System.out.println("\t\tBigquery Source");
System.out.format("\t\t\tInput Uri: %s\n", bigquerySource.getInputUri());
OutputConfig outputConfig = batchPredictionJob.getOutputConfig();
System.out.println("\tOutput Config");
System.out.format("\t\tPredictions Format: %s\n", outputConfig.getPredictionsFormat());
GcsDestination gcsDestination = outputConfig.getGcsDestination();
System.out.println("\t\tGcs Destination");
System.out.format("\t\t\tOutput Uri Prefix: %s\n", gcsDestination.getOutputUriPrefix());
BigQueryDestination bigqueryDestination = outputConfig.getBigqueryDestination();
System.out.println("\t\tBigquery Destination");
System.out.format("\t\t\tOutput Uri: %s\n", bigqueryDestination.getOutputUri());
OutputInfo outputInfo = batchPredictionJob.getOutputInfo();
System.out.println("\tOutput Info");
System.out.format("\t\tGcs Output Directory: %s\n", outputInfo.getGcsOutputDirectory());
System.out.format("\t\tBigquery Output Dataset: %s\n", outputInfo.getBigqueryOutputDataset());
Status status = batchPredictionJob.getError();
System.out.println("\tError");
System.out.format("\t\tCode: %s\n", status.getCode());
System.out.format("\t\tMessage: %s\n", status.getMessage());
List<Any> detailsList = status.getDetailsList();
for (Status partialFailure : batchPredictionJob.getPartialFailuresList()) {
System.out.println("\tPartial Failure");
System.out.format("\t\tCode: %s\n", partialFailure.getCode());
System.out.format("\t\tMessage: %s\n", partialFailure.getMessage());
List<Any> details = partialFailure.getDetailsList();
}
ResourcesConsumed resourcesConsumed = batchPredictionJob.getResourcesConsumed();
System.out.println("\tResources Consumed");
System.out.format("\t\tReplica Hours: %s\n", resourcesConsumed.getReplicaHours());
CompletionStats completionStats = batchPredictionJob.getCompletionStats();
System.out.println("\tCompletion Stats");
System.out.format("\t\tSuccessful Count: %s\n", completionStats.getSuccessfulCount());
System.out.format("\t\tFailed Count: %s\n", completionStats.getFailedCount());
System.out.format("\t\tIncomplete Count: %s\n", completionStats.getIncompleteCount());
}
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient in project java-aiplatform by googleapis.
the class GetHyperparameterTuningJobSample method getHyperparameterTuningJobSample.
static void getHyperparameterTuningJobSample(String project, String hyperparameterTuningJobId) 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)) {
HyperparameterTuningJobName name = HyperparameterTuningJobName.of(project, location, hyperparameterTuningJobId);
HyperparameterTuningJob response = client.getHyperparameterTuningJob(name);
System.out.format("response: %s\n", response);
}
}
use of com.google.cloud.aiplatform.v1beta1.JobServiceClient in project java-aiplatform by googleapis.
the class CreateHyperparameterTuningJobSampleTest method tearDown.
@After
public void tearDown() throws InterruptedException, ExecutionException, IOException, TimeoutException {
JobServiceSettings settings = JobServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
try (JobServiceClient client = JobServiceClient.create(settings)) {
// Cancel hyper parameter job
String hyperparameterJobName = String.format("projects/%s/locations/us-central1/hyperparameterTuningJobs/%s", PROJECT, hyperparameterJobId);
client.cancelHyperparameterTuningJob(hyperparameterJobName);
TimeUnit.MINUTES.sleep(1);
// Delete the created job
client.deleteHyperparameterTuningJobAsync(hyperparameterJobName);
System.out.flush();
System.setOut(originalPrintStream);
}
}
Aggregations