-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ML] Fix serialising the inference update request #122278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.inference.action; | ||
|
|
||
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.inference.TaskType; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
| import org.elasticsearch.xcontent.XContentType; | ||
| import org.elasticsearch.xpack.core.inference.action.UpdateInferenceModelAction; | ||
| import org.elasticsearch.xpack.inference.InferenceNamedWriteablesProvider; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class UpdateInferenceModelActionRequestTests extends AbstractWireSerializingTestCase<UpdateInferenceModelAction.Request> { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would we want to use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because there is on BWC logic on the transport version in the serialisation code the |
||
|
|
||
| @Override | ||
| protected Writeable.Reader<UpdateInferenceModelAction.Request> instanceReader() { | ||
| return UpdateInferenceModelAction.Request::new; | ||
| } | ||
|
|
||
| @Override | ||
| protected UpdateInferenceModelAction.Request createTestInstance() { | ||
| return new UpdateInferenceModelAction.Request( | ||
| randomAlphaOfLength(5), | ||
| randomBytesReference(50), | ||
| randomFrom(XContentType.values()), | ||
| randomFrom(TaskType.values()), | ||
| randomTimeValue() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| protected UpdateInferenceModelAction.Request mutateInstance(UpdateInferenceModelAction.Request instance) throws IOException { | ||
| return randomValueOtherThan(instance, this::createTestInstance); | ||
| } | ||
|
|
||
| @Override | ||
| protected NamedWriteableRegistry getNamedWriteableRegistry() { | ||
| return new NamedWriteableRegistry(InferenceNamedWriteablesProvider.getNamedWriteables()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| package org.elasticsearch.xpack.inference.action; | ||
|
|
||
| import org.elasticsearch.common.io.stream.NamedWriteableRegistry; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
| import org.elasticsearch.test.AbstractWireSerializingTestCase; | ||
| import org.elasticsearch.xpack.core.inference.action.UpdateInferenceModelAction; | ||
| import org.elasticsearch.xpack.inference.InferenceNamedWriteablesProvider; | ||
| import org.elasticsearch.xpack.inference.ModelConfigurationsTests; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class UpdateInferenceModelActionResponseTests extends AbstractWireSerializingTestCase<UpdateInferenceModelAction.Response> { | ||
| @Override | ||
| protected Writeable.Reader<UpdateInferenceModelAction.Response> instanceReader() { | ||
| return UpdateInferenceModelAction.Response::new; | ||
| } | ||
|
|
||
| @Override | ||
| protected UpdateInferenceModelAction.Response createTestInstance() { | ||
| return new UpdateInferenceModelAction.Response(ModelConfigurationsTests.createRandomInstance()); | ||
| } | ||
|
|
||
| @Override | ||
| protected UpdateInferenceModelAction.Response mutateInstance(UpdateInferenceModelAction.Response instance) throws IOException { | ||
| return randomValueOtherThan(instance, this::createTestInstance); | ||
| } | ||
|
|
||
| @Override | ||
| protected NamedWriteableRegistry getNamedWriteableRegistry() { | ||
| return new NamedWriteableRegistry(InferenceNamedWriteablesProvider.getNamedWriteables()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly the fix doesn't require a new transport version. This change means that reading from older nodes will start working and reads from same version and future versions will work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making sure I understand, we don't need a new transport version because it was incorrect to start? Will this have any expected impact on serverless?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The writeTo() code writes
taskTypethencontentand the read was readingcontentthentaskType.My intuition was that a fix would need a new transport version but when I wrote the code it ended up as:
Both sides of the condition are the same so I took out the transport version check, that suprised me as things are rarely this simple. As for serverless, what was once broken should start working.