Multiple classes found for path error on reload with model relationships #1362
Unanswered
Raido-Tokuyama
asked this question in
Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
models.py
database.py
main.py
Description
When using Streamlit with SQLModel, errors occur when reloading the application after making code changes to model files. The errors are related to model registration and mapper initialization.
Even though
__table_args__ = {"extend_existing": True}
is specified in all model classes, which should normally allow redefinitions of table mappings without error, the application still throws anInvalidRequestError
on reload.A comment from a Streamlit contributor suggests that this may be caused by SQLModel's internal registry persisting across script reloads. Streamlit has a mechanism to clean stateful modules between runs, and similar support might be possible if SQLModel provided a way to reset its registry. If such a mechanism already exists, I would appreciate any guidance.
Environment
Steps to Reproduce
Note: Simply reloading the page without code changes does NOT trigger the error
The error occurs when reloading after making code modifications
Expected Behavior
The application should properly handle reloading and maintain the relationships between models when code changes are made and the page is reloaded.
Actual Behavior
After First Code Change and Reload
After Second Code Change and Reload
Key observations:
Operating System
macOS
Operating System Details
Sequoia 15.3.1
SQLModel Version
0.0.24
Python Version
3.13.2
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions