Skip to content
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

Merged
merged 5 commits into from
Jun 12, 2020
Merged

Conversation

bojiang
Copy link
Member

@bojiang bojiang commented Jun 11, 2020

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation
  • Test, CI, or build
  • None

Components (if applicable)

  • BentoService (model packaging, dependency management, handler definition)
  • Model Artifact (model serialization, multi-framework support)
  • Model Server (mico-batching, logging, metrics, tracing, benchmark, OpenAPI)
  • YataiService (model management, deployment automation)
  • Documentation

Checklist:

  • My code follows the bentoml code style, both ./dev/format.sh and
    ./dev/lint.sh script have passed
    (instructions).
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • My change requires a change in bentoml/gallery example notebooks
  • I have sent a pull request to bentoml/gallery to make that change

TODOs:

  • Renaming all handler in docs
  • Add deprecated warnings for bentoml.handlers
  • Check config version while loading

@bojiang bojiang force-pushed the dev3 branch 2 times, most recently from 65dd92a to 477d891 Compare June 12, 2020 03:15
@codecov
Copy link

codecov bot commented Jun 12, 2020

Codecov Report

Merging #784 into master will increase coverage by 0.21%.
The diff coverage is 64.08%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
bentoml/adapters/pytorch_tensor_input.py 0.00% <0.00%> (ø)
bentoml/artifact/fastai_model_artifact.py 45.00% <ø> (ø)
bentoml/artifact/fasttext_model_artifact.py 43.33% <ø> (ø)
bentoml/artifact/h2o_model_artifact.py 41.17% <ø> (ø)
bentoml/artifact/keras_model_artifact.py 21.09% <ø> (ø)
bentoml/artifact/lightgbm_model_artifact.py 40.00% <ø> (ø)
bentoml/artifact/onnx_model_artifact.py 85.13% <ø> (ø)
bentoml/artifact/pytorch_model_artifact.py 85.36% <ø> (ø)
bentoml/artifact/sklearn_model_artifact.py 70.73% <ø> (ø)
bentoml/artifact/spacy_model_artifact.py 40.54% <ø> (ø)
... and 39 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb9a327...690bec8. Read the comment docs.

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]
Copy link
Member

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}>'
Copy link
Member

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?

Copy link
Contributor

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 }) => {

string docs = 3;
string output_type = 6;

// Configs for customizing BentoHandler
Copy link
Member

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"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

LegacyImageInput = LegacyImageHandler
FastaiImageInput = FastaiImageHandler

ClipperBytesInput = ClipperBytesHandler
Copy link
Member

@parano parano Jun 12, 2020

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, working in progress.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR

Copy link
Member

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")
 

@bojiang
Copy link
Member Author

bojiang commented Jun 12, 2020

@parano done. Let's leave deprecation warnings in next PR

@parano parano changed the title [Refactor] rename handlers to inputs [Refactor] rename API Handlers to Inputs Jun 12, 2020
@parano parano merged commit a134e3a into bentoml:master Jun 12, 2020
@parano
Copy link
Member

parano commented Jun 12, 2020

@yubozhao could you help test out Lambda and SageMaker deployment with this change?

aarnphm pushed a commit to aarnphm/BentoML that referenced this pull request Jul 29, 2022
* [Refactor] rename handlers to input adapters

* [Refactor] rename BentoHandler

* [FIX] renaming handler_type in frontend

* Rename ClipperHandlers and DataframeHandler

* Rename rest Handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants