Skip to content

Commit

Permalink
[ML][Inference] minor fixes for created_by, and action permission (#5…
Browse files Browse the repository at this point in the history
…0890) (#50911)

The system created and models we provide now use the `_xpack` user for uniformity with our other features

The `PUT` action is now an admin cluster action

And XPackClient class now references the action instance.
  • Loading branch information
benwtrent authored Jan 13, 2020
1 parent 4e83759 commit eb8fd44
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
public class PutTrainedModelAction extends ActionType<PutTrainedModelAction.Response> {

public static final PutTrainedModelAction INSTANCE = new PutTrainedModelAction();
public static final String NAME = "cluster:monitor/xpack/ml/inference/put";
public static final String NAME = "cluster:admin/xpack/ml/inference/put";
private PutTrainedModelAction() {
super(NAME, Response::new);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.elasticsearch.xpack.core.ml.inference.TrainedModelDefinition;
import org.elasticsearch.xpack.core.ml.inference.TrainedModelInput;
import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.core.security.user.XPackUser;
import org.elasticsearch.xpack.ml.dataframe.DataFrameAnalyticsTask.ProgressTracker;
import org.elasticsearch.xpack.ml.dataframe.process.results.AnalyticsResult;
import org.elasticsearch.xpack.ml.dataframe.process.results.RowResults;
Expand Down Expand Up @@ -173,7 +174,7 @@ private TrainedModelConfig createTrainedModelConfig(TrainedModelDefinition.Build
.collect(toList());
return TrainedModelConfig.builder()
.setModelId(modelId)
.setCreatedBy("data-frame-analytics")
.setCreatedBy(XPackUser.NAME)
.setVersion(Version.CURRENT)
.setCreateTime(createTime)
.setTags(Collections.singletonList(analytics.getId()))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"model_id" : "lang_ident_model_1",
"created_by" : "ml_admin",
"created_by" : "_xpack",
"version" : "7.6.0",
"description" : "Model used for identifying language from arbitrary input text.",
"create_time" : 1575548914594,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.elasticsearch.xpack.core.ml.inference.TrainedModelConfig;
import org.elasticsearch.xpack.core.ml.inference.TrainedModelDefinition;
import org.elasticsearch.xpack.core.ml.inference.TrainedModelDefinitionTests;
import org.elasticsearch.xpack.core.security.user.XPackUser;
import org.elasticsearch.xpack.ml.dataframe.DataFrameAnalyticsTask.ProgressTracker;
import org.elasticsearch.xpack.ml.dataframe.process.results.AnalyticsResult;
import org.elasticsearch.xpack.ml.dataframe.process.results.RowResults;
Expand Down Expand Up @@ -167,7 +168,7 @@ public void testProcess_GivenInferenceModelIsStoredSuccessfully() {
assertThat(storedModel.getLicenseLevel(), equalTo(License.OperationMode.PLATINUM));
assertThat(storedModel.getModelId(), containsString(JOB_ID));
assertThat(storedModel.getVersion(), equalTo(Version.CURRENT));
assertThat(storedModel.getCreatedBy(), equalTo("data-frame-analytics"));
assertThat(storedModel.getCreatedBy(), equalTo(XPackUser.NAME));
assertThat(storedModel.getTags(), contains(JOB_ID));
assertThat(storedModel.getDescription(), equalTo(JOB_DESCRIPTION));
assertThat(storedModel.getModelDefinition(), equalTo(inferenceModel.build()));
Expand Down

0 comments on commit eb8fd44

Please sign in to comment.