-
Notifications
You must be signed in to change notification settings - Fork 68
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
Block remote adapter url and handler override #1147
Conversation
@@ -92,6 +92,11 @@ public Input parseRequest(FullHttpRequest req, QueryStringDecoder decoder) { | |||
byte[] content = NettyUtils.getBytes(req.content()); | |||
input.add("data", content); | |||
} | |||
|
|||
if (input.getProperties().containsKey("handler")) { | |||
throw new BadRequestException("The handler can't be overridden in a request"); |
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.
Why we want to block handler override?
This at least should be an option (a global conf.properties) to disable handler override if we want disable it.
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.
I wrote a comment about this in slack
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.
@frankfliu If we want to support this, I think it should be a property to enable rather than disable. Do you know if we have users using custom handlers now?
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.
This was designed to allow user to call pre/postprocessing:
https://github.com/deepjavalibrary/djl-demo/tree/master/development/python
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.
We can default to disable handler override
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.
After more thought, I don't think it is something we want to support at all. But, here are two workarounds that give very similar results:
1 - Share model.py
We keep the ability to change the handler in the serving.properties
. Then, you can symlink the model.py around to share it. This will still result in different workers for the model and pre-post processing unless we change something.
2 - Sub-handler
subHandlers = {
"pre" : (lambda inputs: ...),
"m" : (lambda inputs: ...),
"post" : (lambda inputs: ...),
}
def handler(inputs):
return subHandlers[inputs.getProperty("subHandler")](inputs)
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.
I think we can leave this discussion for later. For now, I added an env/system prop ALLOW_REQUEST_HANDLER_OVERRIDE
to re-enable handler overrides
No description provided.