Skip to content

Commit

Permalink
[ML] add default inference config to lang ident model (#65986)
Browse files Browse the repository at this point in the history
This adds a default `inference_config` object to the stored lang ident model.

This doesn't change behavior as there are no default settings set in the config.

Additionally, when serializing over the wire in older versions, we handle bwc.

This commit also slightly changes the error message when a model stored as a resource is attempted to be deleted.

relates: elastic/kibana#85179
  • Loading branch information
benwtrent authored Dec 8, 2020
1 parent 3e45318 commit 38a0c33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public final class Messages {
"Configuration [{0}] requires minimum node version [{1}] (current minimum node version [{2}]";
public static final String MODEL_DEFINITION_NOT_FOUND = "Could not find trained model definition [{0}]";
public static final String MODEL_METADATA_NOT_FOUND = "Could not find trained model metadata {0}";
public static final String INFERENCE_CANNOT_DELETE_MODEL =
"Unable to delete model [{0}]";
public static final String INFERENCE_CANNOT_DELETE_ML_MANAGED_MODEL =
"Unable to delete model [{0}] as it is required by machine learning";
public static final String MODEL_DEFINITION_TRUNCATED =
"Model definition truncated. Unable to deserialize trained model definition [{0}]";
public static final String INFERENCE_FAILED_TO_DESERIALIZE = "Could not deserialize trained model [{0}]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,10 @@ public void getTrainedModels(Set<String> modelIds,

public void deleteTrainedModel(String modelId, ActionListener<Boolean> listener) {
if (MODELS_STORED_AS_RESOURCE.contains(modelId)) {
listener.onFailure(ExceptionsHelper.badRequestException(Messages.getMessage(Messages.INFERENCE_CANNOT_DELETE_MODEL, modelId)));
listener.onFailure(ExceptionsHelper.badRequestException(Messages.getMessage(
Messages.INFERENCE_CANNOT_DELETE_ML_MANAGED_MODEL,
modelId
)));
return;
}
DeleteByQueryRequest request = new DeleteByQueryRequest().setAbortOnVersionConflict(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"text"
]
},
"inference_config" : {"classification" : {}},
"estimated_heap_memory_usage_bytes" : 1053992,
"estimated_operations" : 39629,
"license_level" : "basic"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public void testDeleteModelStoredAsResource() {
// Should be OK as we don't make any client calls
trainedModelProvider.deleteTrainedModel("lang_ident_model_1", future);
ElasticsearchException ex = expectThrows(ElasticsearchException.class, future::actionGet);
assertThat(ex.getMessage(), equalTo(Messages.getMessage(Messages.INFERENCE_CANNOT_DELETE_MODEL, "lang_ident_model_1")));
assertThat(ex.getMessage(), equalTo(Messages.getMessage(
Messages.INFERENCE_CANNOT_DELETE_ML_MANAGED_MODEL,
"lang_ident_model_1"
)));
}

public void testPutModelThatExistsAsResource() {
Expand Down

0 comments on commit 38a0c33

Please sign in to comment.