Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumping to OCI Java SDK 3.37.0 #360

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions Interop/OCI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,38 @@
<artifactId>commons-lang3</artifactId>
</exclusion>
<!-- tidy up other OCI Java SDK conflicts -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
<!-- pull in Jackson from OLCUT -->
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.oracle.oci.sdk</groupId>
<artifactId>oci-java-sdk-common-httpclient-jersey3</artifactId>
<version>${oci.sdk.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand All @@ -91,10 +123,9 @@
<artifactId>jakarta.activation-api</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</exclusion>
<!-- pull in Jackson from OLCUT -->
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
Expand Down Expand Up @@ -123,12 +154,12 @@
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.2</version>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.oracle.labs.olcut</groupId>
Expand Down
52 changes: 28 additions & 24 deletions Interop/OCI/src/main/java/org/tribuo/interop/oci/OCIModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
import com.oracle.labs.mlrg.olcut.provenance.primitives.FileProvenance;
import com.oracle.labs.mlrg.olcut.provenance.primitives.StringProvenance;
import com.oracle.labs.mlrg.olcut.util.Pair;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.Invocation;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.tribuo.Example;
import org.tribuo.ImmutableFeatureMap;
import org.tribuo.ImmutableOutputInfo;
Expand All @@ -50,13 +57,6 @@
import org.tribuo.provenance.ModelProvenance;
import org.tribuo.util.Util;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -245,24 +245,28 @@ protected DenseMatrix convertFeaturesList(List<SparseVector> list) {
protected DenseMatrix externalPrediction(DenseMatrix features) {
Invocation.Builder ib = modelEndpoint.request();
ib.accept(MediaType.APPLICATION_JSON);
Response response = ib.buildPost(Entity.entity(formatMatrix(features), MediaType.APPLICATION_JSON)).invoke();

String json;
try (BufferedReader reader = new BufferedReader(new InputStreamReader((InputStream) response.getEntity(), StandardCharsets.UTF_8))) {
StringBuilder jsonBody = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
jsonBody.append(line);
try (Response response = ib.buildPost(Entity.entity(formatMatrix(features), MediaType.APPLICATION_JSON)).invoke()) {
String json;
try (BufferedReader reader = new BufferedReader(
new InputStreamReader((InputStream) response.getEntity(),
StandardCharsets.UTF_8))) {
StringBuilder jsonBody = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
jsonBody.append(line);
}
json = jsonBody.toString();
} catch (IOException e) {
throw new IllegalStateException("Failed to read response from input stream", e);
}
try {
PredictionJson predJson = mapper.readValue(json, OCIModel.PredictionJson.class);
return DenseMatrix.createDenseMatrix(predJson.prediction);
} catch (JsonProcessingException e) {
throw new IllegalStateException(
"Failed to parse json from deployed model endpoint, received '" + json + "'",
e);
}
json = jsonBody.toString();
} catch (IOException e) {
throw new IllegalStateException("Failed to read response from input stream", e);
}
try {
PredictionJson predJson = mapper.readValue(json, OCIModel.PredictionJson.class);
return DenseMatrix.createDenseMatrix(predJson.prediction);
} catch (JsonProcessingException e) {
throw new IllegalStateException("Failed to parse json from deployed model endpoint, received '" + json + "'", e);
}
}

Expand Down
12 changes: 2 additions & 10 deletions Interop/OCI/src/main/java/org/tribuo/interop/oci/OCIModelCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
package org.tribuo.interop.oci;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.oracle.bmc.datascience.DataScienceClient;
import com.oracle.bmc.http.internal.ExplicitlySetFilter;
import com.oracle.labs.mlrg.olcut.config.ConfigurationManager;
import com.oracle.labs.mlrg.olcut.config.Option;
import com.oracle.labs.mlrg.olcut.config.Options;
Expand Down Expand Up @@ -100,11 +96,7 @@ private static void deploy(OCIModelOptions options) throws IOException {
DataScienceClient client = options.makeClient();

// Setup object mapper for writing to the terminal
ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
FilterProvider filters =
new SimpleFilterProvider()
.addFilter(ExplicitlySetFilter.NAME, ExplicitlySetFilter.INSTANCE);
mapper.setFilterProvider(filters);
ObjectMapper mapper = OCIUtil.createObjectMapper();

OCIUtil.OCIDSConfig dsConfig = new OCIUtil.OCIDSConfig(options.compartmentID,options.projectID);
OCIUtil.OCIModelDeploymentConfig config = new OCIUtil.OCIModelDeploymentConfig(dsConfig,options.modelId,options.modelDisplayName,options.instanceShape,options.bandwidth,options.instanceCount);
Expand Down Expand Up @@ -316,7 +308,7 @@ public String getOptionsDescription() {
* @throws IOException If the config file could not be read.
*/
DataScienceClient makeClient() throws IOException {
return new DataScienceClient(OCIModel.makeAuthProvider(ociConfigFile, ociConfigProfile));
return DataScienceClient.builder().build(OCIModel.makeAuthProvider(ociConfigFile, ociConfigProfile));
}

}
Expand Down
6 changes: 4 additions & 2 deletions Interop/OCI/src/main/java/org/tribuo/interop/oci/OCIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import com.oracle.bmc.datascience.requests.CreateModelDeploymentRequest;
import com.oracle.bmc.datascience.requests.CreateModelRequest;
import com.oracle.bmc.datascience.responses.CreateModelArtifactResponse;
import com.oracle.bmc.http.internal.ExplicitlySetFilter;
import com.oracle.bmc.serialization.jackson.internal.ExplicitlySetFilter;
import com.oracle.labs.mlrg.olcut.provenance.ProvenanceUtil;
import org.tribuo.Model;
import org.tribuo.Output;
Expand Down Expand Up @@ -61,6 +61,8 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;

import static com.oracle.bmc.http.client.internal.ExplicitlySetBmcModel.EXPLICITLY_SET_FILTER_NAME;

/**
* Utils for uploading and deploying models to OCI Data Science.
*/
Expand Down Expand Up @@ -323,7 +325,7 @@ public static ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
FilterProvider filters =
new SimpleFilterProvider()
.addFilter(ExplicitlySetFilter.NAME, ExplicitlySetFilter.INSTANCE);
.addFilter(EXPLICITLY_SET_FILTER_NAME, ExplicitlySetFilter.INSTANCE);
mapper.setFilterProvider(filters);

return mapper;
Expand Down
4 changes: 2 additions & 2 deletions THIRD_PARTY_LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1484,9 +1484,9 @@ of the input file used when generating it. This code is not
standalone and requires a support library to be linked with it. This
support library is itself covered by the above license.

oci-java-sdk 2.46.0 - Dual licensed UPL/Apache 2.0
oci-java-sdk 3.37.0 - Dual licensed UPL/Apache 2.0

Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.

This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl
or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<olcut.version>5.2.1</olcut.version>

<!-- Oracle dependencies -->
<oci.sdk.version>2.46.0</oci.sdk.version>
<oci.sdk.version>3.37.0</oci.sdk.version>

<!-- 3rd party backend dependencies -->
<liblinear.version>2.44</liblinear.version>
Expand All @@ -59,7 +59,7 @@
<junit.version>5.9.1</junit.version>
<opencsv.version>5.7.1</opencsv.version>
<protobuf.version>3.19.6</protobuf.version>
<jackson.version>2.14.1</jackson.version>
<jackson.version>2.14.3</jackson.version>

<!-- Other properties -->
<!-- Turn off tests which rely on native code -->
Expand Down