-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable auto redeploy for hidden model #2102
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,24 +38,29 @@ public class MLDeployModelRequest extends MLTaskRequest { | |
private String modelId; | ||
private String[] modelNodeIds; | ||
boolean async; | ||
// This is to identify if the get request is initiated by user or not. During auto redeploy, we also perform deploy operation. This field is to distinguish between | ||
// these two situations. | ||
private final boolean isUserInitiatedDeployRequest; | ||
|
||
@Builder | ||
public MLDeployModelRequest(String modelId, String[] modelNodeIds, boolean async, boolean dispatchTask) { | ||
public MLDeployModelRequest(String modelId, String[] modelNodeIds, boolean async, boolean dispatchTask, boolean isUserInitiatedDeployRequest) { | ||
super(dispatchTask); | ||
this.modelId = modelId; | ||
this.modelNodeIds = modelNodeIds; | ||
this.async = async; | ||
this.isUserInitiatedDeployRequest = isUserInitiatedDeployRequest; | ||
} | ||
|
||
public MLDeployModelRequest(String modelId, boolean async) { | ||
this(modelId, null, async, true); | ||
this(modelId, null, async, true, true); | ||
} | ||
|
||
public MLDeployModelRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.modelId = in.readString(); | ||
this.modelNodeIds = in.readOptionalStringArray(); | ||
this.async = in.readBoolean(); | ||
this.isUserInitiatedDeployRequest = in.readOptionalBoolean(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why optionalboolean? what'll happen if the value isn't present? |
||
} | ||
|
||
@Override | ||
|
@@ -74,6 +79,7 @@ public void writeTo(StreamOutput out) throws IOException { | |
out.writeString(modelId); | ||
out.writeOptionalStringArray(modelNodeIds); | ||
out.writeBoolean(async); | ||
out.writeOptionalBoolean(isUserInitiatedDeployRequest); | ||
} | ||
|
||
public static MLDeployModelRequest parse(XContentParser parser, String modelId) throws IOException { | ||
|
@@ -96,7 +102,7 @@ public static MLDeployModelRequest parse(XContentParser parser, String modelId) | |
} | ||
} | ||
String[] nodeIds = nodeIdList == null ? null : nodeIdList.toArray(new String[0]); | ||
return new MLDeployModelRequest(modelId, nodeIds, false, true); | ||
return new MLDeployModelRequest(modelId, nodeIds, false, true, true); | ||
} | ||
|
||
public static MLDeployModelRequest fromActionRequest(ActionRequest actionRequest) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -857,7 +857,7 @@ private void updateModelRegisterStateAsDone( | |
void deployModelAfterRegistering(MLRegisterModelInput registerModelInput, String modelId) { | ||
String[] modelNodeIds = registerModelInput.getModelNodeIds(); | ||
log.debug("start deploying model after registering, modelId: {} on nodes: {}", modelId, Arrays.toString(modelNodeIds)); | ||
MLDeployModelRequest request = new MLDeployModelRequest(modelId, modelNodeIds, false, true); | ||
MLDeployModelRequest request = new MLDeployModelRequest(modelId, modelNodeIds, false, true, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if user define a flow template with deploy hidden model action in it ? Can user deploy any hidden model? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't hidden model management (register, deploy, undeploy, delete) is out of scope for AI-Flow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a flow template, we will still consider it as user initiated right. So we will still check for access. Only if it is system initiated, we will bypass the access checks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes for normal process, but that's not a hard control. User can copy the hidden model id and define a flow template to deploy it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can user see the hidden model id? I thought only superAdmin can see it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
model id isn't hidden to users. But model content is hidden to users. During prediction, model id is being used. As user can make the prediction request, they can know the model id eventually. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We opened this deploy request to clients and then user initiated request flag is being set to true from code. So every request sent from ai-flow or any other clients should be treated as user initiated request too. |
||
ActionListener<MLDeployModelResponse> listener = ActionListener | ||
.wrap(r -> log.debug("model deployed, response {}", r), e -> log.error("Failed to deploy model", e)); | ||
client.execute(MLDeployModelAction.INSTANCE, request, listener); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,6 +286,7 @@ public void testDoExecute_no_permission_hidden_model() { | |
MLModel mlModel = mock(MLModel.class); | ||
when(mlModel.getAlgorithm()).thenReturn(FunctionName.ANOMALY_LOCALIZATION); | ||
when(mlModel.getIsHidden()).thenReturn(true); | ||
when(mlDeployModelRequest.isUserInitiatedDeployRequest()).thenReturn(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add unit test to cover |
||
doAnswer(invocation -> { | ||
ActionListener<MLModel> listener = invocation.getArgument(3); | ||
listener.onResponse(mlModel); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] may be add a comment why here
isUserInitiatedDeployRequest
will always be true?