Skip to content

fix: catch protobuf TypeError on optional streamlit import#203

Merged
dmpantiu merged 2 commits intomainfrom
fix/streamlit-import-typeerror
Mar 27, 2026
Merged

fix: catch protobuf TypeError on optional streamlit import#203
dmpantiu merged 2 commits intomainfrom
fix/streamlit-import-typeerror

Conversation

@koldunovn
Copy link
Copy Markdown
Collaborator

Summary

  • Broadened except ImportError to except Exception for optional import streamlit in era5_retrieval_tool.py and destine_retrieval_tool.py
  • When running via FastAPI (uvicorn), streamlit is not needed but gets imported transitively. If the installed protobuf version is incompatible with streamlit's generated _pb2.py files, a TypeError is raised — not ImportError — which crashes the backend.
  • These two files already treat streamlit as optional (st = None fallback), so catching any exception is the correct behavior.

Test plan

  • Run uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload — no protobuf crash on startup
  • Streamlit UI still works when run via streamlit run src/climsight/climsight.py

…tions

- Remove langchain-classic from pip deps (requires langchain-core>=1.2.19,
  conflicts with conda langchain 0.3.x; only used as fallback import)
- Pin langchain-anthropic<1.0.0 to stay compatible with langchain-core<1.0.0
- Move npm install before uvicorn start to prevent reload-triggered ETIMEDOUT
- Add --reload-exclude for frontend/node_modules to uvicorn command
…I context

Streamlit's protobuf files can raise TypeError (not ImportError) when the
installed protobuf version is incompatible. This crashes the FastAPI backend
even though it doesn't use streamlit. Broadening the except clause to
Exception prevents the crash.
Copy link
Copy Markdown
Collaborator

@dmpantiu dmpantiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The except Exception fix for streamlit protobuf TypeError is correct — both files already treat streamlit as optional (st = None fallback).

@dmpantiu dmpantiu merged commit 146b478 into main Mar 27, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants