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

Clarify behavior of custom class reloading #1159

Closed
eferm opened this issue Sep 25, 2024 · 0 comments · Fixed by #1215
Closed

Clarify behavior of custom class reloading #1159

eferm opened this issue Sep 25, 2024 · 0 comments · Fixed by #1215

Comments

@eferm
Copy link

eferm commented Sep 25, 2024

Link to doc page in question (if any):

https://docs.streamlit.io/develop/concepts/design/custom-classes#pattern-1-define-your-class-in-a-separate-module

Name of the Streamlit feature whose docs need improvement:

Core concepts, runtime behavior, session state

What you think the docs should say:

Currently the docs say (emphasis mine):

If possible, move class definitions into their own module file and import them into your app script. As long as you are not editing the file where your class is defined, Streamlit will not re-import it with each rerun.

Streamlit only reloads code in imported modules when it detects the code has changed. Thus, if you are actively editing the file where your class is defined, you may need to stop and restart your Streamlit server to avoid an undesirable class redefinition mid-session.

The behavior, at least in 1.38, is that when any code (not just the module file) is changed, the module will be re-imported. So either this is unexpected behavior, in which case let me know and I can file a bug report, or the docs could be improved to say something like:

If possible, move class definitions into their own module file and import them into your app script. As long as you are not editing the file where your class is defined, or the Streamlit app script file, Streamlit will not re-import it with each rerun.

Streamlit only reloads code in imported modules when it detects the**any** code, either the module file or the app script file, has changed. Thus, if you are actively editing the file where your class is defined, you may need to stop and restart your Streamlit server to avoid an undesirable class redefinition mid-session.

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

Successfully merging a pull request may close this issue.

1 participant