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] PUT API #50852

Merged

Conversation

benwtrent
Copy link
Member

This adds the PUT API for creating trained models that support our format.

This includes

  • HLRC change for the API
  • API creation
  • Validations of model format and call

@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (:ml)

@benwtrent
Copy link
Member Author

run elasticsearch-ci/docs-check

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

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

I wonder if we should version the format of the actual model definition JSON in case we want to change it later. One for discussion not necessary for this change

}

/**
* Get trained model config asynchronously and notifies listener upon completion
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Get trained model config asynchronously and notifies listener upon completion
* Put trained model config asynchronously and notifiy listener upon completion

return deflate(reference);
}

public static <T> T inflate(String compressedString,
Copy link
Member

Choose a reason for hiding this comment

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

I think inflate isn't called anywhere apart from InferenceToXContentCompressorTests. If it goes SimpleBoundedInputStream could also be removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

@davidkyle possibly...but I was thinking of users requesting the compressed format from elasticsearch (for faster retrieval) and only inflating locally.

@@ -111,7 +112,7 @@ public static TrainedModelConfig fromXContent(XContentParser parser) throws IOEx
this.modelId = modelId;
this.createdBy = createdBy;
this.version = version;
this.createTime = Instant.ofEpochMilli(createTime.toEpochMilli());
this.createTime = createTime == null ? null : Instant.ofEpochMilli(createTime.toEpochMilli());
Copy link
Member

Choose a reason for hiding this comment

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

createTime can't be null on the server side class. Are we going to set createTime automatically on PUT if not set?

Copy link
Member

Choose a reason for hiding this comment

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

I scrolled down 👍

}
}

validationException = checkIllegalSetting(version, VERSION.getPreferredName(), validationException);
Copy link
Member

Choose a reason for hiding this comment

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

validate() can only be called once on PUT as the builder will set these fields so if called on a built config it will error. Maybe add a isCreateTime flag or similar.

PutJobAction has the same issue and does the validation of create time settings in the action

" \"version\": \"8.0.0\",\n" +
" \"license_level\": \"platinum\",\n" +
" \"created_by\": \"benwtrent\",\n" +
" \"created_by\": \"es_test\",\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
" \"created_by\": \"es_test\",\n" +
" \"created_by\": \"benwtrent\",\n" +

Take the glory dude

Copy link
Member Author

Choose a reason for hiding this comment

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

HAHAHA

TrainedModelConfig trainedModelConfig = new TrainedModelConfig.Builder(request.getTrainedModelConfig())
.setVersion(Version.CURRENT)
.setCreateTime(Instant.now())
.setCreatedBy("user")
Copy link
Member

Choose a reason for hiding this comment

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

I thought created by would be the users name (if security is enabled) but now I realise not. Maybe api rather than user. Or api_user. Our included models are createdBy: ml_admin

Copy link
Member Author

Choose a reason for hiding this comment

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

api_user seems good to me.

Yeah, I don't think we should include the actual user name for security reasons. It seems like a potential to leak info. Somebody could have permissions to read trained models, but not permission to see all configured users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be best to match what we did for system created annotations. Otherwise we’re just creating a plethora of imaginary users and eventually someone will ask why they’re all different.

Copy link
Member Author

Choose a reason for hiding this comment

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

@droberts195 for our internal created annotations, we use XPackUser.NAME which is _xpack. I am fine switching it to that in a subsequent PR.


@Override
public String getName() {
return "xpack_ml_put_data_frame_analytics_action";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return "xpack_ml_put_data_frame_analytics_action";
return "xpack_ml_put_trained_model_action";

@benwtrent benwtrent merged commit 4cecb7a into elastic:master Jan 11, 2020
@benwtrent benwtrent deleted the feature/ml-inference-add-put-model-action branch January 11, 2020 21:03
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request Jan 11, 2020
This adds the `PUT` API for creating trained models that support our format.

This includes

* HLRC change for the API
* API creation
* Validations of model format and call
benwtrent added a commit that referenced this pull request Jan 12, 2020
* [ML][Inference] PUT API (#50852)

This adds the `PUT` API for creating trained models that support our format.

This includes

* HLRC change for the API
* API creation
* Validations of model format and call

* fixing backport
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
This adds the `PUT` API for creating trained models that support our format. 

This includes

* HLRC change for the API
* API creation
* Validations of model format and call
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.

5 participants