Skip to content

Commit

Permalink
apply spotless
Browse files Browse the repository at this point in the history
Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual committed Nov 19, 2024
1 parent 525926f commit 5c1b3da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,24 +291,23 @@ private void checkIngestPipelineBeforeDeleteModel(String modelId, ActionListener
GetPipelineRequest getPipelineRequest = new GetPipelineRequest();
client.execute(GetPipelineAction.INSTANCE, getPipelineRequest, ActionListener.wrap(ingestPipelineResponse -> {
List<String> allRelevantPipelineIds = findRelevantPipelines(
ingestPipelineResponse.pipelines(),
modelId,
org.opensearch.ingest.PipelineConfiguration::getConfigAsMap,
org.opensearch.ingest.PipelineConfiguration::getId
ingestPipelineResponse.pipelines(),
modelId,
org.opensearch.ingest.PipelineConfiguration::getConfigAsMap,
org.opensearch.ingest.PipelineConfiguration::getId
);
if (allRelevantPipelineIds.isEmpty()) {
actionListener.onResponse(true);
}
else {
} else {
actionListener
.onFailure(
new OpenSearchStatusException(
allRelevantPipelineIds.size()
+ " ingest pipelines are still using this model, please delete or update the pipelines first: "
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
RestStatus.CONFLICT
)
);
.onFailure(
new OpenSearchStatusException(
allRelevantPipelineIds.size()
+ " ingest pipelines are still using this model, please delete or update the pipelines first: "
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
RestStatus.CONFLICT
)
);
}
}, e -> {
log.error("Failed to delete ML Model: " + modelId, e);
Expand All @@ -322,24 +321,23 @@ private void checkSearchPipelineBeforeDeleteModel(String modelId, ActionListener
GetSearchPipelineRequest getSearchPipelineRequest = new GetSearchPipelineRequest();
client.execute(GetSearchPipelineAction.INSTANCE, getSearchPipelineRequest, ActionListener.wrap(searchPipelineResponse -> {
List<String> allRelevantPipelineIds = findRelevantPipelines(
searchPipelineResponse.pipelines(),
modelId,
org.opensearch.search.pipeline.PipelineConfiguration::getConfigAsMap,
org.opensearch.search.pipeline.PipelineConfiguration::getId
searchPipelineResponse.pipelines(),
modelId,
org.opensearch.search.pipeline.PipelineConfiguration::getConfigAsMap,
org.opensearch.search.pipeline.PipelineConfiguration::getId
);
if (allRelevantPipelineIds.isEmpty()) {
actionListener.onResponse(true);
}
else {
} else {
actionListener
.onFailure(
new OpenSearchStatusException(
allRelevantPipelineIds.size()
+ " search pipelines are still using this model, please delete or update the pipelines first: "
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
RestStatus.CONFLICT
)
);
.onFailure(
new OpenSearchStatusException(
allRelevantPipelineIds.size()
+ " search pipelines are still using this model, please delete or update the pipelines first: "
+ Arrays.toString(allRelevantPipelineIds.toArray(new String[0])),
RestStatus.CONFLICT
)
);
}
}, e -> {
log.error("Failed to delete ML Model: " + modelId, e);
Expand Down Expand Up @@ -513,7 +511,6 @@ private Boolean searchThroughConfig(Object searchCandidate, String candidateId,
return flag;
}


// this method is only to stub static method.
@VisibleForTesting
boolean isSuperAdminUserWrapper(ClusterService clusterService, Client client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ public void testDeleteModel_BlockedByIngestPipeline() throws IOException {
);

org.opensearch.ingest.PipelineConfiguration irrelevantIngestPipelineConfiguration = new org.opensearch.ingest.PipelineConfiguration(
"2",
new BytesArray("{\"nothing\": \"test_id\"}".getBytes(StandardCharsets.UTF_8)),
MediaTypeRegistry.JSON
"2",
new BytesArray("{\"nothing\": \"test_id\"}".getBytes(StandardCharsets.UTF_8)),
MediaTypeRegistry.JSON
);

when(getIngestionPipelineResponse.pipelines()).thenReturn(List.of(ingestPipelineConfiguration, irrelevantIngestPipelineConfiguration));
when(getIngestionPipelineResponse.pipelines())
.thenReturn(List.of(ingestPipelineConfiguration, irrelevantIngestPipelineConfiguration));
doAnswer(invocation -> {
ActionListener<GetPipelineResponse> listener = invocation.getArgument(2);
listener.onResponse(getIngestionPipelineResponse);
Expand Down

0 comments on commit 5c1b3da

Please sign in to comment.