From 5bf36ed78152ca6b0e2fab49904dc58404a295d9 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Thu, 7 Sep 2023 16:49:53 -0700 Subject: [PATCH] Fixed compilation errors after recent changes in ml-commons (#285) * Fixed compilation errors after recent changes in ml-commons Signed-off-by: Martin Gaievski --- .../neuralsearch/common/BaseNeuralSearchIT.java | 8 ++++---- .../neuralsearch/ml/MLCommonsClientAccessorTests.java | 5 ++++- .../resources/processor/CreateModelGroupRequestBody.json | 5 ++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java index fdf2459df..b144ade6c 100644 --- a/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java +++ b/src/test/java/org/opensearch/neuralsearch/common/BaseNeuralSearchIT.java @@ -8,7 +8,6 @@ import static org.opensearch.neuralsearch.common.VectorUtil.vectorAsListToArray; import java.io.IOException; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Collections; @@ -50,6 +49,7 @@ import org.opensearch.knn.index.SpaceType; import org.opensearch.neuralsearch.OpenSearchSecureRestTestCase; +import com.carrotsearch.randomizedtesting.RandomizedTest; import com.google.common.collect.ImmutableList; public abstract class BaseNeuralSearchIT extends OpenSearchSecureRestTestCase { @@ -137,7 +137,7 @@ protected void loadModel(String modelId) throws Exception { Response uploadResponse = makeRequest( client(), "POST", - String.format(LOCALE, "/_plugins/_ml/models/%s/_load", modelId), + String.format(LOCALE, "/_plugins/_ml/models/%s/_deploy", modelId), null, toHttpEntity(""), ImmutableList.of(new BasicHeader(HttpHeaders.USER_AGENT, DEFAULT_USER_AGENT)) @@ -685,10 +685,10 @@ protected String getDeployedModelId() { } @SneakyThrows - private String registerModelGroup() throws IOException, URISyntaxException { + private String registerModelGroup() { String modelGroupRegisterRequestBody = Files.readString( Path.of(classLoader.getResource("processor/CreateModelGroupRequestBody.json").toURI()) - ); + ).replace("", "public_model_" + RandomizedTest.randomAsciiAlphanumOfLength(8)); Response modelGroupResponse = makeRequest( client(), "POST", diff --git a/src/test/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessorTests.java b/src/test/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessorTests.java index 350394250..3ef5431b3 100644 --- a/src/test/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessorTests.java +++ b/src/test/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessorTests.java @@ -13,6 +13,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import org.junit.Before; import org.mockito.InjectMocks; @@ -168,7 +169,9 @@ private ModelTensorOutput createModelTensorOutput(final Float[] output) { output, new long[] { 1, 2 }, MLResultDataType.FLOAT64, - ByteBuffer.wrap(new byte[12]) + ByteBuffer.wrap(new byte[12]), + "someValue", + Map.of() ); mlModelTensorList.add(tensor); final ModelTensors modelTensors = new ModelTensors(mlModelTensorList); diff --git a/src/test/resources/processor/CreateModelGroupRequestBody.json b/src/test/resources/processor/CreateModelGroupRequestBody.json index d6d398c76..91f68e222 100644 --- a/src/test/resources/processor/CreateModelGroupRequestBody.json +++ b/src/test/resources/processor/CreateModelGroupRequestBody.json @@ -1,5 +1,4 @@ { - "name": "test_model_group_public", - "description": "This is a public model group", - "access_mode": "public" + "name": "", + "description": "This is a public model group" } \ No newline at end of file