[ML][Inference] minor cleanup for inference (#50444) (#50676)

This commit is contained in:
Benjamin Trent 2020-01-06 14:05:04 -05:00 committed by GitHub
parent 1b28af489f
commit f52af7977d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 9 deletions

View File

@ -43,8 +43,8 @@ public final class InferenceToXContentCompressor {
}
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),

View File

@ -28,7 +28,6 @@ import org.elasticsearch.ingest.PipelineConfiguration;
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;
@ -151,12 +150,8 @@ public class InferenceProcessor extends AbstractProcessor {
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);
}