Skip to content

Commit

Permalink
change to a better method
Browse files Browse the repository at this point in the history
Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual committed Dec 4, 2024
1 parent eb33bd2 commit 6a38c2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import org.opensearch.common.inject.Inject;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.concurrent.ThreadContext;
import org.opensearch.common.xcontent.XContentHelper;
import org.opensearch.common.xcontent.json.JsonXContent;
import org.opensearch.commons.authuser.User;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.rest.RestStatus;
Expand All @@ -68,7 +70,6 @@
import org.opensearch.ml.common.transport.model.MLModelDeleteAction;
import org.opensearch.ml.common.transport.model.MLModelDeleteRequest;
import org.opensearch.ml.common.transport.model.MLModelGetRequest;
import org.opensearch.ml.common.utils.StringUtils;
import org.opensearch.ml.engine.utils.AgentModelsSearcher;
import org.opensearch.ml.helper.ModelAccessControlHelper;
import org.opensearch.ml.utils.RestActionUtils;
Expand Down Expand Up @@ -305,7 +306,7 @@ private void checkPipelineBeforeDeleteModel(
) {
ActionRequest request = requestSupplier.get();
client.execute(actionType, request, ActionListener.wrap(pipelineResponse -> {
Map<String, Object> allConfigMap = StringUtils.fromJson(pipelineResponse.toString(), "");
Map<String, Object> allConfigMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, pipelineResponse.toString(), true);
List<String> allDependentPipelineIds = findDependentPipelinesEasy(allConfigMap, modelId);
if (allDependentPipelineIds.isEmpty()) {
actionListener.onResponse(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void testDeleteModel_BlockedByIngestPipeline() throws IOException {
public void testDeleteModel_BlockedByAgent() throws IOException {
XContentBuilder content = XContentBuilder.builder(XContentType.JSON.xContent());
content.startObject();
content.field(MLAgent.IS_HIDDEN_FIELD, "false");
content.field(MLAgent.IS_HIDDEN_FIELD, false);
content.endObject();
SearchHit hit = new SearchHit(1, "1", null, null).sourceRef(BytesReference.bytes(content));
SearchHits searchHits = new SearchHits(new SearchHit[] { hit }, new TotalHits(1, TotalHits.Relation.EQUAL_TO), 1.0f);
Expand Down

0 comments on commit 6a38c2b

Please sign in to comment.