Skip to content

Commit

Permalink
rename setting and add comment
Browse files Browse the repository at this point in the history
Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual committed Jan 17, 2025
1 parent 7794944 commit 6d5ae9c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
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_SAFE_DELETE_MODEL;
import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK;
import static org.opensearch.ml.utils.MLNodeUtils.createXContentParserFromRegistry;
import static org.opensearch.ml.utils.RestActionUtils.getFetchSourceContext;

Expand Down Expand Up @@ -122,8 +122,8 @@ public DeleteModelTransportAction(
this.modelAccessControlHelper = modelAccessControlHelper;
this.agentModelsSearcher = agentModelsSearcher;
this.settings = settings;
isSafeDelete = ML_COMMONS_SAFE_DELETE_MODEL.get(settings);
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_SAFE_DELETE_MODEL, it -> isSafeDelete = it);
isSafeDelete = ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK.get(settings);
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK, it -> isSafeDelete = it);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,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_WITH_USAGE_CHECK,
MLCommonsSettings.ML_COMMONS_MULTI_TENANCY_ENABLED,
MLCommonsSettings.REMOTE_METADATA_TYPE,
MLCommonsSettings.REMOTE_METADATA_ENDPOINT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ private MLCommonsSettings() {}
public static final Setting<Boolean> ML_COMMONS_CONTROLLER_ENABLED = Setting
.boolSetting("plugins.ml_commons.controller_enabled", true, Setting.Property.NodeScope, Setting.Property.Dynamic);

public static final Setting<Boolean> ML_COMMONS_SAFE_DELETE_MODEL = Setting
//This flag is the determine whether we need to check downstream task before deleting a model.
public static final Setting<Boolean> ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK = Setting
.boolSetting("plugins.ml_commons.safe_delete_model", false, Setting.Property.NodeScope, Setting.Property.Dynamic);
/**
* Indicates whether multi-tenancy is enabled in ML Commons.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +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_WITH_USAGE_CHECK.getKey(), true).build();
threadContext = new ThreadContext(settings);
ClusterSettings clusterSettings = clusterSetting(settings, ML_COMMONS_SAFE_DELETE_MODEL);
ClusterSettings clusterSettings = clusterSetting(settings, ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK);
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
when(clusterService.getSettings()).thenReturn(settings);
deleteModelTransportAction = spy(
Expand Down Expand Up @@ -306,9 +306,9 @@ public void testDeleteModel_BlockedBySearchPipelineListModelId() throws IOExcept
}

public void testDeleteModel_UseSettingToSkipBlockedByIngestPipeline() throws IOException {
Settings settings = Settings.builder().put(ML_COMMONS_SAFE_DELETE_MODEL.getKey(), false).build();
Settings settings = Settings.builder().put(ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK.getKey(), false).build();
threadContext = new ThreadContext(settings);
ClusterSettings clusterSettings = clusterSetting(settings, ML_COMMONS_SAFE_DELETE_MODEL);
ClusterSettings clusterSettings = clusterSetting(settings, ML_COMMONS_SAFE_DELETE_WITH_USAGE_CHECK);
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
when(clusterService.getSettings()).thenReturn(settings);
deleteModelTransportAction = spy(
Expand Down

0 comments on commit 6d5ae9c

Please sign in to comment.