Skip to content

Commit

Permalink
Add unit test for TransportUpdateModelAction class
Browse files Browse the repository at this point in the history
Signed-off-by: Sicheng Song <[email protected]>
  • Loading branch information
b4sjoo committed Sep 23, 2023
1 parent 032579b commit ac48986
Show file tree
Hide file tree
Showing 2 changed files with 263 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,25 +223,6 @@ private void updateRemoteOrTextEmbeddingModel(
}
}

private ActionListener<UpdateResponse> getUpdateResponseListener(
String modelId,
ActionListener<UpdateResponse> actionListener,
ThreadContext.StoredContext context
) {
return ActionListener.runBefore(ActionListener.wrap(updateResponse -> {
if (updateResponse != null && updateResponse.getResult() != DocWriteResponse.Result.UPDATED) {
log.info("Model id:{} failed update", modelId);
actionListener.onResponse(updateResponse);
return;
}
log.info("Completed Update Model Request, model id:{} updated", modelId);
actionListener.onResponse(updateResponse);
}, exception -> {
log.error("Failed to update ML model: " + modelId, exception);
actionListener.onFailure(exception);
}), context::restore);
}

private void updateModelWithOrWithoutRelinkModelGroup(
String modelId,
String relinkModelGroupId,
Expand Down Expand Up @@ -271,4 +252,23 @@ private void updateModelWithOrWithoutRelinkModelGroup(
client.update(updateRequest, getUpdateResponseListener(modelId, actionListener, context));
}
}

private ActionListener<UpdateResponse> getUpdateResponseListener(
String modelId,
ActionListener<UpdateResponse> actionListener,
ThreadContext.StoredContext context
) {
return ActionListener.runBefore(ActionListener.wrap(updateResponse -> {
if (updateResponse != null && updateResponse.getResult() != DocWriteResponse.Result.UPDATED) {
log.info("Model id:{} failed update", modelId);
actionListener.onResponse(updateResponse);
return;
}
log.info("Completed Update Model Request, model id:{} updated", modelId);
actionListener.onResponse(updateResponse);
}, exception -> {
log.error("Failed to update ML model: " + modelId, exception);
actionListener.onFailure(exception);
}), context::restore);
}
}
Loading

0 comments on commit ac48986

Please sign in to comment.