Skip to content

Commit 5c1b3da

Browse files
committed
apply spotless
Signed-off-by: xinyual <xinyual@amazon.com>
1 parent 525926f commit 5c1b3da

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

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

+26-29
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,23 @@ private void checkIngestPipelineBeforeDeleteModel(String modelId, ActionListener
291291
GetPipelineRequest getPipelineRequest = new GetPipelineRequest();
292292
client.execute(GetPipelineAction.INSTANCE, getPipelineRequest, ActionListener.wrap(ingestPipelineResponse -> {
293293
List<String> allRelevantPipelineIds = findRelevantPipelines(
294-
ingestPipelineResponse.pipelines(),
295-
modelId,
296-
org.opensearch.ingest.PipelineConfiguration::getConfigAsMap,
297-
org.opensearch.ingest.PipelineConfiguration::getId
294+
ingestPipelineResponse.pipelines(),
295+
modelId,
296+
org.opensearch.ingest.PipelineConfiguration::getConfigAsMap,
297+
org.opensearch.ingest.PipelineConfiguration::getId
298298
);
299299
if (allRelevantPipelineIds.isEmpty()) {
300300
actionListener.onResponse(true);
301-
}
302-
else {
301+
} else {
303302
actionListener
304-
.onFailure(
305-
new OpenSearchStatusException(
306-
allRelevantPipelineIds.size()
307-
+ " ingest pipelines are still using this model, please delete or update the pipelines first: "
308-
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
309-
RestStatus.CONFLICT
310-
)
311-
);
303+
.onFailure(
304+
new OpenSearchStatusException(
305+
allRelevantPipelineIds.size()
306+
+ " ingest pipelines are still using this model, please delete or update the pipelines first: "
307+
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
308+
RestStatus.CONFLICT
309+
)
310+
);
312311
}
313312
}, e -> {
314313
log.error("Failed to delete ML Model: " + modelId, e);
@@ -322,24 +321,23 @@ private void checkSearchPipelineBeforeDeleteModel(String modelId, ActionListener
322321
GetSearchPipelineRequest getSearchPipelineRequest = new GetSearchPipelineRequest();
323322
client.execute(GetSearchPipelineAction.INSTANCE, getSearchPipelineRequest, ActionListener.wrap(searchPipelineResponse -> {
324323
List<String> allRelevantPipelineIds = findRelevantPipelines(
325-
searchPipelineResponse.pipelines(),
326-
modelId,
327-
org.opensearch.search.pipeline.PipelineConfiguration::getConfigAsMap,
328-
org.opensearch.search.pipeline.PipelineConfiguration::getId
324+
searchPipelineResponse.pipelines(),
325+
modelId,
326+
org.opensearch.search.pipeline.PipelineConfiguration::getConfigAsMap,
327+
org.opensearch.search.pipeline.PipelineConfiguration::getId
329328
);
330329
if (allRelevantPipelineIds.isEmpty()) {
331330
actionListener.onResponse(true);
332-
}
333-
else {
331+
} else {
334332
actionListener
335-
.onFailure(
336-
new OpenSearchStatusException(
337-
allRelevantPipelineIds.size()
338-
+ " search pipelines are still using this model, please delete or update the pipelines first: "
339-
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
340-
RestStatus.CONFLICT
341-
)
342-
);
333+
.onFailure(
334+
new OpenSearchStatusException(
335+
allRelevantPipelineIds.size()
336+
+ " search pipelines are still using this model, please delete or update the pipelines first: "
337+
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
338+
RestStatus.CONFLICT
339+
)
340+
);
343341
}
344342
}, e -> {
345343
log.error("Failed to delete ML Model: " + modelId, e);
@@ -513,7 +511,6 @@ private Boolean searchThroughConfig(Object searchCandidate, String candidateId,
513511
return flag;
514512
}
515513

516-
517514
// this method is only to stub static method.
518515
@VisibleForTesting
519516
boolean isSuperAdminUserWrapper(ClusterService clusterService, Client client) {

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,13 @@ public void testDeleteModel_BlockedByIngestPipeline() throws IOException {
248248
);
249249

250250
org.opensearch.ingest.PipelineConfiguration irrelevantIngestPipelineConfiguration = new org.opensearch.ingest.PipelineConfiguration(
251-
"2",
252-
new BytesArray("{\"nothing\": \"test_id\"}".getBytes(StandardCharsets.UTF_8)),
253-
MediaTypeRegistry.JSON
251+
"2",
252+
new BytesArray("{\"nothing\": \"test_id\"}".getBytes(StandardCharsets.UTF_8)),
253+
MediaTypeRegistry.JSON
254254
);
255255

256-
when(getIngestionPipelineResponse.pipelines()).thenReturn(List.of(ingestPipelineConfiguration, irrelevantIngestPipelineConfiguration));
256+
when(getIngestionPipelineResponse.pipelines())
257+
.thenReturn(List.of(ingestPipelineConfiguration, irrelevantIngestPipelineConfiguration));
257258
doAnswer(invocation -> {
258259
ActionListener<GetPipelineResponse> listener = invocation.getArgument(2);
259260
listener.onResponse(getIngestionPipelineResponse);

0 commit comments

Comments
 (0)