-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
[ML][Inference] adding .ml-inference* index and storage #47267
[ML][Inference] adding .ml-inference* index and storage #47267
Conversation
Pinging @elastic/ml-core |
...igh-level/src/main/java/org/elasticsearch/client/ml/inference/NamedXContentObjectHelper.java
Show resolved
Hide resolved
...ugin/core/src/main/java/org/elasticsearch/xpack/core/ml/utils/NamedXContentObjectHelper.java
Show resolved
Hide resolved
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public final class NamedXContentObjectHelper { |
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.
Just to make sure: to what extent do we want to decouple server code from client code?
It feels to me that a utility class like this one could be placed in some "common" package visible by both server and client.
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.
Potentially, but I am not convinced it belongs in the root server code. It is something only used by this plugin.
NOTE: I think for this to be able to be used by the client + xpack.core, it would need to be put in the common ES Server code. That does not seem justified to me
@@ -45,4 +46,13 @@ public static Date parseTimeField(XContentParser parser, String fieldName) throw | |||
"unexpected token [" + parser.currentToken() + "] for [" + fieldName + "]"); | |||
} | |||
|
|||
public static Instant parseTimeFieldToInstant(XContentParser parser, String fieldName) throws IOException { |
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.
Could org.elasticsearch.client.transform.transforms.util.TimeUtil
class be moved to org.elasticsearch.client.common
and reused here?
.../rest-high-level/src/main/java/org/elasticsearch/client/ml/inference/TrainedModelConfig.java
Outdated
Show resolved
Hide resolved
.../plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/TrainedModelConfig.java
Outdated
Show resolved
Hide resolved
...main/java/org/elasticsearch/xpack/core/ml/inference/persistence/InferenceIndexConstants.java
Outdated
Show resolved
Hide resolved
...l/src/main/java/org/elasticsearch/xpack/ml/inference/persistence/InferenceInternalIndex.java
Show resolved
Hide resolved
r -> listener.onResponse(true), | ||
e -> { | ||
logger.error( | ||
new ParameterizedMessage("[{}] failed to store trained model for inference", trainedModelConfig.getModelId()), |
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.
We use Messages.INFERENCE_FAILED_TO_STORE_MODE
in line 80. Should it be used here as well?
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.
seems to me it should be moved into the if-clause and log corresponding messages
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.
I consider the two messages to be different. I think potentially user facing errors should be sentences (or close to it). Logged messages should follow the prevailing format of [<RESOURCE_ID>] <MESSAGE>
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.
I updated the message to include the model version. But again, for logging, it is much easier to grep and visually parse logs if the resource ID is right at the front. This is the prevailing pattern in our ML plugin and the Transform Plugin.
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.
(nit) should not have piggy backed my comment: For me it would be clearer if logging corresponds to the listener.onFailure
calls, so we have 2 different log messages for the 2 failure cases.
|
||
public class TrainedModelProviderIT extends MlSingleNodeTestCase { | ||
|
||
TrainedModelProvider trainedModelProvider; |
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.
private
*/ | ||
public final class InferenceIndexConstants { | ||
|
||
public static final String INDEX_VERSION = "000001"; |
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.
this looks like a rollover pattern, I think version should be non-fixed size digits (-> single digit in this case) and the rollover pattern should be an additional suffix if rollover is wanted.
Are you planning to use rollover for this in future to delete old models? It seems that configs and models are stored in this index, that would rule out rollover.
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.
@hendrikmuhs This is for index versioning. Simply using 1
won't 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.
you mean because of sorting on retrieval and there limitations? ok, 1 digit limits to 9 versions. But almost 1 million versions seems a little bit to much.
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.
I think a single extension for both potential future rollover and mappings version is OK. The rollover API is designed with periodic changes to index templates in mind. And then since rollover uses six digits it's best to use six digits. If we use fewer and then decide to do rollover then it forces us to have two suffices.
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.
for support reasons I would prefer 2 suffixes, but you have a point.
It's a good hint, I am currently using 1 digit in transforms, which limits versioning to 9 versions. I will upgrade to use more digits, 6 sounds still to much as I rule out rollover for this index.
r -> listener.onResponse(true), | ||
e -> { | ||
logger.error( | ||
new ParameterizedMessage("[{}] failed to store trained model for inference", trainedModelConfig.getModelId()), |
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.
seems to me it should be moved into the if-clause and log corresponding messages
.../ml/src/main/java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelProvider.java
Outdated
Show resolved
Hide resolved
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.
LGTM
|
||
static class NamedTestObject implements NamedXContentObject { | ||
|
||
private String fieldValue; |
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.
nit: Could you move the member variable down, right before constructor?
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.
LGTM
run elasticsearch-ci/2 |
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.
LGTM
* [ML][Inference] adding .ml-inference* index and storage * Addressing PR comments * Allowing null definition, adding validation tests for model config * fixing line length
Adds a new
.ml-inference
index, a trained model configuration document object, and methods to put/get a document from the index.I opted for versioning the indices similar to how we do with Transforms. This is partially blocked by #47241, so, opening as WIP until that PR is merged.