Hot load doesn't work in a package setting
See original GitHub issueSummary
When changing an imported module/function’s code, streamlit won’t reload properly.
Steps to reproduce
Setting
Code
Assume the following tree structure:
.
├── mymod
│ ├── __init__.py
│ ├── dashboard
│ │ ├── __init__.py
│ │ └── app.py
│ └── foo.py
└── setup.py
with the following code:
# setup.py
from setuptools import setup
setup(name="mymod", version="0.1", packages=["mymod"], zip_safe=False)
# foo.py
def combine_numbers(a, b):
return a+b
# app.py
import streamlit as st
from mymod.foo import combine_numbers
print(combine_numbers(2, 3))
st.write(combine_numbers(2, 3))
Environment
Create a conda environment with Python 3.7 and install streamlit using pip. In addition install the package using pip install -e .
.
What next?
- Run the application
streamlit run mymod/dashboard/app.py
. - As expected,
5
is rendered. - Edit the file
foo.py
and replace+
with*
- go back to the app.
6
is not rendered. Rerunning the app doesn’t help. Only killing the app and restarting it picks up the change infoo.py
.
Expected behavior:
I would hope that streamlit will pick up changes in depending files
Actual behavior:
In order for the app to reflect changes in the imported code, the app has to be restarted.
Is this a regression?
no
Debug info
- Streamlit version: 0.56.0
- Python version: 3.7.6
- Using conda
- OS version: macOS 10.14.6
- Browser version: Chrome 80.0.3987.106
Additional information
Related to #358 as per @tconkling request.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8
Top Results From Across the Web
Hot Reload is not working in my React App - Stack Overflow
If your page is not loading automatically then you have to do these ... Go to package.json and replace react, react-dom and react-scripts ......
Read more >Hot reload - Flutter documentation
Hot reload loads code changes into the VM and re-builds the widget tree, preserving the app state; it doesn't rerun main() or initState()...
Read more >Module Methods - webpack
This section covers all methods available in code compiled with webpack. When using webpack to bundle your application, you can pick from a...
Read more >Troubleshoot connecting to the app during setup - Google Help
Troubleshoot connecting to the app during setup · 1. Check your camera's distance to the router · 2. Restart your camera · 3....
Read more >webpack-dev-server - npm
TypeScript icon, indicating that this package has built-in type ... Note: While you can install and run webpack-dev-server globally, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @drorata, by default, we only watch modules contained in the current directory of the main app module. This means that in your case,
foo.py
is not tracked.You can change the default behavior by adding the parent directory of the module you want to track to the
PYTHONPATH
. Let me know if this helps. We implemented this here.matteo
I would be happy to provide more information about this problem. At the moment, I can only say this is really slowing down the work with
streamlit
😦