From 1e5da99ac9f0b6d073b3dbd529f34c44c27f406b Mon Sep 17 00:00:00 2001 From: Xun Zhang Date: Thu, 16 Nov 2023 21:26:31 -0800 Subject: [PATCH] fix spotless and compile errors --- .../index/InteractionsIndexITTests.java | 88 +++++++++++++------ .../ml/plugin/MachineLearningPlugin.java | 2 +- .../RestMemorySearchConversationsAction.java | 2 +- .../RestMemorySearchInteractionsAction.java | 2 +- 4 files changed, 62 insertions(+), 32 deletions(-) diff --git a/memory/src/test/java/org/opensearch/ml/memory/index/InteractionsIndexITTests.java b/memory/src/test/java/org/opensearch/ml/memory/index/InteractionsIndexITTests.java index 36098578d2..21a17b4fe4 100644 --- a/memory/src/test/java/org/opensearch/ml/memory/index/InteractionsIndexITTests.java +++ b/memory/src/test/java/org/opensearch/ml/memory/index/InteractionsIndexITTests.java @@ -19,8 +19,8 @@ import java.time.Instant; import java.time.temporal.ChronoUnit; -import java.util.Collections; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -410,40 +410,70 @@ public void testSearchInteractions() { final String conversation2 = "conversation2"; CountDownLatch cdl = new CountDownLatch(1); StepListener iid1 = new StepListener<>(); - index.createInteraction(conversation1, "input about fish", "pt", "response about fish", "origin1", Collections.singletonMap("metadata", "some meta"), iid1); + index + .createInteraction( + conversation1, + "input about fish", + "pt", + "response about fish", + "origin1", + Collections.singletonMap("metadata", "some meta"), + iid1 + ); StepListener iid2 = new StepListener<>(); - iid1 - .whenComplete( - r -> { index.createInteraction(conversation1, "input about squash", "pt", "response about squash", "origin1", Collections.singletonMap("metadata", "some meta"), iid2); }, - e -> { - cdl.countDown(); - log.error(e); - assert (false); - } - ); + iid1.whenComplete(r -> { + index + .createInteraction( + conversation1, + "input about squash", + "pt", + "response about squash", + "origin1", + Collections.singletonMap("metadata", "some meta"), + iid2 + ); + }, e -> { + cdl.countDown(); + log.error(e); + assert (false); + }); StepListener iid3 = new StepListener<>(); - iid2 - .whenComplete( - r -> { index.createInteraction(conversation2, "input about fish", "pt2", "response about fish", "origin1", Collections.singletonMap("metadata", "some meta"), iid3); }, - e -> { - cdl.countDown(); - log.error(e); - assert (false); - } - ); + iid2.whenComplete(r -> { + index + .createInteraction( + conversation2, + "input about fish", + "pt2", + "response about fish", + "origin1", + Collections.singletonMap("metadata", "some meta"), + iid3 + ); + }, e -> { + cdl.countDown(); + log.error(e); + assert (false); + }); StepListener iid4 = new StepListener<>(); - iid3 - .whenComplete( - r -> { index.createInteraction(conversation1, "input about france", "pt", "response about france", "origin1", Collections.singletonMap("metadata", "some meta"), iid4); }, - e -> { - cdl.countDown(); - log.error(e); - assert (false); - } - ); + iid3.whenComplete(r -> { + index + .createInteraction( + conversation1, + "input about france", + "pt", + "response about france", + "origin1", + Collections.singletonMap("metadata", "some meta"), + iid4 + ); + }, e -> { + cdl.countDown(); + log.error(e); + assert (false); + }); StepListener searchListener = new StepListener<>(); iid4.whenComplete(r -> { diff --git a/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java b/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java index d74b299790..09590c003a 100644 --- a/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java +++ b/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java @@ -162,11 +162,11 @@ import org.opensearch.ml.memory.action.conversation.GetConversationsTransportAction; import org.opensearch.ml.memory.action.conversation.GetInteractionsAction; import org.opensearch.ml.memory.action.conversation.GetInteractionsTransportAction; -import org.opensearch.ml.memory.index.ConversationMetaIndex; import org.opensearch.ml.memory.action.conversation.SearchConversationsAction; import org.opensearch.ml.memory.action.conversation.SearchConversationsTransportAction; import org.opensearch.ml.memory.action.conversation.SearchInteractionsAction; import org.opensearch.ml.memory.action.conversation.SearchInteractionsTransportAction; +import org.opensearch.ml.memory.index.ConversationMetaIndex; import org.opensearch.ml.memory.index.OpenSearchConversationalMemoryHandler; import org.opensearch.ml.model.MLModelCacheHelper; import org.opensearch.ml.model.MLModelManager; diff --git a/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchConversationsAction.java b/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchConversationsAction.java index 5beee29c42..2546741528 100644 --- a/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchConversationsAction.java +++ b/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchConversationsAction.java @@ -22,7 +22,7 @@ import org.opensearch.ml.common.conversation.ConversationalIndexConstants; import org.opensearch.ml.memory.action.conversation.SearchConversationsAction; -import com.google.common.collect.ImmutableList; +import org.opensearch.ml.repackage.com.google.common.collect.ImmutableList; public class RestMemorySearchConversationsAction extends AbstractMLSearchAction { private static final String SEARCH_CONVERSATIONS_NAME = "conversation_memory_search_conversations"; diff --git a/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchInteractionsAction.java b/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchInteractionsAction.java index 063e2502ce..4901e12d63 100644 --- a/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchInteractionsAction.java +++ b/plugin/src/main/java/org/opensearch/ml/rest/RestMemorySearchInteractionsAction.java @@ -38,7 +38,7 @@ import org.opensearch.rest.action.RestResponseListener; import org.opensearch.search.builder.SearchSourceBuilder; -import com.google.common.collect.ImmutableList; +import org.opensearch.ml.repackage.com.google.common.collect.ImmutableList; public class RestMemorySearchInteractionsAction extends BaseRestHandler { private static final String SEARCH_INTERACTIONS_NAME = "conversation_memory_search_interactions";