[7.x] [ML] renames */inference* apis to */trained_models* (#63097) (#63136)

* [ML] renames */inference* apis to */trained_models* (#63097)

This commit renames all `inference` CRUD APIs to `trained_models`.

This aligns with internal terminology, documentation, and use-cases.
This commit is contained in:
Benjamin Trent 2020-10-02 07:34:28 -04:00 committed by GitHub
parent 535f8a434b
commit cfcf973259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 215 additions and 159 deletions

View File

@ -758,7 +758,7 @@ final class MLRequestConverters {
static Request getTrainedModels(GetTrainedModelsRequest getTrainedModelsRequest) {
String endpoint = new EndpointBuilder()
.addPathPartAsIs("_ml", "inference")
.addPathPartAsIs("_ml", "trained_models")
.addPathPart(Strings.collectionToCommaDelimitedString(getTrainedModelsRequest.getIds()))
.build();
RequestConverters.Params params = new RequestConverters.Params();
@ -796,7 +796,7 @@ final class MLRequestConverters {
static Request getTrainedModelsStats(GetTrainedModelsStatsRequest getTrainedModelsStatsRequest) {
String endpoint = new EndpointBuilder()
.addPathPartAsIs("_ml", "inference")
.addPathPartAsIs("_ml", "trained_models")
.addPathPart(Strings.collectionToCommaDelimitedString(getTrainedModelsStatsRequest.getIds()))
.addPathPart("_stats")
.build();
@ -821,7 +821,7 @@ final class MLRequestConverters {
static Request deleteTrainedModel(DeleteTrainedModelRequest deleteRequest) {
String endpoint = new EndpointBuilder()
.addPathPartAsIs("_ml", "inference")
.addPathPartAsIs("_ml", "trained_models")
.addPathPart(deleteRequest.getId())
.build();
return new Request(HttpDelete.METHOD_NAME, endpoint);
@ -829,7 +829,7 @@ final class MLRequestConverters {
static Request putTrainedModel(PutTrainedModelRequest putTrainedModelRequest) throws IOException {
String endpoint = new EndpointBuilder()
.addPathPartAsIs("_ml", "inference")
.addPathPartAsIs("_ml", "trained_models")
.addPathPart(putTrainedModelRequest.getTrainedModelConfig().getModelId())
.build();
Request request = new Request(HttpPut.METHOD_NAME, endpoint);

View File

@ -2395,7 +2395,7 @@ public final class MachineLearningClient {
* Gets trained model configs
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference.html">
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html">
* GET Trained Model Configs documentation</a>
*
* @param request The {@link GetTrainedModelsRequest}
@ -2415,7 +2415,7 @@ public final class MachineLearningClient {
* Gets trained model configs asynchronously and notifies listener upon completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference.html">
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html">
* GET Trained Model Configs documentation</a>
*
* @param request The {@link GetTrainedModelsRequest}
@ -2480,7 +2480,7 @@ public final class MachineLearningClient {
* Gets trained model stats
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-stats.html">
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html">
* GET Trained Model Stats documentation</a>
*
* @param request The {@link GetTrainedModelsStatsRequest}
@ -2500,7 +2500,7 @@ public final class MachineLearningClient {
* Gets trained model stats asynchronously and notifies listener upon completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-stats.html">
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html">
* GET Trained Model Stats documentation</a>
*
* @param request The {@link GetTrainedModelsStatsRequest}
@ -2523,7 +2523,7 @@ public final class MachineLearningClient {
* Deletes the given Trained Model
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html">
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html">
* DELETE Trained Model documentation</a>
*
* @param request The {@link DeleteTrainedModelRequest}
@ -2543,7 +2543,7 @@ public final class MachineLearningClient {
* Deletes the given Trained Model asynchronously and notifies listener upon completion
* <p>
* For additional info
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html">
* see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html">
* DELETE Trained Model documentation</a>
*
* @param request The {@link DeleteTrainedModelRequest}

View File

@ -900,7 +900,7 @@ public class MLRequestConvertersTests extends ESTestCase {
Request request = MLRequestConverters.getTrainedModels(getRequest);
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
assertEquals("/_ml/inference/" + modelId1 + "," + modelId2 + "," + modelId3, request.getEndpoint());
assertEquals("/_ml/trained_models/" + modelId1 + "," + modelId2 + "," + modelId3, request.getEndpoint());
assertThat(request.getParameters(),
allOf(
hasEntry("from", "100"),
@ -923,7 +923,7 @@ public class MLRequestConvertersTests extends ESTestCase {
Request request = MLRequestConverters.getTrainedModelsStats(getRequest);
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
assertEquals("/_ml/inference/" + modelId1 + "," + modelId2 + "," + modelId3 + "/_stats", request.getEndpoint());
assertEquals("/_ml/trained_models/" + modelId1 + "," + modelId2 + "," + modelId3 + "/_stats", request.getEndpoint());
assertThat(request.getParameters(),
allOf(
hasEntry("from", "100"),
@ -937,7 +937,7 @@ public class MLRequestConvertersTests extends ESTestCase {
DeleteTrainedModelRequest deleteRequest = new DeleteTrainedModelRequest(randomAlphaOfLength(10));
Request request = MLRequestConverters.deleteTrainedModel(deleteRequest);
assertEquals(HttpDelete.METHOD_NAME, request.getMethod());
assertEquals("/_ml/inference/" + deleteRequest.getId(), request.getEndpoint());
assertEquals("/_ml/trained_models/" + deleteRequest.getId(), request.getEndpoint());
assertNull(request.getEntity());
}
@ -948,7 +948,7 @@ public class MLRequestConvertersTests extends ESTestCase {
Request request = MLRequestConverters.putTrainedModel(putTrainedModelRequest);
assertEquals(HttpPut.METHOD_NAME, request.getMethod());
assertThat(request.getEndpoint(), equalTo("/_ml/inference/" + trainedModelConfig.getModelId()));
assertThat(request.getEndpoint(), equalTo("/_ml/trained_models/" + trainedModelConfig.getModelId()));
try (XContentParser parser = createParser(JsonXContent.jsonXContent, request.getEntity().getContent())) {
TrainedModelConfig parsedTrainedModelConfig = TrainedModelConfig.PARSER.apply(parser, null).build();
assertThat(parsedTrainedModelConfig, equalTo(trainedModelConfig));

View File

@ -2455,7 +2455,7 @@ public class MachineLearningIT extends ESRestHighLevelClientTestCase {
public void testDeleteTrainedModel() throws Exception {
MachineLearningClient machineLearningClient = highLevelClient().machineLearning();
String modelId = "delete-trained-model-test";
String modelId = "delete-trained-models-test";
putTrainedModel(modelId);
GetTrainedModelsResponse getTrainedModelsResponse = execute(

View File

@ -3901,17 +3901,17 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase {
RestHighLevelClient client = highLevelClient();
{
putTrainedModel("my-trained-model");
// tag::delete-trained-model-request
// tag::delete-trained-models-request
DeleteTrainedModelRequest request = new DeleteTrainedModelRequest("my-trained-model"); // <1>
// end::delete-trained-model-request
// end::delete-trained-models-request
// tag::delete-trained-model-execute
// tag::delete-trained-models-execute
AcknowledgedResponse response = client.machineLearning().deleteTrainedModel(request, RequestOptions.DEFAULT);
// end::delete-trained-model-execute
// end::delete-trained-models-execute
// tag::delete-trained-model-response
// tag::delete-trained-models-response
boolean deleted = response.isAcknowledged();
// end::delete-trained-model-response
// end::delete-trained-models-response
assertThat(deleted, is(true));
}
@ -3919,7 +3919,7 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase {
putTrainedModel("my-trained-model");
DeleteTrainedModelRequest request = new DeleteTrainedModelRequest("my-trained-model");
// tag::delete-trained-model-execute-listener
// tag::delete-trained-models-execute-listener
ActionListener<AcknowledgedResponse> listener = new ActionListener<AcknowledgedResponse>() {
@Override
public void onResponse(AcknowledgedResponse response) {
@ -3931,15 +3931,15 @@ public class MlClientDocumentationIT extends ESRestHighLevelClientTestCase {
// <2>
}
};
// end::delete-trained-model-execute-listener
// end::delete-trained-models-execute-listener
// Replace the empty listener by a blocking listener in test
CountDownLatch latch = new CountDownLatch(1);
listener = new LatchedActionListener<>(listener, latch);
// tag::delete-trained-model-execute-async
// tag::delete-trained-models-execute-async
client.machineLearning().deleteTrainedModelAsync(request, RequestOptions.DEFAULT, listener); // <1>
// end::delete-trained-model-execute-async
// end::delete-trained-models-execute-async
assertTrue(latch.await(30L, TimeUnit.SECONDS));
}

View File

@ -1,5 +1,5 @@
--
:api: delete-trained-model
:api: delete-trained-models
:request: DeleteTrainedModelRequest
:response: AcknowledgedResponse
--

View File

@ -333,7 +333,7 @@ The Java High Level REST Client supports the following Machine Learning APIs:
* <<{upid}-get-trained-models>>
* <<{upid}-put-trained-model>>
* <<{upid}-get-trained-models-stats>>
* <<{upid}-delete-trained-model>>
* <<{upid}-delete-trained-models>>
* <<{upid}-put-filter>>
* <<{upid}-get-filters>>
* <<{upid}-update-filter>>
@ -391,7 +391,7 @@ include::ml/explain-data-frame-analytics.asciidoc[]
include::ml/get-trained-models.asciidoc[]
include::ml/put-trained-model.asciidoc[]
include::ml/get-trained-models-stats.asciidoc[]
include::ml/delete-trained-model.asciidoc[]
include::ml/delete-trained-models.asciidoc[]
include::ml/put-filter.asciidoc[]
include::ml/get-filters.asciidoc[]
include::ml/update-filter.asciidoc[]

View File

@ -9,7 +9,7 @@ A parent pipeline aggregation which loads a pre-trained model and performs
{infer} on the collated result fields from the parent bucket aggregation.
To use the {infer} bucket aggregation, you need to have the same security
privileges that are required for using the <<get-inference>>.
privileges that are required for using the <<get-trained-models>>.
[[inference-bucket-agg-syntax]]
==== Syntax

View File

@ -1,6 +1,6 @@
[role="xpack"]
[testenv="basic"]
[[delete-inference]]
[[delete-trained-models]]
= Delete trained model API
[subs="attributes"]
++++
@ -13,13 +13,13 @@ ingest pipeline.
experimental[]
[[ml-delete-inference-request]]
[[ml-delete-trained-models-request]]
== {api-request-title}
`DELETE _ml/inference/<model_id>`
`DELETE _ml/trained_models/<model_id>`
[[ml-delete-inference-prereq]]
[[ml-delete-trained-models-prereq]]
== {api-prereq-title}
If the {es} {security-features} are enabled, you must have the following built-in roles or equivalent privileges:
@ -29,7 +29,7 @@ If the {es} {security-features} are enabled, you must have the following built-i
For more information, see <<built-in-roles>> and {ml-docs-setup-privileges}.
[[ml-delete-inference-path-params]]
[[ml-delete-trained-models-path-params]]
== {api-path-parms-title}
`<model_id>`::
@ -37,7 +37,7 @@ For more information, see <<built-in-roles>> and {ml-docs-setup-privileges}.
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
[[ml-delete-inference-response-codes]]
[[ml-delete-trained-models-response-codes]]
== {api-response-codes-title}
`409`::
@ -45,7 +45,7 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
and cannot be deleted.
[[ml-delete-inference-example]]
[[ml-delete-trained-models-example]]
== {api-examples-title}
The following example deletes the `regression-job-one-1574775307356` trained
@ -53,7 +53,7 @@ model:
[source,console]
--------------------------------------------------
DELETE _ml/inference/regression-job-one-1574775307356
DELETE _ml/trained_models/regression-job-one-1574775307356
--------------------------------------------------
// TEST[skip:TBD]

View File

@ -1,6 +1,6 @@
[role="xpack"]
[testenv="basic"]
[[get-inference-stats]]
[[get-trained-models-stats]]
= Get trained model statistics API
[subs="attributes"]
++++
@ -12,21 +12,21 @@ Retrieves usage information for trained models.
experimental[]
[[ml-get-inference-stats-request]]
[[ml-get-trained-models-stats-request]]
== {api-request-title}
`GET _ml/inference/_stats` +
`GET _ml/trained_models/_stats` +
`GET _ml/inference/_all/_stats` +
`GET _ml/trained_models/_all/_stats` +
`GET _ml/inference/<model_id>/_stats` +
`GET _ml/trained_models/<model_id>/_stats` +
`GET _ml/inference/<model_id>,<model_id_2>/_stats` +
`GET _ml/trained_models/<model_id>,<model_id_2>/_stats` +
`GET _ml/inference/<model_id_pattern*>,<model_id_2>/_stats`
`GET _ml/trained_models/<model_id_pattern*>,<model_id_2>/_stats`
[[ml-get-inference-stats-prereq]]
[[ml-get-trained-models-stats-prereq]]
== {api-prereq-title}
Required privileges which should be added to a custom role:
@ -35,14 +35,14 @@ Required privileges which should be added to a custom role:
For more information, see <<security-privileges>> and {ml-docs-setup-privileges}.
[[ml-get-inference-stats-desc]]
[[ml-get-trained-models-stats-desc]]
== {api-description-title}
You can get usage information for multiple trained models in a single API
request by using a comma-separated list of model IDs or a wildcard expression.
[[ml-get-inference-stats-path-params]]
[[ml-get-trained-models-stats-path-params]]
== {api-path-parms-title}
`<model_id>`::
@ -50,7 +50,7 @@ request by using a comma-separated list of model IDs or a wildcard expression.
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
[[ml-get-inference-stats-query-params]]
[[ml-get-trained-models-stats-query-params]]
== {api-query-parms-title}
`allow_no_match`::
@ -66,7 +66,7 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models]
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
[role="child_attributes"]
[[ml-get-inference-stats-results]]
[[ml-get-trained-models-stats-results]]
== {api-response-body-title}
`count`::
@ -134,21 +134,21 @@ section in <<cluster-nodes-stats>>.
====
[[ml-get-inference-stats-response-codes]]
[[ml-get-trained-models-stats-response-codes]]
== {api-response-codes-title}
`404` (Missing resources)::
If `allow_no_match` is `false`, this code indicates that there are no
resources that match the request or only partial matches for the request.
[[ml-get-inference-stats-example]]
[[ml-get-trained-models-stats-example]]
== {api-examples-title}
The following example gets usage information for all the trained models:
[source,console]
--------------------------------------------------
GET _ml/inference/_stats
GET _ml/trained_models/_stats
--------------------------------------------------
// TEST[skip:TBD]

View File

@ -1,6 +1,6 @@
[role="xpack"]
[testenv="basic"]
[[get-inference]]
[[get-trained-models]]
= Get trained model API
[subs="attributes"]
++++
@ -12,21 +12,21 @@ Retrieves configuration information for a trained model.
experimental[]
[[ml-get-inference-request]]
[[ml-get-trained-models-request]]
== {api-request-title}
`GET _ml/inference/` +
`GET _ml/trained_models/` +
`GET _ml/inference/<model_id>` +
`GET _ml/trained_models/<model_id>` +
`GET _ml/inference/_all` +
`GET _ml/trained_models/_all` +
`GET _ml/inference/<model_id1>,<model_id2>` +
`GET _ml/trained_models/<model_id1>,<model_id2>` +
`GET _ml/inference/<model_id_pattern*>`
`GET _ml/trained_models/<model_id_pattern*>`
[[ml-get-inference-prereq]]
[[ml-get-trained-models-prereq]]
== {api-prereq-title}
If the {es} {security-features} are enabled, you must have the following
@ -38,14 +38,14 @@ For more information, see <<security-privileges>> and
{ml-docs-setup-privileges}.
[[ml-get-inference-desc]]
[[ml-get-trained-models-desc]]
== {api-description-title}
You can get information for multiple trained models in a single API request by
using a comma-separated list of model IDs or a wildcard expression.
[[ml-get-inference-path-params]]
[[ml-get-trained-models-path-params]]
== {api-path-parms-title}
`<model_id>`::
@ -53,7 +53,7 @@ using a comma-separated list of model IDs or a wildcard expression.
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
[[ml-get-inference-query-params]]
[[ml-get-trained-models-query-params]]
== {api-query-parms-title}
`allow_no_match`::
@ -94,7 +94,7 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=size-models]
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=tags]
[role="child_attributes"]
[[ml-get-inference-results]]
[[ml-get-trained-models-results]]
== {api-response-body-title}
`trained_model_configs`::
@ -232,7 +232,8 @@ A comma delimited string of tags. A trained model can have many tags, or none.
The {es} version number in which the trained model was created.
====
[[ml-get-inference-response-codes]]
[[ml-get-trained-models-response-codes]]
== {api-response-codes-title}
`400`::
@ -244,13 +245,13 @@ The {es} version number in which the trained model was created.
resources that match the request or only partial matches for the request.
[[ml-get-inference-example]]
[[ml-get-trained-models-example]]
== {api-examples-title}
The following example gets configuration information for all the trained models:
[source,console]
--------------------------------------------------
GET _ml/inference/
GET _ml/trained_models/
--------------------------------------------------
// TEST[skip:TBD]

View File

@ -1,12 +1,12 @@
include::ml-df-analytics-apis.asciidoc[leveloffset=+1]
//CREATE
include::put-dfanalytics.asciidoc[leveloffset=+2]
include::put-inference.asciidoc[leveloffset=+2]
include::put-trained-models.asciidoc[leveloffset=+2]
//UPDATE
include::update-dfanalytics.asciidoc[leveloffset=+2]
//DELETE
include::delete-dfanalytics.asciidoc[leveloffset=+2]
include::delete-inference-trained-model.asciidoc[leveloffset=+2]
include::delete-trained-models.asciidoc[leveloffset=+2]
//EVALUATE
include::evaluate-dfanalytics.asciidoc[leveloffset=+2]
//ESTIMATE_MEMORY_USAGE
@ -14,8 +14,8 @@ include::explain-dfanalytics.asciidoc[leveloffset=+2]
//GET
include::get-dfanalytics.asciidoc[leveloffset=+2]
include::get-dfanalytics-stats.asciidoc[leveloffset=+2]
include::get-inference-trained-model.asciidoc[leveloffset=+2]
include::get-inference-trained-model-stats.asciidoc[leveloffset=+2]
include::get-trained-models.asciidoc[leveloffset=+2]
include::get-trained-models-stats.asciidoc[leveloffset=+2]
//SET/START/STOP
include::start-dfanalytics.asciidoc[leveloffset=+2]
include::stop-dfanalytics.asciidoc[leveloffset=+2]

View File

@ -18,10 +18,10 @@ You can use the following APIs to perform {ml} {dfanalytics} activities.
You can use the following APIs to perform {infer} operations.
* <<put-inference>>
* <<get-inference>>
* <<get-inference-stats>>
* <<delete-inference>>
* <<put-trained-models>>
* <<get-trained-models>>
* <<get-trained-models-stats>>
* <<delete-trained-models>>
See also <<ml-apis>>.

View File

@ -1,13 +1,13 @@
[role="xpack"]
[testenv="basic"]
[[put-inference]]
[[put-trained-models]]
= Create trained model API
[subs="attributes"]
++++
<titleabbrev>Create trained model</titleabbrev>
++++
Creates an trained model.
Creates a trained model.
WARNING: Models created in version 7.8.0 are not backwards compatible
with older node versions. If in a mixed cluster environment,
@ -18,13 +18,13 @@ WARNING: Models created in version 7.8.0 are not backwards compatible
experimental[]
[[ml-put-inference-request]]
[[ml-put-trained-models-request]]
== {api-request-title}
`PUT _ml/inference/<model_id>`
`PUT _ml/trained_models/<model_id>`
[[ml-put-inference-prereq]]
[[ml-put-trained-models-prereq]]
== {api-prereq-title}
If the {es} {security-features} are enabled, you must have the following
@ -35,14 +35,14 @@ built-in roles or equivalent privileges:
For more information, see <<built-in-roles>> and {ml-docs-setup-privileges}.
[[ml-put-inference-desc]]
[[ml-put-trained-models-desc]]
== {api-description-title}
The create trained model API enables you to supply a trained model that is not
created by {dfanalytics}.
[[ml-put-inference-path-params]]
[[ml-put-trained-models-path-params]]
== {api-path-parms-title}
`<model_id>`::
@ -50,7 +50,7 @@ created by {dfanalytics}.
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]
[role="child_attributes"]
[[ml-put-inference-request-body]]
[[ml-put-trained-models-request-body]]
== {api-request-body-title}
`compressed_definition`::
@ -70,7 +70,7 @@ The {infer} definition for the model. If `definition` is specified, then
//Begin preprocessors
`preprocessors`::
(Optional, object)
Collection of preprocessors. See <<ml-put-inference-preprocessor-example>>.
Collection of preprocessors. See <<ml-put-trained-models-preprocessor-example>>.
+
.Properties of `preprocessors`
[%collapsible%open]
@ -249,7 +249,7 @@ The decision threshold with which to compare the feature value.
//Begin ensemble
`ensemble`::
(Optional, object)
The definition for an ensemble model. See <<ml-put-inference-model-example>>.
The definition for an ensemble model. See <<ml-put-trained-models-model-example>>.
+
.Properties of `ensemble`
[%collapsible%open]
@ -259,7 +259,7 @@ The definition for an ensemble model. See <<ml-put-inference-model-example>>.
(Required, object)
An aggregated output object that defines how to aggregate the outputs of the
`trained_models`. Supported objects are `weighted_mode`, `weighted_sum`, and
`logistic_regression`. See <<ml-put-inference-aggregated-output-example>>.
`logistic_regression`. See <<ml-put-trained-models-aggregated-output-example>>.
+
.Properties of `aggregate_output`
[%collapsible%open]
@ -448,10 +448,10 @@ An object map that contains metadata about the model.
An array of tags to organize the model.
[[ml-put-inference-example]]
[[ml-put-trained-models-example]]
== {api-examples-title}
[[ml-put-inference-preprocessor-example]]
[[ml-put-trained-models-preprocessor-example]]
=== Preprocessor examples
The example below shows a `frequency_encoding` preprocessor object:
@ -518,7 +518,7 @@ This example shows a `target_mean_encoding` preprocessor object:
//NOTCONSOLE
[[ml-put-inference-model-example]]
[[ml-put-trained-models-model-example]]
=== Model examples
The first example shows a `trained_model` object:
@ -602,7 +602,7 @@ The following example shows an `ensemble` model object:
//NOTCONSOLE
[[ml-put-inference-aggregated-output-example]]
[[ml-put-trained-models-aggregated-output-example]]
=== Aggregated output example
Example of a `logistic_regression` object:
@ -657,7 +657,7 @@ Example of an `exponent` object:
//NOTCONSOLE
[[ml-put-inference-json-schema]]
[[ml-put-trained-models-json-schema]]
=== {infer-cap} JSON schema
For the full JSON schema of model {infer},

View File

@ -539,6 +539,26 @@ See <<put-dfanalytics>>.
This page was deleted.
See <<put-dfanalytics>>.
[role="exclude",id="put-inference"]
=== Create trained model API
See <<put-trained-models>>.
[role="exclude",id="get-inference-stats"]
=== Get trained model statistics API
See <<get-trained-models-stats>>.
[role="exclude",id="get-inference"]
=== Get trained model API
See <<get-trained-models>>.
[role="exclude",id="delete-inference"]
=== Delete trained model API
See <<delete-trained-models>>.
[role="exclude",id="data-frames-settings"]
=== {transforms-cap} settings in Elasticsearch

View File

@ -118,11 +118,11 @@ public class InferenceIngestIT extends ESRestTestCase {
assertBusy(() -> {
try {
Response statsResponse = client().performRequest(new Request("GET",
"_ml/inference/" + classificationModelId + "/_stats"));
"_ml/trained_models/" + classificationModelId + "/_stats"));
String response = EntityUtils.toString(statsResponse.getEntity());
assertThat(response, containsString("\"inference_count\":10"));
assertThat(response, containsString("\"cache_miss_count\":30"));
statsResponse = client().performRequest(new Request("GET", "_ml/inference/" + regressionModelId + "/_stats"));
statsResponse = client().performRequest(new Request("GET", "_ml/trained_models/" + regressionModelId + "/_stats"));
response = EntityUtils.toString(statsResponse.getEntity());
assertThat(response, containsString("\"inference_count\":10"));
assertThat(response, containsString("\"cache_miss_count\":30"));
@ -174,16 +174,16 @@ public class InferenceIngestIT extends ESRestTestCase {
assertBusy(() -> {
try {
Response statsResponse = client().performRequest(new Request("GET",
"_ml/inference/" + classificationModelId + "/_stats"));
"_ml/trained_models/" + classificationModelId + "/_stats"));
String response = EntityUtils.toString(statsResponse.getEntity());
assertThat(response, containsString("\"inference_count\":10"));
assertThat(response, containsString("\"cache_miss_count\":3"));
statsResponse = client().performRequest(new Request("GET", "_ml/inference/" + regressionModelId + "/_stats"));
statsResponse = client().performRequest(new Request("GET", "_ml/trained_models/" + regressionModelId + "/_stats"));
response = EntityUtils.toString(statsResponse.getEntity());
assertThat(response, containsString("\"inference_count\":15"));
assertThat(response, containsString("\"cache_miss_count\":3"));
// can get both
statsResponse = client().performRequest(new Request("GET", "_ml/inference/_stats"));
statsResponse = client().performRequest(new Request("GET", "_ml/trained_models/_stats"));
String entityString = EntityUtils.toString(statsResponse.getEntity());
assertThat(entityString, containsString("\"inference_count\":15"));
assertThat(entityString, containsString("\"inference_count\":10"));
@ -604,7 +604,7 @@ public class InferenceIngestIT extends ESRestTestCase {
}
private void putModel(String modelId, String modelConfiguration) throws IOException {
Request request = new Request("PUT", "_ml/inference/" + modelId);
Request request = new Request("PUT", "_ml/trained_models/" + modelId);
request.setJsonEntity(modelConfiguration);
client().performRequest(request);
}

View File

@ -69,7 +69,7 @@ public class TrainedModelIT extends ESRestTestCase {
putRegressionModel(modelId);
putRegressionModel(modelId2);
Response getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/" + modelId));
MachineLearning.BASE_PATH + "trained_models/" + modelId));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
String response = EntityUtils.toString(getModel.getEntity());
@ -78,7 +78,7 @@ public class TrainedModelIT extends ESRestTestCase {
assertThat(response, containsString("\"count\":1"));
getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/a_test_regression*"));
MachineLearning.BASE_PATH + "trained_models/a_test_regression*"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -88,7 +88,7 @@ public class TrainedModelIT extends ESRestTestCase {
assertThat(response, containsString("\"count\":2"));
getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/a_test_regression_model?human=true&include=definition"));
MachineLearning.BASE_PATH + "trained_models/a_test_regression_model?human=true&include=definition"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -100,7 +100,7 @@ public class TrainedModelIT extends ESRestTestCase {
assertThat(response, containsString("\"count\":1"));
getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/a_test_regression_model?decompress_definition=false&include=definition"));
MachineLearning.BASE_PATH + "trained_models/a_test_regression_model?decompress_definition=false&include=definition"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -112,12 +112,12 @@ public class TrainedModelIT extends ESRestTestCase {
ResponseException responseException = expectThrows(ResponseException.class, () ->
client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/a_test_regression*?human=true&include=definition")));
MachineLearning.BASE_PATH + "trained_models/a_test_regression*?human=true&include=definition")));
assertThat(EntityUtils.toString(responseException.getResponse().getEntity()),
containsString(Messages.INFERENCE_TOO_MANY_DEFINITIONS_REQUESTED));
getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/a_test_regression_model,a_test_regression_model-2"));
MachineLearning.BASE_PATH + "trained_models/a_test_regression_model,a_test_regression_model-2"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -126,17 +126,17 @@ public class TrainedModelIT extends ESRestTestCase {
assertThat(response, containsString("\"count\":2"));
getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/classification*?allow_no_match=true"));
MachineLearning.BASE_PATH + "trained_models/classification*?allow_no_match=true"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
assertThat(response, containsString("\"count\":0"));
ResponseException ex = expectThrows(ResponseException.class, () -> client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/classification*?allow_no_match=false")));
MachineLearning.BASE_PATH + "trained_models/classification*?allow_no_match=false")));
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(404));
getModel = client().performRequest(new Request("GET", MachineLearning.BASE_PATH + "inference?from=0&size=1"));
getModel = client().performRequest(new Request("GET", MachineLearning.BASE_PATH + "trained_models?from=0&size=1"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -144,7 +144,7 @@ public class TrainedModelIT extends ESRestTestCase {
assertThat(response, containsString("\"model_id\":\"a_test_regression_model\""));
assertThat(response, not(containsString("\"model_id\":\"a_test_regression_model-2\"")));
getModel = client().performRequest(new Request("GET", MachineLearning.BASE_PATH + "inference?from=1&size=1"));
getModel = client().performRequest(new Request("GET", MachineLearning.BASE_PATH + "trained_models?from=1&size=1"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -158,12 +158,12 @@ public class TrainedModelIT extends ESRestTestCase {
putRegressionModel(modelId);
Response delModel = client().performRequest(new Request("DELETE",
MachineLearning.BASE_PATH + "inference/" + modelId));
MachineLearning.BASE_PATH + "trained_models/" + modelId));
String response = EntityUtils.toString(delModel.getEntity());
assertThat(response, containsString("\"acknowledged\":true"));
ResponseException responseException = expectThrows(ResponseException.class,
() -> client().performRequest(new Request("DELETE", MachineLearning.BASE_PATH + "inference/" + modelId)));
() -> client().performRequest(new Request("DELETE", MachineLearning.BASE_PATH + "trained_models/" + modelId)));
assertThat(responseException.getResponse().getStatusLine().getStatusCode(), equalTo(404));
responseException = expectThrows(ResponseException.class,
@ -181,7 +181,7 @@ public class TrainedModelIT extends ESRestTestCase {
public void testGetPrePackagedModels() throws IOException {
Response getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/lang_ident_model_1?human=true&include=definition"));
MachineLearning.BASE_PATH + "trained_models/lang_ident_model_1?human=true&include=definition"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
String response = EntityUtils.toString(getModel.getEntity());
@ -194,7 +194,7 @@ public class TrainedModelIT extends ESRestTestCase {
String modelId = "regression_model_to_export";
putRegressionModel(modelId);
Response getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH + "inference/" + modelId));
MachineLearning.BASE_PATH + "trained_models/" + modelId));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
String response = EntityUtils.toString(getModel.getEntity());
@ -203,7 +203,7 @@ public class TrainedModelIT extends ESRestTestCase {
getModel = client().performRequest(new Request("GET",
MachineLearning.BASE_PATH +
"inference/" + modelId +
"trained_models/" + modelId +
"?include=definition&decompress_definition=false&for_export=true"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
@ -213,11 +213,11 @@ public class TrainedModelIT extends ESRestTestCase {
String importedModelId = "regression_model_to_import";
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
builder.map(modelDefinition);
Request model = new Request("PUT", "_ml/inference/" + importedModelId);
Request model = new Request("PUT", "_ml/trained_models/" + importedModelId);
model.setJsonEntity(XContentHelper.convertToJson(BytesReference.bytes(builder), false, XContentType.JSON));
assertThat(client().performRequest(model).getStatusLine().getStatusCode(), equalTo(200));
}
getModel = client().performRequest(new Request("GET", MachineLearning.BASE_PATH + "inference/regression*"));
getModel = client().performRequest(new Request("GET", MachineLearning.BASE_PATH + "trained_models/regression*"));
assertThat(getModel.getStatusLine().getStatusCode(), equalTo(200));
response = EntityUtils.toString(getModel.getEntity());
@ -237,7 +237,7 @@ public class TrainedModelIT extends ESRestTestCase {
.setModelId(modelId)
.setInput(new TrainedModelInput(Arrays.asList("col1", "col2", "col3")))
.build().toXContent(builder, ToXContent.EMPTY_PARAMS);
Request model = new Request("PUT", "_ml/inference/" + modelId);
Request model = new Request("PUT", "_ml/trained_models/" + modelId);
model.setJsonEntity(XContentHelper.convertToJson(BytesReference.bytes(builder), false, XContentType.JSON));
assertThat(client().performRequest(model).getStatusLine().getStatusCode(), equalTo(200));
}

View File

@ -35,7 +35,7 @@ public class InferenceProcessorIT extends ESRestTestCase {
private void putRegressionModel() throws IOException {
Request model = new Request("PUT", "_ml/inference/" + MODEL_ID);
Request model = new Request("PUT", "_ml/trained_models/" + MODEL_ID);
model.setJsonEntity(
" {\n" +
" \"description\": \"empty model for tests\",\n" +

View File

@ -14,6 +14,7 @@ import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig;
import org.elasticsearch.xpack.ml.MachineLearning;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static java.util.Collections.singletonList;
@ -23,8 +24,15 @@ public class RestDeleteTrainedModelAction extends BaseRestHandler {
@Override
public List<Route> routes() {
return Collections.emptyList();
}
@Override
public List<ReplacedRoute> replacedRoutes() {
return singletonList(
new Route(DELETE, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"));
new ReplacedRoute(
DELETE, MachineLearning.BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}",
DELETE, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"));
}
@Override

View File

@ -42,9 +42,18 @@ public class RestGetTrainedModelsAction extends BaseRestHandler {
@Override
public List<Route> routes() {
return Collections.emptyList();
}
@Override
public List<ReplacedRoute> replacedRoutes() {
return unmodifiableList(asList(
new Route(GET, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"),
new Route(GET, MachineLearning.BASE_PATH + "inference")));
new ReplacedRoute(
GET, MachineLearning.BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}",
GET, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"),
new ReplacedRoute(
GET, MachineLearning.BASE_PATH + "trained_models",
GET, MachineLearning.BASE_PATH + "inference")));
}
private static final Map<String, String> DEFAULT_TO_XCONTENT_VALUES =

View File

@ -17,6 +17,7 @@ import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig;
import org.elasticsearch.xpack.ml.MachineLearning;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
@ -28,9 +29,18 @@ public class RestGetTrainedModelsStatsAction extends BaseRestHandler {
@Override
public List<Route> routes() {
return Collections.emptyList();
}
@Override
public List<ReplacedRoute> replacedRoutes() {
return unmodifiableList(asList(
new Route(GET, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}/_stats"),
new Route(GET, MachineLearning.BASE_PATH + "inference/_stats")));
new ReplacedRoute(
GET, MachineLearning.BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}/_stats",
GET, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}/_stats"),
new ReplacedRoute(
GET, MachineLearning.BASE_PATH + "trained_models/_stats",
GET, MachineLearning.BASE_PATH + "inference/_stats")));
}
@Override

View File

@ -15,6 +15,7 @@ import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig;
import org.elasticsearch.xpack.ml.MachineLearning;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import static java.util.Collections.singletonList;
@ -24,8 +25,15 @@ public class RestPutTrainedModelAction extends BaseRestHandler {
@Override
public List<Route> routes() {
return Collections.emptyList();
}
@Override
public List<ReplacedRoute> replacedRoutes() {
return singletonList(
new Route(PUT, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"));
new ReplacedRoute(
PUT, MachineLearning.BASE_PATH + "trained_models/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}",
PUT, MachineLearning.BASE_PATH + "inference/{" + TrainedModelConfig.MODEL_ID.getPreferredName() + "}"));
}
@Override

View File

@ -1,14 +1,14 @@
{
"ml.delete_trained_model":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-trained-models.html",
"description":"Deletes an existing trained inference model that is currently not referenced by an ingest pipeline."
},
"stability":"experimental",
"url":{
"paths":[
{
"path":"/_ml/inference/{model_id}",
"path":"/_ml/trained_models/{model_id}",
"methods":[
"DELETE"
],

View File

@ -1,14 +1,14 @@
{
"ml.get_trained_models":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models.html",
"description":"Retrieves configuration information for a trained inference model."
},
"stability":"experimental",
"url":{
"paths":[
{
"path":"/_ml/inference/{model_id}",
"path":"/_ml/trained_models/{model_id}",
"methods":[
"GET"
],
@ -20,7 +20,7 @@
}
},
{
"path":"/_ml/inference",
"path":"/_ml/trained_models",
"methods":[
"GET"
]

View File

@ -1,14 +1,14 @@
{
"ml.get_trained_models_stats":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-stats.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html",
"description":"Retrieves usage information for trained inference models."
},
"stability":"experimental",
"url":{
"paths":[
{
"path":"/_ml/inference/{model_id}/_stats",
"path":"/_ml/trained_models/{model_id}/_stats",
"methods":[
"GET"
],
@ -20,7 +20,7 @@
}
},
{
"path":"/_ml/inference/_stats",
"path":"/_ml/trained_models/_stats",
"methods":[
"GET"
]

View File

@ -1,14 +1,14 @@
{
"ml.put_trained_model":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/put-trained-models.html",
"description":"Creates an inference trained model."
},
"stability":"experimental",
"url":{
"paths":[
{
"path":"/_ml/inference/{model_id}",
"path":"/_ml/trained_models/{model_id}",
"methods":[
"PUT"
],