Skip to content

Commit a64e2b9

Browse files
change the settings name and fixed a bug in delete model (#861) (#864)
Signed-off-by: Dhrubo Saha <[email protected]> (cherry picked from commit d2fb391) Co-authored-by: Dhrubo Saha <[email protected]>
1 parent 1d743af commit a64e2b9

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

plugin/src/main/java/org/opensearch/ml/action/models/DeleteModelTransportAction.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ public void onFailure(Exception e) {
125125
log.error("Failed to parse ml model" + r.getId(), e);
126126
actionListener.onFailure(e);
127127
}
128+
} else {
129+
actionListener
130+
.onFailure(new IllegalArgumentException("Failed to find model to delete with the provided model id: " + modelId));
128131
}
129132
}, e -> { actionListener.onFailure(new MLResourceNotFoundException("Fail to find model")); }));
130133
} catch (Exception e) {

plugin/src/main/java/org/opensearch/ml/action/models/GetModelTransportAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<MLMode
7979
actionListener.onFailure(e);
8080
}
8181
} else {
82-
actionListener.onFailure(new MLResourceNotFoundException("Fail to find model"));
82+
actionListener.onFailure(new IllegalArgumentException("Failed to find model with the provided model id: " + modelId));
8383
}
8484
}, e -> {
8585
if (e instanceof IndexNotFoundException) {

plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public List<Setting<?>> getSettings() {
504504
MLCommonsSettings.ML_COMMONS_NATIVE_MEM_THRESHOLD,
505505
MLCommonsSettings.ML_COMMONS_EXCLUDE_NODE_NAMES,
506506
MLCommonsSettings.ML_COMMONS_ALLOW_CUSTOM_DEPLOYMENT_PLAN,
507-
MLCommonsSettings.ML_COMMONS_ENABLE_MCORR,
507+
MLCommonsSettings.ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL,
508508
MLCommonsSettings.ML_COMMONS_MODEL_AUTO_REDEPLOY_ENABLE,
509509
MLCommonsSettings.ML_COMMONS_MODEL_AUTO_REDEPLOY_LIFETIME_RETRY_TIMES
510510
);

plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@ private MLCommonsSettings() {}
3232
public static final Setting<Boolean> ML_COMMONS_ONLY_RUN_ON_ML_NODE = Setting
3333
.boolSetting("plugins.ml_commons.only_run_on_ml_node", true, Setting.Property.NodeScope, Setting.Property.Dynamic);
3434

35-
// in opensource 2.7 release, we are releasing metrics correlation feature as experimental.
36-
// by default this algorithm will be disabled. client needs to explicitly enable this setting
37-
public static final Setting<Boolean> ML_COMMONS_ENABLE_MCORR = Setting
38-
.boolSetting("plugins.ml_commons.enable_metrics_correlation", false, Setting.Property.NodeScope, Setting.Property.Dynamic);
35+
public static final Setting<Boolean> ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL = Setting
36+
.boolSetting("plugins.ml_commons.enable_inhouse_python_model", false, Setting.Property.NodeScope, Setting.Property.Dynamic);
3937
public static final Setting<Integer> ML_COMMONS_SYNC_UP_JOB_INTERVAL_IN_SECONDS = Setting
4038
.intSetting(
4139
"plugins.ml_commons.sync_up_job_interval_in_seconds",

plugin/src/main/java/org/opensearch/ml/task/MLExecuteTaskRunner.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package org.opensearch.ml.task;
77

88
import static org.opensearch.ml.plugin.MachineLearningPlugin.EXECUTE_THREAD_POOL;
9-
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_ENABLE_MCORR;
9+
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL;
1010

1111
import lombok.extern.log4j.Log4j2;
1212

@@ -42,7 +42,7 @@ public class MLExecuteTaskRunner extends MLTaskRunner<MLExecuteTaskRequest, MLEx
4242
private final MLInputDatasetHandler mlInputDatasetHandler;
4343
protected final DiscoveryNodeHelper nodeHelper;
4444
private final MLEngine mlEngine;
45-
private volatile Boolean isMcorrEnabled;
45+
private volatile Boolean isPythonModelEnabled;
4646

4747
public MLExecuteTaskRunner(
4848
ThreadPool threadPool,
@@ -63,8 +63,10 @@ public MLExecuteTaskRunner(
6363
this.mlInputDatasetHandler = mlInputDatasetHandler;
6464
this.nodeHelper = nodeHelper;
6565
this.mlEngine = mlEngine;
66-
isMcorrEnabled = ML_COMMONS_ENABLE_MCORR.get(this.clusterService.getSettings());
67-
this.clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_ENABLE_MCORR, it -> isMcorrEnabled = it);
66+
isPythonModelEnabled = ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL.get(this.clusterService.getSettings());
67+
this.clusterService
68+
.getClusterSettings()
69+
.addSettingsUpdateConsumer(ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL, it -> isPythonModelEnabled = it);
6870
}
6971

7072
@Override
@@ -96,7 +98,7 @@ protected void executeTask(MLExecuteTaskRequest request, ActionListener<MLExecut
9698
Input input = request.getInput();
9799
FunctionName functionName = request.getFunctionName();
98100
if (FunctionName.METRICS_CORRELATION.equals(functionName)) {
99-
if (!isMcorrEnabled) {
101+
if (!isPythonModelEnabled) {
100102
Exception exception = new IllegalArgumentException("This algorithm is not enabled from settings");
101103
listener.onFailure(exception);
102104
return;

plugin/src/test/java/org/opensearch/ml/action/models/GetModelTransportActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void testGetModel_NullResponse() {
8080
getModelTransportAction.doExecute(null, mlModelGetRequest, actionListener);
8181
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
8282
verify(actionListener).onFailure(argumentCaptor.capture());
83-
assertEquals("Fail to find model", argumentCaptor.getValue().getMessage());
83+
assertEquals("Failed to find model with the provided model id: test_id", argumentCaptor.getValue().getMessage());
8484
}
8585

8686
public void testGetModel_RuntimeException() {

plugin/src/test/java/org/opensearch/ml/task/MLExecuteTaskRunnerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ public void setup() {
102102
settings = Settings.builder().put(ML_COMMONS_MAX_REGISTER_MODEL_TASKS_PER_NODE.getKey(), 10).build();
103103
settings = Settings.builder().put(ML_COMMONS_MONITORING_REQUEST_COUNT.getKey(), 10).build();
104104
settings = Settings.builder().put(ML_COMMONS_MAX_DEPLOY_MODEL_TASKS_PER_NODE.getKey(), 10).build();
105-
settings = Settings.builder().put(ML_COMMONS_ENABLE_MCORR.getKey(), false).build();
105+
settings = Settings.builder().put(ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL.getKey(), false).build();
106106
ClusterSettings clusterSettings = clusterSetting(
107107
settings,
108108
ML_COMMONS_MAX_MODELS_PER_NODE,
109109
ML_COMMONS_MAX_REGISTER_MODEL_TASKS_PER_NODE,
110110
ML_COMMONS_MONITORING_REQUEST_COUNT,
111111
ML_COMMONS_MAX_DEPLOY_MODEL_TASKS_PER_NODE,
112-
ML_COMMONS_ENABLE_MCORR
112+
ML_COMMONS_ENABLE_INHOUSE_PYTHON_MODEL
113113
);
114114
clusterService = spy(new ClusterService(settings, clusterSettings, null));
115115
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);

0 commit comments

Comments
 (0)