davidefiocco / streamlit-fastapi-model-serving

Simple web app example serving a PyTorch model using streamlit and FastAPI

Home Page:https://davidefiocco.github.io/streamlit-fastapi-ml-serving

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

streamlit exited with code 1 due to TypeError in python3.7/site-packages/google/protobuf/descriptor.py

slowglow opened this issue · comments

Thanks for the example of how to tie up FastAPI and streamlit in docker.

On two of my machines streamlit exited with code 1, as mentioned in the title.
The full trace is pasted below.
The solution I found was to upgrade the packages in streamlit/requirements.txt to their most recent versions:

-- original requirements.txt ---

streamlit==1.9.0 
requests==2.24.0
requests-toolbelt==0.9.1

-- modified requirements.txt ---

streamlit==1.10.0 
requests==2.28.1
requests-toolbelt==0.9.1

--- Screen output---

~/Downloads/streamlit-fastapi$ docker-compose up
Creating network "streamlit-fastapi_deploy_network" with driver "bridge"
Creating fastapi ... done
Creating streamlit ... done
Attaching to fastapi, streamlit
streamlit    | Traceback (most recent call last):
streamlit    |   File "/usr/local/bin/streamlit", line 5, in <module>
streamlit    |     from streamlit.cli import main
streamlit    |   File "/usr/local/lib/python3.7/site-packages/streamlit/__init__.py", line 48, in <module>
streamlit    |     from streamlit.proto.RootContainer_pb2 import RootContainer
streamlit    |   File "/usr/local/lib/python3.7/site-packages/streamlit/proto/RootContainer_pb2.py", line 37, in <module>
streamlit    |     create_key=_descriptor._internal_create_key),
streamlit    |   File "/usr/local/lib/python3.7/site-packages/google/protobuf/descriptor.py", line 755, in __new__
streamlit    |     _message.Message._CheckCalledFromGeneratedFile()
streamlit    | TypeError: Descriptors cannot not be created directly.
streamlit    | If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
streamlit    | If you cannot immediately regenerate your protos, some other possible workarounds are:
streamlit    |  1. Downgrade the protobuf package to 3.20.x or lower.
streamlit    |  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
streamlit    | 
streamlit    | More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
streamlit exited with code 1
fastapi      | Downloading: "https://github.com/pytorch/vision/archive/v0.6.0.zip" to /root/.cache/torch/hub/v0.6.0.zip
fastapi      | Downloading: "https://download.pytorch.org/models/resnet101-5d3b4d8f.pth" to /root/.cache/torch/hub/checkpoints/resnet101-5d3b4d8f.pth
100.0%i      | 
fastapi      | Downloading: "https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth" to /root/.cache/torch/hub/checkpoints/deeplabv3_resnet101_coco-586e9e4e.pth
100.0%i      | 
fastapi      | INFO:     Started server process [1]
fastapi      | INFO:     Waiting for application startup.
fastapi      | INFO:     Application startup complete.
fastapi      | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
fastapi      | INFO:     172.19.0.1:51794 - "GET / HTTP/1.1" 404 Not Found

Hey, thanks for flagging this and suggesting the solution.
The problem is related to this https://stackoverflow.com/questions/72441758/typeerror-descriptors-cannot-not-be-created-directly/72493690#72493690
The main branch has been updated accordingly with #24
Can reopen this if the problem occurs again!