Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sauyon committed Oct 10, 2023
1 parent 3e1cd6b commit fc8b726
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/bentoml/_internal/client/http.py
Expand Up @@ -151,6 +151,7 @@ async def _call(
fake_resp = await api.input.to_http_response(kwargs, None)
else:
fake_resp = await api.input.to_http_response(inp, None)
req_body = fake_resp.body

# TODO: Temporary workaround before moving everything to StreamingResponse
if isinstance(fake_resp, starlette.responses.StreamingResponse):
Expand All @@ -159,7 +160,7 @@ async def _call(
req_body = fake_resp.body

resp = await self.client.post(
"/" + api.route if not api.route.startswith("/") else api.route,
api.route,
content=req_body,
headers={"content-type": fake_resp.headers["content-type"]},
)
Expand Down Expand Up @@ -302,10 +303,14 @@ def _call(
fake_resp = asyncio.run(api.input.to_http_response(inp, None))
req_body = fake_resp.body

# TODO: Temporary workaround before moving everything to StreamingResponse
if isinstance(fake_resp, starlette.responses.StreamingResponse):
req_body = "".join([s async for s in fake_resp.body_iterator])
else:
req_body = fake_resp.body

resp = self.client.post(
self.server_url + "/" + api.route
if not api.route.startswith("/")
else api.route,
api.route,
content=req_body,
headers={"content-type": fake_resp.headers["content-type"]},
)
Expand Down
2 changes: 2 additions & 0 deletions src/bentoml/client.py
Expand Up @@ -16,6 +16,7 @@

from ._internal.client import AsyncClient
from ._internal.client import Client
from ._internal.client import SyncClient
from ._internal.client.grpc import AsyncGrpcClient
from ._internal.client.grpc import GrpcClient
from ._internal.client.grpc import SyncGrpcClient
Expand All @@ -25,6 +26,7 @@

__all__ = [
"AsyncClient",
"SyncClient",
"Client",
"AsyncHTTPClient",
"SyncHTTPClient",
Expand Down

0 comments on commit fc8b726

Please sign in to comment.