Slackbot
10/20/2022, 7:25 PMSudeep Ghimire
10/21/2022, 1:21 AMJiang
10/21/2022, 2:28 AMdemo_img_loader as a Pickleable model, correct?Jiang
10/21/2022, 2:36 AMdemo_img_loader is a bare Python async function, you can await call it directly in the endpoint (the predict function). If it is a sync function, you may make your endpoint a sync function and call it directly.Sudeep Ghimire
10/21/2022, 10:08 AM@router.post("/analyze")
async def predict(inference_request: InferenceRequest):
pil_img: Image = await async_load_image_internal(inference_request.s3Path)
print('-------Main----')
print(pil_img.is_loaded_by_image_loader)
print(pil_img.loading_status)
print('-------')
results = await asyncio.gather(
demo_runner1.infer.async_run(pil_image), demo_runner2.infer.async_run(pil_image),
demo_runner3.infer.async_run(pil_image)
)
return results
image loaded by async_load_image_internal has correct attributes for is_loaded_by_image_loader and loading_status when checking in the logic for the service endpoint, but check the same in the infer methods for the runners fails. Really getting out of ideas to resolve the issue.
Is it because of the case that endpoint is defined @router.post("/analyze") i.e. decorator for router from fastapi ( instead of using the decorator @svc.api) and registered in service.py as
fastapi_app = FastAPI()
fastapi_app.include_router(inference_router)
svc = bentoml.Service("demo_abc",
runners=[demo_runner1, demo_runner2, demo_runner3])
svc.mount_asgi_app(fastapi_app)Sudeep Ghimire
10/21/2022, 10:20 AMinfer method of individual runners then it works as expected. But loading initially in the part of the endpoint defn and passing pil image to the infer method of runners is not workingJiang
10/21/2022, 5:44 PMis_loaded_by_image_loader attribute. So the class of pil_img here is a custom class?Jiang
10/21/2022, 5:50 PM