From cfcf973259afe92e3763530e2686951ffafe00da Mon Sep 17 00:00:00 2001 From: Benjamin Trent Date: Fri, 2 Oct 2020 07:34:28 -0400 Subject: [PATCH] [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. --- .../client/MLRequestConverters.java | 8 +-- .../client/MachineLearningClient.java | 12 ++--- .../client/MLRequestConvertersTests.java | 8 +-- .../client/MachineLearningIT.java | 2 +- .../MlClientDocumentationIT.java | 20 +++---- ...sciidoc => delete-trained-models.asciidoc} | 2 +- .../high-level/supported-apis.asciidoc | 4 +- .../inference-bucket-aggregation.asciidoc | 18 +++---- ...sciidoc => delete-trained-models.asciidoc} | 24 ++++----- ...idoc => get-trained-models-stats.asciidoc} | 54 +++++++++---------- ...l.asciidoc => get-trained-models.asciidoc} | 31 +++++------ .../ml/df-analytics/apis/index.asciidoc | 8 +-- .../apis/ml-df-analytics-apis.asciidoc | 8 +-- ...e.asciidoc => put-trained-models.asciidoc} | 38 ++++++------- docs/reference/redirects.asciidoc | 20 +++++++ .../ml/integration/InferenceIngestIT.java | 12 ++--- .../xpack/ml/integration/TrainedModelIT.java | 36 ++++++------- .../ml/integration/InferenceProcessorIT.java | 2 +- .../RestDeleteTrainedModelAction.java | 10 +++- .../inference/RestGetTrainedModelsAction.java | 13 ++++- .../RestGetTrainedModelsStatsAction.java | 14 ++++- .../inference/RestPutTrainedModelAction.java | 10 +++- .../api/ml.delete_trained_model.json | 4 +- .../api/ml.get_trained_models.json | 6 +-- .../api/ml.get_trained_models_stats.json | 6 +-- .../api/ml.put_trained_model.json | 4 +- 26 files changed, 215 insertions(+), 159 deletions(-) rename docs/java-rest/high-level/ml/{delete-trained-model.asciidoc => delete-trained-models.asciidoc} (97%) rename docs/reference/ml/df-analytics/apis/{delete-inference-trained-model.asciidoc => delete-trained-models.asciidoc} (73%) rename docs/reference/ml/df-analytics/apis/{get-inference-trained-model-stats.asciidoc => get-trained-models-stats.asciidoc} (84%) rename docs/reference/ml/df-analytics/apis/{get-inference-trained-model.asciidoc => get-trained-models.asciidoc} (92%) rename docs/reference/ml/df-analytics/apis/{put-inference.asciidoc => put-trained-models.asciidoc} (94%) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/MLRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/MLRequestConverters.java index 758a1700878..6575a4aacb7 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/MLRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/MLRequestConverters.java @@ -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); diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/MachineLearningClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/MachineLearningClient.java index 6c74dd1e800..4103f71d627 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/MachineLearningClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/MachineLearningClient.java @@ -2395,7 +2395,7 @@ public final class MachineLearningClient { * Gets trained model configs *

* For additional info - * see + * see * GET Trained Model Configs documentation * * @param request The {@link GetTrainedModelsRequest} @@ -2415,7 +2415,7 @@ public final class MachineLearningClient { * Gets trained model configs asynchronously and notifies listener upon completion *

* For additional info - * see + * see * GET Trained Model Configs documentation * * @param request The {@link GetTrainedModelsRequest} @@ -2480,7 +2480,7 @@ public final class MachineLearningClient { * Gets trained model stats *

* For additional info - * see + * see * GET Trained Model Stats documentation * * @param request The {@link GetTrainedModelsStatsRequest} @@ -2500,7 +2500,7 @@ public final class MachineLearningClient { * Gets trained model stats asynchronously and notifies listener upon completion *

* For additional info - * see + * see * GET Trained Model Stats documentation * * @param request The {@link GetTrainedModelsStatsRequest} @@ -2523,7 +2523,7 @@ public final class MachineLearningClient { * Deletes the given Trained Model *

* For additional info - * see + * see * DELETE Trained Model documentation * * @param request The {@link DeleteTrainedModelRequest} @@ -2543,7 +2543,7 @@ public final class MachineLearningClient { * Deletes the given Trained Model asynchronously and notifies listener upon completion *

* For additional info - * see + * see * DELETE Trained Model documentation * * @param request The {@link DeleteTrainedModelRequest} diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/MLRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/MLRequestConvertersTests.java index 75958f8e433..f67fa3cce87 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MLRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/MLRequestConvertersTests.java @@ -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)); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java index 0d8c4d6ff39..a817afe305f 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/MachineLearningIT.java @@ -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( diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java index 3aaca3a86ae..3d04afc73b1 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/MlClientDocumentationIT.java @@ -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 listener = new ActionListener() { @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)); } diff --git a/docs/java-rest/high-level/ml/delete-trained-model.asciidoc b/docs/java-rest/high-level/ml/delete-trained-models.asciidoc similarity index 97% rename from docs/java-rest/high-level/ml/delete-trained-model.asciidoc rename to docs/java-rest/high-level/ml/delete-trained-models.asciidoc index d1e0a2a69c3..81836808b3d 100644 --- a/docs/java-rest/high-level/ml/delete-trained-model.asciidoc +++ b/docs/java-rest/high-level/ml/delete-trained-models.asciidoc @@ -1,5 +1,5 @@ -- -:api: delete-trained-model +:api: delete-trained-models :request: DeleteTrainedModelRequest :response: AcknowledgedResponse -- diff --git a/docs/java-rest/high-level/supported-apis.asciidoc b/docs/java-rest/high-level/supported-apis.asciidoc index fc5be393b89..453b0e39124 100644 --- a/docs/java-rest/high-level/supported-apis.asciidoc +++ b/docs/java-rest/high-level/supported-apis.asciidoc @@ -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[] diff --git a/docs/reference/aggregations/pipeline/inference-bucket-aggregation.asciidoc b/docs/reference/aggregations/pipeline/inference-bucket-aggregation.asciidoc index ed811c3829a..115d7c73570 100644 --- a/docs/reference/aggregations/pipeline/inference-bucket-aggregation.asciidoc +++ b/docs/reference/aggregations/pipeline/inference-bucket-aggregation.asciidoc @@ -8,8 +8,8 @@ experimental::[] 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 <>. +To use the {infer} bucket aggregation, you need to have the same security +privileges that are required for using the <>. [[inference-bucket-agg-syntax]] ==== Syntax @@ -53,8 +53,8 @@ See <> for more details | Required | - ==== Configuration options for {infer} models -The `inference_config` setting is optional and usually isn't required as the -pre-trained models come equipped with sensible defaults. In the context of +The `inference_config` setting is optional and usually isn't required as the +pre-trained models come equipped with sensible defaults. In the context of aggregations some options can overridden for each of the 2 types of model. [discrete] @@ -83,10 +83,10 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=inference-config-classification [[inference-bucket-agg-example]] -==== Example +==== Example -The following snippet aggregates a web log by `client_ip` and extracts a number -of features via metric and bucket sub-aggregations as input to the {infer} +The following snippet aggregates a web log by `client_ip` and extracts a number +of features via metric and bucket sub-aggregations as input to the {infer} aggregation configured with a model trained to identify suspicious client IPs: [source,console] @@ -178,5 +178,5 @@ GET kibana_sample_data_logs/_search <1> A composite bucket aggregation that aggregates the data by `client_ip`. <2> A series of metrics and bucket sub-aggregations. -<3> {infer-cap} bucket aggregation that contains the model ID and maps the -aggregation names to the model's input fields. \ No newline at end of file +<3> {infer-cap} bucket aggregation that contains the model ID and maps the +aggregation names to the model's input fields. diff --git a/docs/reference/ml/df-analytics/apis/delete-inference-trained-model.asciidoc b/docs/reference/ml/df-analytics/apis/delete-trained-models.asciidoc similarity index 73% rename from docs/reference/ml/df-analytics/apis/delete-inference-trained-model.asciidoc rename to docs/reference/ml/df-analytics/apis/delete-trained-models.asciidoc index 469d45a3656..1a8fdff0713 100644 --- a/docs/reference/ml/df-analytics/apis/delete-inference-trained-model.asciidoc +++ b/docs/reference/ml/df-analytics/apis/delete-trained-models.asciidoc @@ -1,25 +1,25 @@ [role="xpack"] [testenv="basic"] -[[delete-inference]] +[[delete-trained-models]] = Delete trained model API [subs="attributes"] ++++ Delete trained model ++++ -Deletes an existing trained {infer} model that is currently not referenced by an +Deletes an existing trained {infer} model that is currently not referenced by an ingest pipeline. experimental[] -[[ml-delete-inference-request]] +[[ml-delete-trained-models-request]] == {api-request-title} -`DELETE _ml/inference/` +`DELETE _ml/trained_models/` -[[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,31 +29,31 @@ If the {es} {security-features} are enabled, you must have the following built-i For more information, see <> and {ml-docs-setup-privileges}. -[[ml-delete-inference-path-params]] +[[ml-delete-trained-models-path-params]] == {api-path-parms-title} ``:: -(Optional, string) +(Optional, string) 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`:: - The code indicates that the trained model is referenced by an ingest pipeline + The code indicates that the trained model is referenced by an ingest pipeline 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 +The following example deletes the `regression-job-one-1574775307356` trained model: [source,console] -------------------------------------------------- -DELETE _ml/inference/regression-job-one-1574775307356 +DELETE _ml/trained_models/regression-job-one-1574775307356 -------------------------------------------------- // TEST[skip:TBD] diff --git a/docs/reference/ml/df-analytics/apis/get-inference-trained-model-stats.asciidoc b/docs/reference/ml/df-analytics/apis/get-trained-models-stats.asciidoc similarity index 84% rename from docs/reference/ml/df-analytics/apis/get-inference-trained-model-stats.asciidoc rename to docs/reference/ml/df-analytics/apis/get-trained-models-stats.asciidoc index e47c60dde83..d4c44d80791 100644 --- a/docs/reference/ml/df-analytics/apis/get-inference-trained-model-stats.asciidoc +++ b/docs/reference/ml/df-analytics/apis/get-trained-models-stats.asciidoc @@ -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//_stats` + +`GET _ml/trained_models//_stats` + -`GET _ml/inference/,/_stats` + +`GET _ml/trained_models/,/_stats` + -`GET _ml/inference/,/_stats` +`GET _ml/trained_models/,/_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,49 +35,49 @@ Required privileges which should be added to a custom role: For more information, see <> 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 +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} ``:: -(Optional, string) +(Optional, string) 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`:: -(Optional, boolean) +(Optional, boolean) include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-no-match-models] `from`:: -(Optional, integer) +(Optional, integer) include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=from-models] `size`:: -(Optional, integer) +(Optional, integer) 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`:: (integer) -The total number of trained model statistics that matched the requested ID -patterns. Could be higher than the number of items in the `trained_model_stats` +The total number of trained model statistics that matched the requested ID +patterns. Could be higher than the number of items in the `trained_model_stats` array as the size of the array is restricted by the supplied `size` parameter. `trained_model_stats`:: (array) -An array of trained model statistics, which are sorted by the `model_id` value +An array of trained model statistics, which are sorted by the `model_id` value in ascending order. + .Properties of trained model stats @@ -111,10 +111,10 @@ This is across all inference contexts, including all pipelines. `cache_miss_count`::: (integer) -The number of times the model was loaded for inference and was not retrieved -from the cache. If this number is close to the `inference_count`, then the cache -is not being appropriately used. This can be solved by increasing the cache size -or its time-to-live (TTL). See <> for the appropriate +The number of times the model was loaded for inference and was not retrieved +from the cache. If this number is close to the `inference_count`, then the cache +is not being appropriately used. This can be solved by increasing the cache size +or its time-to-live (TTL). See <> for the appropriate settings. `failure_count`::: @@ -134,21 +134,21 @@ section in <>. ==== -[[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] diff --git a/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc b/docs/reference/ml/df-analytics/apis/get-trained-models.asciidoc similarity index 92% rename from docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc rename to docs/reference/ml/df-analytics/apis/get-trained-models.asciidoc index 59b3f89bcfa..c99a20d6cb4 100644 --- a/docs/reference/ml/df-analytics/apis/get-inference-trained-model.asciidoc +++ b/docs/reference/ml/df-analytics/apis/get-trained-models.asciidoc @@ -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/` + +`GET _ml/trained_models/` + -`GET _ml/inference/_all` + +`GET _ml/trained_models/_all` + -`GET _ml/inference/,` + +`GET _ml/trained_models/,` + -`GET _ml/inference/` +`GET _ml/trained_models/` -[[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 <> 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} ``:: @@ -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] diff --git a/docs/reference/ml/df-analytics/apis/index.asciidoc b/docs/reference/ml/df-analytics/apis/index.asciidoc index 421393a1b53..63a46480ce7 100644 --- a/docs/reference/ml/df-analytics/apis/index.asciidoc +++ b/docs/reference/ml/df-analytics/apis/index.asciidoc @@ -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] diff --git a/docs/reference/ml/df-analytics/apis/ml-df-analytics-apis.asciidoc b/docs/reference/ml/df-analytics/apis/ml-df-analytics-apis.asciidoc index 05cbaec9d43..6597c2ae841 100644 --- a/docs/reference/ml/df-analytics/apis/ml-df-analytics-apis.asciidoc +++ b/docs/reference/ml/df-analytics/apis/ml-df-analytics-apis.asciidoc @@ -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. -* <> -* <> -* <> -* <> +* <> +* <> +* <> +* <> See also <>. diff --git a/docs/reference/ml/df-analytics/apis/put-inference.asciidoc b/docs/reference/ml/df-analytics/apis/put-trained-models.asciidoc similarity index 94% rename from docs/reference/ml/df-analytics/apis/put-inference.asciidoc rename to docs/reference/ml/df-analytics/apis/put-trained-models.asciidoc index 7f39dfd8b1c..d40c9455642 100644 --- a/docs/reference/ml/df-analytics/apis/put-inference.asciidoc +++ b/docs/reference/ml/df-analytics/apis/put-trained-models.asciidoc @@ -1,13 +1,13 @@ [role="xpack"] [testenv="basic"] -[[put-inference]] +[[put-trained-models]] = Create trained model API [subs="attributes"] ++++ Create trained model ++++ -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/` +`PUT _ml/trained_models/` -[[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 <> 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 +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} ``:: @@ -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`:: @@ -61,7 +61,7 @@ If `compressed_definition` is specified, then `definition` cannot be specified. //Begin definition `definition`:: (Required, object) -The {infer} definition for the model. If `definition` is specified, then +The {infer} definition for the model. If `definition` is specified, then `compressed_definition` cannot be specified. + .Properties of `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 <>. +Collection of preprocessors. See <>. + .Properties of `preprocessors` [%collapsible%open] @@ -172,7 +172,7 @@ The definition for a binary decision tree. [%collapsible%open] ====== `classification_labels`::: -(Optional, string) An array of classification labels (used for +(Optional, string) An array of classification labels (used for `classification`). `feature_names`::: @@ -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 <>. +The definition for an ensemble model. See <>. + .Properties of `ensemble` [%collapsible%open] @@ -259,7 +259,7 @@ The definition for an ensemble model. See <>. (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 <>. +`logistic_regression`. See <>. + .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}, diff --git a/docs/reference/redirects.asciidoc b/docs/reference/redirects.asciidoc index 7ac318aeaac..6f91157866a 100644 --- a/docs/reference/redirects.asciidoc +++ b/docs/reference/redirects.asciidoc @@ -539,6 +539,26 @@ See <>. This page was deleted. See <>. +[role="exclude",id="put-inference"] +=== Create trained model API + +See <>. + +[role="exclude",id="get-inference-stats"] +=== Get trained model statistics API + +See <>. + +[role="exclude",id="get-inference"] +=== Get trained model API + +See <>. + +[role="exclude",id="delete-inference"] +=== Delete trained model API + +See <>. + [role="exclude",id="data-frames-settings"] === {transforms-cap} settings in Elasticsearch diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceIngestIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceIngestIT.java index c1e9bf70457..00d4e0fa6af 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceIngestIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceIngestIT.java @@ -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); } diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TrainedModelIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TrainedModelIT.java index 0f036218b6d..aa1c9658e76 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TrainedModelIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TrainedModelIT.java @@ -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)); } diff --git a/x-pack/plugin/ml/qa/single-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceProcessorIT.java b/x-pack/plugin/ml/qa/single-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceProcessorIT.java index c0129fff722..78c885011cd 100644 --- a/x-pack/plugin/ml/qa/single-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceProcessorIT.java +++ b/x-pack/plugin/ml/qa/single-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/InferenceProcessorIT.java @@ -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" + diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestDeleteTrainedModelAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestDeleteTrainedModelAction.java index e0e2b3f3d20..671a88d6f38 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestDeleteTrainedModelAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestDeleteTrainedModelAction.java @@ -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 routes() { + return Collections.emptyList(); + } + + @Override + public List 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 diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java index 0e0acde2157..6e618b1a650 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java @@ -42,9 +42,18 @@ public class RestGetTrainedModelsAction extends BaseRestHandler { @Override public List routes() { + return Collections.emptyList(); + } + + @Override + public List 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 DEFAULT_TO_XCONTENT_VALUES = diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java index 4016f7410be..eced51d1e59 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsStatsAction.java @@ -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 routes() { + return Collections.emptyList(); + } + + @Override + public List 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 diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestPutTrainedModelAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestPutTrainedModelAction.java index 54f0f8476bd..590778f4844 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestPutTrainedModelAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestPutTrainedModelAction.java @@ -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 routes() { + return Collections.emptyList(); + } + + @Override + public List 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 diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.delete_trained_model.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.delete_trained_model.json index 27d24cd7759..15c21314e4c 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.delete_trained_model.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.delete_trained_model.json @@ -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" ], diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models.json index b58e5258097..779fe6069cb 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models.json @@ -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" ] diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models_stats.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models_stats.json index 93e94452130..271f167c662 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models_stats.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.get_trained_models_stats.json @@ -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" ] diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.put_trained_model.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.put_trained_model.json index f69756b55e9..094bef3ba61 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.put_trained_model.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/ml.put_trained_model.json @@ -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" ],