Skip to content

Commit

Permalink
[ML][Inference] minor cleanup for inference (elastic#50444)
Browse files Browse the repository at this point in the history
  • Loading branch information
benwtrent authored and SivagurunathanV committed Jan 21, 2020
1 parent c18fea3 commit 9f239d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static <T extends ToXContentObject> String deflate(T objectToCompress) th
}

static <T> T inflate(String compressedString,
CheckedFunction<XContentParser, T, IOException> parserFunction,
NamedXContentRegistry xContentRegistry) throws IOException {
CheckedFunction<XContentParser, T, IOException> parserFunction,
NamedXContentRegistry xContentRegistry) throws IOException {
try(XContentParser parser = XContentHelper.createParser(xContentRegistry,
LoggingDeprecationHandler.INSTANCE,
inflate(compressedString, MAX_INFLATED_BYTES),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.ingest.Processor;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.xpack.core.ml.action.InternalInferModelAction;
import org.elasticsearch.xpack.core.ml.inference.results.InferenceResults;
import org.elasticsearch.xpack.core.ml.inference.results.WarningInferenceResults;
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.ClassificationConfig;
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.InferenceConfig;
Expand Down Expand Up @@ -151,12 +150,8 @@ void mutateDocument(InternalInferModelAction.Response response, IngestDocument i
if (response.getInferenceResults().isEmpty()) {
throw new ElasticsearchStatusException("Unexpected empty inference response", RestStatus.INTERNAL_SERVER_ERROR);
}
InferenceResults inferenceResults = response.getInferenceResults().get(0);
if (inferenceResults instanceof WarningInferenceResults) {
inferenceResults.writeResult(ingestDocument, this.targetField);
} else {
response.getInferenceResults().get(0).writeResult(ingestDocument, this.targetField);
}
assert response.getInferenceResults().size() == 1;
response.getInferenceResults().get(0).writeResult(ingestDocument, this.targetField);
ingestDocument.setFieldValue(targetField + "." + MODEL_ID, modelId);
}

Expand Down

0 comments on commit 9f239d6

Please sign in to comment.