Skip to content

Commit

Permalink
making Boolean type for isHidden (opensearch-project#2341)
Browse files Browse the repository at this point in the history
* making Boolean type for isHidden

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>

* added another Boolean

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>

---------

Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
  • Loading branch information
dhrubo-os authored and zane-neo committed Apr 21, 2024
1 parent e316005 commit 06773b4
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private void deleteControllerWithDeployedModel(String modelId, Boolean isHidden,
}
}

private void deleteController(String modelId, boolean isHidden, ActionListener<DeleteResponse> actionListener) {
private void deleteController(String modelId, Boolean isHidden, ActionListener<DeleteResponse> actionListener) {
DeleteRequest deleteRequest = new DeleteRequest(ML_CONTROLLER_INDEX, modelId);
client.delete(deleteRequest, new ActionListener<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void deployRemoteModel(
private ActionListener<MLDeployModelNodesResponse> deployModelNodesResponseListener(
String taskId,
String modelId,
boolean isHidden,
Boolean isHidden,
ActionListener<MLDeployModelResponse> listener
) {
return ActionListener.wrap(r -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
);
}
}, e -> {
log.error("Failed to validate Access for Model Id " + modelId, e);
log.error(getErrorMessage("Failed to validate Access", modelId, isHidden), e);
wrappedListener.onFailure(e);
}));
}
Expand All @@ -182,7 +182,7 @@ protected void doExecute(Task task, ActionRequest request, ActionListener<Delete
}

@VisibleForTesting
void deleteModelChunks(String modelId, boolean isHidden, ActionListener<Boolean> actionListener) {
void deleteModelChunks(String modelId, Boolean isHidden, ActionListener<Boolean> actionListener) {
DeleteByQueryRequest deleteModelsRequest = new DeleteByQueryRequest(ML_MODEL_INDEX);
deleteModelsRequest.setQuery(new TermsQueryBuilder(MODEL_ID_FIELD, modelId));

Expand Down Expand Up @@ -213,7 +213,7 @@ private void returnFailure(BulkByScrollResponse response, String modelId, Action
actionListener.onFailure(new OpenSearchStatusException(errorMessage, RestStatus.INTERNAL_SERVER_ERROR));
}

private void deleteModel(String modelId, boolean isHidden, ActionListener<DeleteResponse> actionListener) {
private void deleteModel(String modelId, Boolean isHidden, ActionListener<DeleteResponse> actionListener) {
DeleteRequest deleteRequest = new DeleteRequest(ML_MODEL_INDEX, modelId).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
client.delete(deleteRequest, new ActionListener<>() {
@Override
Expand All @@ -236,7 +236,7 @@ public void onFailure(Exception e) {
private void deleteModelChunksAndController(
ActionListener<DeleteResponse> actionListener,
String modelId,
boolean isHidden,
Boolean isHidden,
DeleteResponse deleteResponse
) {
CountDownLatch countDownLatch = new CountDownLatch(2);
Expand Down Expand Up @@ -286,7 +286,7 @@ private void deleteModelChunksAndController(
*
* @param modelId model ID
*/
private void deleteController(String modelId, boolean isHidden, ActionListener<Boolean> actionListener) {
private void deleteController(String modelId, Boolean isHidden, ActionListener<Boolean> actionListener) {
DeleteRequest deleteRequest = new DeleteRequest(ML_CONTROLLER_INDEX, modelId);
client.delete(deleteRequest, new ActionListener<>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ private void retrieveModelChunks(MLModel mlModelMeta, ActionListener<File> liste
* @param modelId model id
* @param updatedFields updated fields
*/
public void updateModel(String modelId, boolean isHidden, Map<String, Object> updatedFields) {
public void updateModel(String modelId, Boolean isHidden, Map<String, Object> updatedFields) {
updateModel(modelId, updatedFields, ActionListener.wrap(response -> {
if (response.status() == RestStatus.OK) {
log.debug(getErrorMessage("Updated ML model successfully: {}", modelId, isHidden), response.status());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void testCleanUpLocalCache_ExpiredMLTask_Register() {
when(mlTaskManager.getMLTaskCache(taskId)).thenReturn(taskCache);
action.cleanUpLocalCache(runningDeployModelTasks);
verify(mlTaskManager, times(1)).updateMLTask(anyString(), any(), anyLong(), anyBoolean());
verify(mlModelManager, never()).updateModel(anyString(), any(), any());
verify(mlModelManager, never()).updateModel(anyString(), (Boolean) any(), any());
}

public void testCleanUpLocalCache_ExpiredMLTask_Deploy_NullWorkerNode() {
Expand Down

0 comments on commit 06773b4

Please sign in to comment.