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

Allow to use custom handlers from pip packages #981

Open
hal-314 opened this issue Feb 25, 2021 · 0 comments
Open

Allow to use custom handlers from pip packages #981

hal-314 opened this issue Feb 25, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@hal-314
Copy link

hal-314 commented Feb 25, 2021

First of all, many thanks for developing TorchServe!

Is your feature request related to a problem? Please describe.

You need to specify a file to use a custom handler.

This requirements prevents for code reusing. For example, your custom handler can't extend other custom handlers. Also, helper classes or custom transforms must be defined in the same file and can't be reused by other handlers.

Describe the solution

Allow to use handlers implemented in a Pypi package. So, torchserve --handler you allow to pass the import route to the handler. The value would need to be a valid import route that can be dynamically loaded with importlib library.

Example: torchserve --handler my_package.hander.custom_handler.CustomHandler

Describe alternatives solution

There are two alternative solutions:

  • Do not use pypi package use --extra-files to pass extra python files. See this comment. However, user must be careful on adding of necessary files.
  • Use a pypi package and pass to torchserve --handler handler file path as usual. This is how I do it currently.
@chauhang chauhang added the enhancement New feature or request label Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants