Comments (19)
Ok. This is very valuable. Thank you!
from awesome-streamlit.
from awesome-streamlit.
I will close this as I've found a work to enable hotreloading on all files in my end.
In the future you can referer to the Streamlit Github to follow the development.
from awesome-streamlit.
Please note I've refactored the project a lot so please so if you try to do the steps below please pull master first :-)
As far as I can see modules with st.something commands are not being reloaded automatically. As an example lets play around with the home.py file.
Then I change home.py
and click rerun
As you see nothing happens. I can also navigate to other pages and back and nothing happens. I can also click rerun again and nothing happens.
If I close the server and start all over and enable reload
and change
then at first nothing happens. But if i navigate to another page like the Vision page and back it's updated.
It's the same if I click the rerun once more instead of navigating to another page and back.
So In conclusion I cannot get automatic updates. But I can get semi-automatic updates if I navigate to another page and back.
Unfortunately I cannot run Streamlit on individual pages because I import relative to the root folder of the project but streamlit starts the app in the folder of the file. Thus I will get import errors :-)
The home.py file
"""Home page shown when the user enters the application"""
import streamlit as st
import streamlit_extensions as st_extensions
imports streamlit_extensions from the root folder of the project from which I start the project.
The workaround for now is putting the home.py file in the root folder while developing it.
from awesome-streamlit.
And I also think Streamlit should have a way of fixing it.
Maybe it's my app structure that should be changed or maybe the assumption of Streamlit has been that all files are in the same folder?
from awesome-streamlit.
As far as I can tell, Streamit should properly reload modules in this case. Ok for me to submit a Streamlit bug report referencing this issue?
from awesome-streamlit.
from awesome-streamlit.
Ok. Just added the bug. It would be very helpful if you could add some information as specified. Thanks! ❤️
from awesome-streamlit.
Hi @treuille
One of the problems is that the modules i'm reloading are actually not in sys.modules! I don't understand why but if I change to code to
and run
streamlit run app.py
It's showing the home.py, file.
If I change the spreadsheet.py code, go to the gallery.py page and select the spreadsheet.py subpage then I see
so src.pages.gallery.spreadsheet is not in sys.modules before the reload! But I can see it is after!
So I believe a hack for me now is to run the reload in the exception handling as well.
from awesome-streamlit.
I've tried adding
But that does not change anything. I still have to reload twice or reload and interact with widget before the change takes effect.
from awesome-streamlit.
In the src/pages/gallery/index.py file I tried changing
to
But that does not change anything either.
from awesome-streamlit.
I've tried importing spacyio, spreadsheet in the app.py file that is run by Streamlit
But that does not change anything either. Still need to reload twice.
from awesome-streamlit.
But (Hurra!!!!). when I added spacyio and spreadsheet as below
I get automatic reload!!!!!
Don't ask me why :-)
FYI @treuille
from awesome-streamlit.
And now if I change the imports in app.py to absolute imports
I can remove the importlib.reload
and have automatic updates !!!!
This solves my problem. But I guess @treuille that you could have other users experiencing the same problem and have to help them. Maybe there is something to understand and fix wrt. the way you use sys.modules?
Thanks for the help.
from awesome-streamlit.
I tried removing imports of spacyio and spreadsheet from app.py and
and add them in the src/pages/gallery/index.py file.
But then autoreload of spreadsheet.py stopped
I tried some more things to see if I could avoid making unused imports in app.py or anywhere. But I could not.
Bottom line: all imports must be done in app.py and in a specific way for autoreload to work.
from awesome-streamlit.
One more fun fact is that autoreload works for src.shared.components.st_awesome but not for st_extensions!
But if I move the st_extensions file and change to
The I get autoreload as well.
from awesome-streamlit.
Argghhh :-)
My understanding now is that
- It works mostly if you use the the full path like
import x.y.z
and not
import x.y.z as z
from x.y import z
And definately you should use the same import convention across all files.
- st_extensions and st_awesome do not get autoreload if I put them in the root folder but they get autoreload if I put them in a subfolder. For example if they are in the src folder and I use
import src.st_extensions
import src.st_awesome
- I cannot get autoreload to work for src.pages.gallery.spacyio and src.pages.gallery.spreadsheet unless I add the importlib.reload
If I stick to the above imports then I get autoreload for everything and no exceptions in the write_page function
Phew :-)
from awesome-streamlit.
Hi @MarcSkovMadsen : I have factored the bug report into two different issues: 358 and 366.
Do those two isssues cover everything you've observed, or is there more we need to cover? Thanks!
from awesome-streamlit.
I have a feeling you don't cover everything. Each possible way of importing should be covered.
I've created an example file structure here.
If I could get hot reloading in all files I think that would cover most peoples use cases.
I guess I'm the first one trying to develop an app in multiple pages/ multiple files so getting a good practice for that and improving Streamlit to fit that use case is important.
streamlit run a.py
a.py
import streamlit as st
import st_extensions # Hot reloading works in st_extensions.py file
import bf.b # Hot reloading works in b.py file
from bf2 import b2 # Hot reload does not work in b2.py file
from bf3 import b3 as b3_new_name # Hot reload does not work in b3.py file
import bf4.b4 as b4_new_name # Hot reload works in b4.py file
# c hot reloading does not work in bf/cf/c.py file through file bf/b.py
# d hot reloading does not work in bf/cf/df/d.py file through file bf/cf/c.py
st.write("this is a")
bf.b.write()
b2.write()
b3_new_name.write()
b4_new_name.write()
st_extensions.write("awesome")
from awesome-streamlit.
Related Issues (20)
- Parallel query computation question HOT 1
- Contribution of app HOT 5
- Contribute to the gallery HOT 3
- Stream: page names with spaces crash app. HOT 2
- Did you find a way to execute Script immediately? HOT 1
- Display pyLDAvis HOT 2
- 'list index out of range' and 'no module named gitdb.utils.compat'
- ModuleNotFoundError: No module named 'awesome_streamlit.database' HOT 3
- Error installing awesome-streamlit in anaconda navigator HOT 2
- Error deploying Awesome-streamlit via gitlab CI (Running setup.py develop for awesome-streamlit; ERROR: Command errored out with exit status 1:)
- Contribute 'python formatter' app to the gallery HOT 1
- Run app on external URL HOT 1
- Add my project DeepNeural Net Visualiser HOT 2
- First boked demo is not displaying HOT 3
- awesome-streamlit.org has expired and is parked free HOT 2
- How do you switch between the debug and prod toml files in development?
- How to deploy streamlit on an Apache server?
- really slow/non working website HOT 3
- Integrated debugging only works on main file
- Certificate issue on website HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awesome-streamlit.