Skip to content

Commit

Permalink
pre commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle committed Nov 22, 2023
1 parent a4b3cc3 commit dfdd495
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.inference.ModelConfigurations;
import org.elasticsearch.inference.TaskType;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
Expand Down Expand Up @@ -97,7 +96,7 @@ public void testMockServiceWithMultipleInputs() throws IOException {
List.of(randomAlphaOfLength(5), randomAlphaOfLength(10), randomAlphaOfLength(15))
);

var tokens = (List<Map<String, Object>>)inference.get("inference_results");
var tokens = (List<Map<String, Object>>) inference.get("inference_results");
assertThat(tokens, hasSize(3));
assertNonEmptyInferenceResults(inference, TaskType.SPARSE_EMBEDDING);
}
Expand Down Expand Up @@ -139,11 +138,11 @@ private Map<String, Object> inferOnMockService(String modelId, TaskType taskType
var request = new Request("POST", endpoint);

var bodyBuilder = new StringBuilder("{\"input\": [");
for (var in : input){
for (var in : input) {
bodyBuilder.append('"').append(in).append('"').append(',');
}
// remove last comma
bodyBuilder.deleteCharAt(bodyBuilder.length() -1);
bodyBuilder.deleteCharAt(bodyBuilder.length() - 1);
bodyBuilder.append("]}");

System.out.println("body_request:" + bodyBuilder);
Expand All @@ -156,10 +155,8 @@ private Map<String, Object> inferOnMockService(String modelId, TaskType taskType
@SuppressWarnings("unchecked")
protected void assertNonEmptyInferenceResults(Map<String, Object> resultMap, TaskType taskType) {
if (taskType == TaskType.SPARSE_EMBEDDING) {
var tokens = (List<Map<String, Object>>)resultMap.get("inference_results");
tokens.forEach(result -> {
assertThat(result.keySet(), not(empty()));
});
var tokens = (List<Map<String, Object>>) resultMap.get("inference_results");
tokens.forEach(result -> { assertThat(result.keySet(), not(empty())); });
} else {
fail("test with task type [" + taskType + "] are not supported yet");
}
Expand Down

0 comments on commit dfdd495

Please sign in to comment.