Skip to content

Commit 493e394

Browse files
Signed-off-by: Xun Zhang <xunzh@amazon.com> (cherry picked from commit 848abf6) Co-authored-by: Xun Zhang <xunzh@amazon.com>
1 parent c5c4e61 commit 493e394

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plugin/src/main/java/org/opensearch/ml/task/MLPredictTaskRunner.java

+17
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ public void dispatchTask(
148148
if (FunctionName.isAutoDeployEnabled(autoDeploymentEnabled, functionName)) {
149149
try (ThreadContext.StoredContext context = client.threadPool().getThreadContext().stashContext()) {
150150
mlModelManager.getModel(modelId, ActionListener.runBefore(ActionListener.wrap(model -> {
151+
if (!checkModelAutoDeployEnabled(model)) {
152+
log.info("Auto deployment disabled for model {}, please deploy model first", modelId);
153+
listener
154+
.onFailure(
155+
new IllegalArgumentException(
156+
"Model not ready yet. Please run this first: POST /_plugins/_ml/models/" + modelId + "/_deploy"
157+
)
158+
);
159+
return;
160+
}
151161
String[] planningWorkerNodes = model.getPlanningWorkerNodes();
152162
MLModel modelBeingAutoDeployed = mlModelManager.addModelToAutoDeployCache(modelId, model);
153163
if (modelBeingAutoDeployed == model) {
@@ -241,6 +251,13 @@ protected void executeTask(MLPredictionTaskRequest request, ActionListener<MLTas
241251
}
242252
}
243253

254+
private boolean checkModelAutoDeployEnabled(MLModel mlModel) {
255+
if (mlModel.getDeploySetting() == null) {
256+
return true;
257+
}
258+
return mlModel.getDeploySetting().getIsAutoDeployEnabled();
259+
}
260+
244261
private String getPredictThreadPool(FunctionName functionName) {
245262
return functionName == FunctionName.REMOTE ? REMOTE_PREDICT_THREAD_POOL : PREDICT_THREAD_POOL;
246263
}

0 commit comments

Comments
 (0)