Skip to content

Commit

Permalink
check model auto deploy (#2288) (#2290)
Browse files Browse the repository at this point in the history
Signed-off-by: Xun Zhang <[email protected]>
(cherry picked from commit 848abf6)

Co-authored-by: Xun Zhang <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and Zhangxunmt authored Mar 27, 2024
1 parent c5c4e61 commit 493e394
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ public void dispatchTask(
if (FunctionName.isAutoDeployEnabled(autoDeploymentEnabled, functionName)) {
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
mlModelManager.getModel(modelId, ActionListener.runBefore(ActionListener.wrap(model -> {
if (!checkModelAutoDeployEnabled(model)) {
log.info("Auto deployment disabled for model {}, please deploy model first", modelId);
listener
.onFailure(
new IllegalArgumentException(
"Model not ready yet. Please run this first: POST /_plugins/_ml/models/" + modelId + "/_deploy"
)
);
return;
}
String[] planningWorkerNodes = model.getPlanningWorkerNodes();
MLModel modelBeingAutoDeployed = mlModelManager.addModelToAutoDeployCache(modelId, model);
if (modelBeingAutoDeployed == model) {
Expand Down Expand Up @@ -241,6 +251,13 @@ protected void executeTask(MLPredictionTaskRequest request, ActionListener<MLTas
}
}

private boolean checkModelAutoDeployEnabled(MLModel mlModel) {
if (mlModel.getDeploySetting() == null) {
return true;
}
return mlModel.getDeploySetting().getIsAutoDeployEnabled();
}

private String getPredictThreadPool(FunctionName functionName) {
return functionName == FunctionName.REMOTE ? REMOTE_PREDICT_THREAD_POOL : PREDICT_THREAD_POOL;
}
Expand Down

0 comments on commit 493e394

Please sign in to comment.