Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change in fastapi dependency in GenericModel.to_docker() #137

Closed
wegry opened this issue Oct 8, 2024 · 2 comments
Closed

Breaking change in fastapi dependency in GenericModel.to_docker() #137

wegry opened this issue Oct 8, 2024 · 2 comments

Comments

@wegry
Copy link

wegry commented Oct 8, 2024

The requirements.txt generated by GenericModel.to_docker() uses the lastest version fastapi. In fastapi@0.112, fastapi/fastapi#11935 removed the CLI from fastapi. This causes docker serving of YDF models to fail on the latest fastapi (0.115) version.

To maintain the old behavior (and what I assume is intended), fastapi[all] should be the dependency instead.

diff --git a/yggdrasil_decision_forests/port/python/ydf/model/export_docker.py b/yggdrasil_decision_forests/port/python/ydf/model/export_docker.py
index ab19b9c..f1614c5 100644
--- a/yggdrasil_decision_forests/port/python/ydf/model/export_docker.py
+++ b/yggdrasil_decision_forests/port/python/ydf/model/export_docker.py
@@ -273,7 +273,7 @@ CMD ["fastapi", "run", "main.py", "--port", "8080"]
 
 def content_requirements() -> str:
   return """\
-fastapi
+fastapi[all]
 pydantic
 ydf
 """
@rstz
Copy link
Collaborator

rstz commented Oct 9, 2024

Thank you for reporting! AFAICT, fastapi[standard] should be sufficient, is that right?

@wegry
Copy link
Author

wegry commented Oct 9, 2024

@rstz with fastapi[standard], I couldn't get requests to the container running on my machine locally or in GCP to succeed. I did do a build and run the container with slightly different flags than the docs. I'm on macOS 15.0.

docker build --platform linux/amd64 -t ydf_predict_image my_docker_model
docker run --platform linux/amd64 -it --rm -p 8080:8080 -d ydf_predict_image

When I make a request:

$ curl -X 'POST'   'localhost:8080/predict'   -H "accept: application/json"   -H 'Content-Type: application/json'   -d '{}'
curl: (56) Recv failure: Connection reset by peer

My serialized model is large enough that that could've been a factor in the server failing to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants