use of com.google.cloud.aiplatform.v1.UploadModelResponse in project java-aiplatform by googleapis.
the class UploadModelSample method uploadModel.
static void uploadModel(String project, String modelDisplayName, String metadataSchemaUri, String imageUri, String artifactUri) throws IOException, InterruptedException, ExecutionException, TimeoutException {
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";
LocationName locationName = LocationName.of(project, location);
ModelContainerSpec modelContainerSpec = ModelContainerSpec.newBuilder().setImageUri(imageUri).build();
Model model = Model.newBuilder().setDisplayName(modelDisplayName).setMetadataSchemaUri(metadataSchemaUri).setArtifactUri(artifactUri).setContainerSpec(modelContainerSpec).build();
OperationFuture<UploadModelResponse, UploadModelOperationMetadata> uploadModelResponseFuture = modelServiceClient.uploadModelAsync(locationName, model);
System.out.format("Operation name: %s\n", uploadModelResponseFuture.getInitialFuture().get().getName());
System.out.println("Waiting for operation to finish...");
UploadModelResponse uploadModelResponse = uploadModelResponseFuture.get(5, TimeUnit.MINUTES);
System.out.println("Upload Model Response");
System.out.format("Model: %s\n", uploadModelResponse.getModel());
}
}
Aggregations