Runtime error on huggingface spaces

rleeson
Wed, 14 Jun 2023 02:46:50 +0000

Found the fix: Referring to the fastapi_dummy template: https://huggingface.co/spaces/DockerTemplates/fastapi_dummy/tree/main the Dockerfile CMD is CMD [“uvicorn”, “main:app”, “–host”, “0.0.0.0”, “–port”, “7860”], note the “main.app”.

In the “Your first Docker Spaces” documentation: Your First Docker Space: Text Generation with T5, the Dockerfile CMD is CMD [“uvicorn”, “app.main:app”, “–host”, “0.0.0.0”, “–port”, “7860”]
where the reference to the app object is “app.main:app”.

Working locally the fix is to change “app.main:app” to “main:app”. Here’s the gotcha: if you try to rebuild with docker build -t fastapi . , docker will used the cached image so I needed rebuild with the --no-cache flag: docker build --no-cache -t fastapi . and then run docker run -it -p 7860:7860 fastapi the app works.