Skip to content
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

Merged

Conversation

benwtrent
Copy link
Member

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.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core

import java.io.IOException;
import java.util.List;

public final class NamedXContentObjectHelper {
Copy link
Contributor

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.

Copy link
Member Author

@benwtrent benwtrent Sep 30, 2019

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 {
Copy link
Contributor

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?

r -> listener.onResponse(true),
e -> {
logger.error(
new ParameterizedMessage("[{}] failed to store trained model for inference", trainedModelConfig.getModelId()),
Copy link
Contributor

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?

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

Copy link
Member Author

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>

Copy link
Member Author

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.

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;
Copy link
Contributor

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";

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.

Copy link
Member Author

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.

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.

Copy link
Contributor

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.

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()),

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

Copy link
Contributor

@przemekwitek przemekwitek left a 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;
Copy link
Contributor

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?

Copy link

@hendrikmuhs hendrikmuhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benwtrent
Copy link
Member Author

run elasticsearch-ci/2

Copy link
Contributor

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benwtrent benwtrent merged commit f6f2c9f into elastic:master Sep 30, 2019
@benwtrent benwtrent deleted the feature/ml-inference-adding-inference-index branch September 30, 2019 16:26
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request Sep 30, 2019
* [ML][Inference] adding .ml-inference* index and storage

* Addressing PR comments

* Allowing null definition, adding validation tests for model config

* fixing line length
benwtrent added a commit that referenced this pull request Oct 1, 2019
#47310)

* [ML][Inference] adding .ml-inference* index and storage (#47267)

* [ML][Inference] adding .ml-inference* index and storage

* Addressing PR comments

* Allowing null definition, adding validation tests for model config

* fixing line length

* adjusting for backport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants