Skip to content

Commit

Permalink
apply spot less
Browse files Browse the repository at this point in the history
Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual committed Dec 17, 2024
1 parent b472292 commit 8ef451e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import static org.opensearch.ml.common.MLModel.IS_HIDDEN_FIELD;
import static org.opensearch.ml.common.MLModel.MODEL_ID_FIELD;
import static org.opensearch.ml.common.utils.StringUtils.getErrorMessage;
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_ALLOW_MODEL_URL;
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_SAFE_DELETE_MODEL;
import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry;
import static org.opensearch.ml.utils.RestActionUtils.getFetchSourceContext;
Expand Down Expand Up @@ -164,8 +163,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
if (isModelNotDeployed(mlModelState)) {
if (isSafeDelete) {
checkDownstreamTaskBeforeDeleteModel(modelId, isHidden, actionListener);
}
else {
} else {
deleteModel(modelId, isHidden, actionListener);
}
} else {
Expand All @@ -192,8 +190,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
} else if (isModelNotDeployed(mlModelState)) {
if (isSafeDelete) {
checkDownstreamTaskBeforeDeleteModel(modelId, isHidden, actionListener);
}
else {
} else {
deleteModel(modelId, isHidden, actionListener);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ public List<Setting<?>> getSettings() {
MLCommonsSettings.ML_COMMONS_MAX_BATCH_INFERENCE_TASKS,
MLCommonsSettings.ML_COMMONS_MAX_BATCH_INGESTION_TASKS,
MLCommonsSettings.ML_COMMONS_BATCH_INGESTION_BULK_SIZE,
MLCommonsSettings.ML_COMMONS_SAFE_DELETE_MODEL
MLCommonsSettings.ML_COMMONS_SAFE_DELETE_MODEL
);
return settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,5 @@ private MLCommonsSettings() {}
.boolSetting("plugins.ml_commons.controller_enabled", true, Setting.Property.NodeScope, Setting.Property.Dynamic);

public static final Setting<Boolean> ML_COMMONS_SAFE_DELETE_MODEL = Setting
.boolSetting("plugins.ml_commons.safe_delete_model", true, Setting.Property.NodeScope, Setting.Property.Dynamic);
.boolSetting("plugins.ml_commons.safe_delete_model", true, Setting.Property.NodeScope, Setting.Property.Dynamic);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static org.opensearch.ml.action.models.DeleteModelTransportAction.TIMEOUT_MSG;
import static org.opensearch.ml.common.CommonValue.ML_MODEL_INDEX;
import static org.opensearch.ml.settings.MLCommonsSettings.*;
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_TRUSTED_CONNECTOR_ENDPOINTS_REGEX;
import static org.opensearch.ml.utils.TestHelper.clusterSetting;

import java.io.IOException;
Expand Down Expand Up @@ -67,7 +66,6 @@
import org.opensearch.index.reindex.BulkByScrollResponse;
import org.opensearch.index.reindex.DeleteByQueryAction;
import org.opensearch.index.reindex.ScrollableHitSource;
import org.opensearch.ml.action.register.TransportRegisterModelAction;
import org.opensearch.ml.common.FunctionName;
import org.opensearch.ml.common.MLModel;
import org.opensearch.ml.common.agent.MLAgent;
Expand Down Expand Up @@ -150,15 +148,9 @@ public void setup() throws IOException {

mlModelDeleteRequest = MLModelDeleteRequest.builder().modelId("test_id").build();

Settings settings = Settings
.builder()
.put(ML_COMMONS_SAFE_DELETE_MODEL.getKey(), true)
.build();
Settings settings = Settings.builder().put(ML_COMMONS_SAFE_DELETE_MODEL.getKey(), true).build();
threadContext = new ThreadContext(settings);
ClusterSettings clusterSettings = clusterSetting(
settings,
ML_COMMONS_SAFE_DELETE_MODEL
);
ClusterSettings clusterSettings = clusterSetting(settings, ML_COMMONS_SAFE_DELETE_MODEL);
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
when(clusterService.getSettings()).thenReturn(settings);
deleteModelTransportAction = spy(
Expand Down

0 comments on commit 8ef451e

Please sign in to comment.