-
Notifications
You must be signed in to change notification settings - Fork 754
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
[Refactor] rename API Handlers to Inputs #784
Conversation
65dd92a
to
477d891
Compare
Codecov Report
@@ Coverage Diff @@
## master #784 +/- ##
==========================================
+ Coverage 55.53% 55.75% +0.21%
==========================================
Files 108 114 +6
Lines 8144 8346 +202
==========================================
+ Hits 4523 4653 +130
- Misses 3621 3693 +72
Continue to review full report at Codecov.
|
bentoml/clipper/__init__.py
Outdated
raise BentoMLException( | ||
"Only BentoService APIs using ClipperHandler can be deployed to Clipper" | ||
) | ||
|
||
input_type = HANDLER_TYPE_TO_INPUT_TYPE[api_metadata.handler_type] | ||
input_type = HANDLER_TYPE_TO_INPUT_TYPE[api_metadata.input_type] |
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.
maybe change this to something like to_clipper_input_type(api_metadata.input_type
and CLIPPER_INPUTS
?
@@ -47,7 +47,7 @@ def _print_bento_table(bentos, wide=False): | |||
for artifact in bento.bento_service_metadata.artifacts | |||
] | |||
apis = [ | |||
f'{api.name}<{api.handler_type}>' | |||
f'{api.name}<{api.input_type}:{api.output_type}>' |
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 may also need to update the Web UI for this, @yubozhao could you help identify the files that need similar change?
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.
Yep.
We would need to update the table view here:
return apis.map((api) => `${api.name}<${api.handler_type}>`).join("\n"); |
and the API table:
const ApisTable: React.FC<{ apis: Array<IApiProps> }> = ({ apis }) => { |
protos/repository.proto
Outdated
string docs = 3; | ||
string output_type = 6; | ||
|
||
// Configs for customizing BentoHandler |
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.
Also update the inline docs here?
def predict_dataframe(self, df): | ||
"""predict_dataframe expects dataframe as input | ||
""" | ||
return self.artifacts.model.predict_dataframe(df) | ||
|
||
@bentoml.api(DataframeHandler, input_dtypes={"col1": "int"}) | ||
@bentoml.api(DataframeInput, input_dtypes={"col1": "int"}) |
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.
👍
bentoml/adapters/__init__.py
Outdated
LegacyImageInput = LegacyImageHandler | ||
FastaiImageInput = FastaiImageHandler | ||
|
||
ClipperBytesInput = ClipperBytesHandler |
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.
Maybe make it the other way around?
E.g. rename ImageHandler class to ImageInput, and add ImageHandler = ImageInput
here?
It will be easier to deprecate those alias later on, and easier to new contributors to understand the codebase.
Let me know if you plan to do that in a separate PR
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.
Yeah, working in progress.
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.
In this PR
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.
Actually, would be nice to add a deprecation warning when the user is using the "handler" APIs. Would something like this work?
class ImageHandler(ImageInput):
""" backwards compatible alias ..... """
def __init__(...):
super...
logger.warning("will be deprecated .... use ImageInput")
@parano done. Let's leave deprecation warnings in next PR |
@yubozhao could you help test out Lambda and SageMaker deployment with this change? |
* [Refactor] rename handlers to input adapters * [Refactor] rename BentoHandler * [FIX] renaming handler_type in frontend * Rename ClipperHandlers and DataframeHandler * Rename rest Handlers
Description
Motivation and Context
How Has This Been Tested?
Types of changes
Components (if applicable)
Checklist:
./dev/format.sh
and./dev/lint.sh
script have passed(instructions).
TODOs:
handler
in docsbentoml.handlers