fix(serve-grpc): clearer error when given a new-SDK service#5609
Open
saivedant169 wants to merge 1 commit into
Open
fix(serve-grpc): clearer error when given a new-SDK service#5609saivedant169 wants to merge 1 commit into
saivedant169 wants to merge 1 commit into
Conversation
`bentoml serve-grpc` accepts any importable target. When users point it
at a service defined with the `@bentoml.service` decorator (the
bentoml>=1.2 programming model) it fails with:
<class '_bentoml_sdk.service.factory.Service'> type doesn't support gRPC serving
That message is correct but unhelpful. gRPC is implemented only for the
legacy `bentoml.Service` API, and the new SDK has no gRPC code path, so
this case will not work and there is nothing the user can do beyond
switching transports or APIs.
Detect that situation explicitly in `serve_grpc_production` and raise a
message that names the new programming model, points the user at
`bentoml serve` for HTTP, and at the legacy `bentoml.Service` API if
they need gRPC. Unrelated types still fall through to the existing
generic error.
Adds a unit test that creates a temporary `@bentoml.service` definition,
calls `serve_grpc_production`, and asserts the new wording.
Closes bentoml#5607
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR address?
Fixes #5607
bentoml serve-grpcaccepts any importable target, including services defined with the@bentoml.servicedecorator (the bentoml>=1.2 programming model). gRPC is only implemented for the legacybentoml.ServiceAPI, so pointingserve-grpcat a new-SDK service fails with:The message is correct but unhelpful. The user has no way to tell from it that the new programming model has no gRPC path and that the fix is to switch transports or APIs.
Repro
After this PR
Changes
src/bentoml/serving.py: inserve_grpc_production, detect_bentoml_sdk.Serviceinstances explicitly and raise aBentoMLExceptionthat names the programming model and points at the two viable workarounds. Any other unrecognised type still falls through to the existing generic message.tests/unit/test_serve_grpc_new_sdk_error.py: writes a minimal@bentoml.servicedefinition into a tmp dir and assertsserve_grpc_productionraises the new wording.I did not implement gRPC for the new SDK in this PR. That is a feature, not a bug fix, and the
serve-grpcCLI is alreadyhidden=Truewhich suggests it is being phased out for new-style services.Before submitting:
fix:prefix)pre-commit run -ascript has passed? Yes, ran on changed files.