Skip to content

Commit

Permalink
format?
Browse files Browse the repository at this point in the history
  • Loading branch information
sauyon committed Oct 28, 2022
1 parent d46bf61 commit 95c7eb0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/bentoml/client.py
Expand Up @@ -31,8 +31,14 @@ def __init__(self, svc: Service, server_url: str):

for name, api in self._svc.apis.items():
if not hasattr(self, name):
setattr(self, name, functools.partial(self._sync_call, _bentoml_api=api))
setattr(self, f"async_{name}", functools.partial(self._call, _bentoml_api=api))
setattr(
self, name, functools.partial(self._sync_call, _bentoml_api=api)
)
setattr(
self,
f"async_{name}",
functools.partial(self._call, _bentoml_api=api),
)

def call(self, bentoml_api_name: str, inp: t.Any = None, **kwargs: t.Any) -> t.Any:
return asyncio.run(self.async_call(bentoml_api_name, inp))
Expand All @@ -42,7 +48,9 @@ async def async_call(
) -> t.Any:
return await self._call(inp, _bentoml_api=self._svc.apis[bentoml_api_name])

def _sync_call(self, inp: t.Any = None, *, _bentoml_api: InferenceAPI, **kwagrs: t.Any):
def _sync_call(
self, inp: t.Any = None, *, _bentoml_api: InferenceAPI, **kwagrs: t.Any
):
return asyncio.run(self._call(inp, _bentoml_api=_bentoml_api))

@abstractmethod
Expand Down

0 comments on commit 95c7eb0

Please sign in to comment.