streamlit-fastapi-model-serving icon indicating copy to clipboard operation
streamlit-fastapi-model-serving copied to clipboard

Streamlit requests may fail if FastAPI backend hasn't initialized yet

Open davidefiocco opened this issue 5 years ago • 2 comments

As the app is started with docker-compose up, the streamlit service is likely the fastest to come online (the fastapi service needs to do the PyTorch model load). If the user visits the streamlit page and fires a call, the result may be

image

because the fastapi service is not responding yet.

The user should just wait a bit and then results should be returned OK, but it would be better to implement some sort of healthcheck so that streamlit requests can be handled more gracefully.

davidefiocco avatar Jun 28 '20 13:06 davidefiocco

This example might help

robmarkcole avatar Jun 29 '20 04:06 robmarkcole

Can this not be resolved in the docker-compose file by only starting the streamlit container after the FastAPI service is up and healthy?

Already the project has the depends_on: in the docker-compose. In addition you can add configuration to wait until that fastapi service is up and healthy. The top rated answer here from SvenHornberg gives some details on how to do that in the docker-compose.yml file - https://stackoverflow.com/questions/31746182/docker-compose-wait-for-container-x-before-starting-y

ttamg avatar Dec 02 '22 09:12 ttamg