Re-Run/Refresh does not update page anymore on 1.24.0, need restart of Streamlit for update to happen

Summary

I just updated to 1.24.0 from a 1.20.0 version and now in order for any of my updates to be shown I have to fully restart Streamlit, where as normally a “re-run” or browser refresh on the page would have worked.

I see it mentioned in this post that it was solved for them on 1.24.0 (where it seemed to happen in 1.23.1 for them), but I am still having this issue on 1.24.0

After I revert back to 1.20.0 it all works as “normal” again.

Debug info

  • Streamlit version: Streamlit 1.24.0
  • Python version: Python 3.10.6
  • Using Conda? PipEnv? PyEnv? Pex? - No
  • OS version: Ubuntu 22.04.2 LTS
  • Browser version: Chrome 114.0.5735.199

Thanks, @darkb1u3!

You may need to reinstall Streamlit again and also ensure you have the most recent version of all your packages.

You can use e.g. pip list --outdated to see a list of packages that need updating. Then, update them using pip install --upgrade <package name>.

Hopefully, that will sort it. Let me know if not, as it may also be a bug. :blush:

Thanks,
Charly

2 Likes

Thanks for trying to help out,

  • I’ve updated all my packages in “pip list --outdated”
  • Uninstalled streamlit (1.24.0) using, “pip uninstall streamlit”
  • Installed it again using, “pip install streamlit”
  • I start my app and and then make a change, for example adding st.write(“Hello”) and then “Re-Run” the app (Pressing R) and the update does not show up, I try a Refresh of the browser page (F5) and the update still does not show up.
  • I go and fully restart Streamlit from the console, go back into the browser window and press F5 to refresh (since it lost connection to the app) and now I can see the update (the st.write(“Hello”) text I added).
  • No matter the update I make to my page/app, it will not show up unless I fully restart Streamlit.

If I uninstall Streamlit once again, and this time install Streamlit 1.20.0 (which was the previous version I had) it all works like normal, I can make any change and just press R or Refresh and the update will instantly show up.

Thanks, @darkb1u3 , for the detailed explanation. I’ve shared it with our team for further review. We appreciate your patience!

Charly

Hey @darkb1u3 can you share a code example to help us repro? Thanks!

I feel like I have stumbled upon something now, just not sure how to interpret it, or if there is some weird user error on my end.

I have installed Streamlit 1.24.0 once again, next I have created a new “app”, just a new Home.py file inside of a folder called “streamlit-test” and it contains the most simplest of code.

import streamlit as st

st.set_page_config(
page_title=“Test Page”,
page_icon=“:ice_cube:”,
layout=“centered”,
initial_sidebar_state=“expanded”,
)

st.write(“Hi”)

I then run this in the following way on my Ubuntu 22.04 LTS server,

streamlit run Home.py &

It all starts up fine and I can access the page.

I then start up Visual Studio Code and open the folder and Home.py file.
I then add the line st.write(“new line”) at the end of the file, then Ctrl + S (Save)
Go back into browser and my streamlit app, press R to ReRun and the line that I added does not show up.

If I go into the ubuntu terminal I can see that the file has updated with the line. So the file has been updated, its just that Streamlit doesn’t seem to notice that it has.

Next if instead open the file in the terminal, “vi Home.py”, add the line st.write(“added from vi”), “:wq!” (save the file). Go into the browser and my streamlit, and now it actually shows on the top right that it has detected a source file update “Source file changed.” I then press R to ReRun and all of a sudden it updates. I see both the line that I added from Visual Studio Code and VI (terminal).

So to summarize this part, any update that I make in Visual Studio Code (I tried Sublime as well) does not seem to trigger an update to Streamlit even though it is there in the file. If i write it directly to the file using VI it works.

Now for the “weird part”, next I uninstall Streamlit 1.24.0 and install Streamlit 1.20.0 instead.
Go into the same “streamlit-test” folder, and start the same app I was using for 1.24.0.

streamlit run Home.py &

App starts up fine and I see all the edits I previously made while tinkering with 1.24.0
With the file (Home.py) still open in Visual Studio Code I make an edit, add st.write(“line from vsc”) and the end of the file, Ctrl + S (Save).
Go back into browser and my app, press R to ReRun and it instantly updates with the new line I added.

So to summarize again, with 1.20.0 I can update from VSC and get it to show up instantly when I ReRun (R), but in 1.24.0 the same procedure does not work, even though its the same app/file and the only thing that has changed is the Streamlit version.

And just to state, I have been updating my file/app using VSC in this way throughout all my usage of Streamlit (1-2 years), but now with 1.24.0 it seems to be not be working for some reason.

Not sure if any of this makes sense?

2 Likes

@darkb1u3, @jcarroll

I created the topic cited by @darkb1u3. I have some sample code on that topic as well.

I don’t have the problem as much on 1.24.0 as in 1.23.1 when editing streamlit scripts. But the issue does still happen.

Here’s a sample code:

import streamlit as st

def function_sum(x):
    
    x = x+2
    
    return x

f"""
This is my number: {function_sum(5)}
"""

I get the problem whenever I edit anything inside the f-string.

Hey @darkb1u3 and @DarkCSS!

We suspect that our feature to cache scripts for rerun is causing the issue. Essentially, since the script “has not changed” we don’t reread and recompile the the code. This seems to generally work, but we rely very heavily that our file watchers are really reliable in letting us know that the file has indeed changed. Our fix in 1.24 was to remove a race condition where the script may not be removed from cache before rerunning. Your concerns suggest that we need to assume our file watchers are not reliable.

To start with a question that I likely know the answer. You can disable the file watching in our config with server.folderWatchBlacklist and folderWatcherType. Do you modify any of these that could be causing the problem?

Second, I’d like to verify if my intuition is correct. Would you both be open to having a custom wheel file that removes this caching to verify that it fixes the issue? Likely the solution would be to have a configuration to take the performance penalty of script caching for development purposes.

1 Like

One other question is that @darkb1u3 uses ubunutu. This assumes that installing Streamlit leverages watchdog (watchdog · PyPI). Could you try setting configuration for server.folderWatcherType to poll to see if it works as well. If that works, we may need to work with the watchdog team to get it working properly.

1 Like

@kmcgrady for your first question.

Blockquote server.folderWatchBlacklist and folderWatcherType. Do you modify any of these that could be causing the problem?

No, I don’t know any of these configs and did not mess with any of them.

Blockquote Would you both be open to having a custom wheel file that removes this caching to verify that it fixes the issue?

Sure I would be willing to to help Streamlit crackdown on this problem. You might have to give me the instructions to do so, though, because I don’t know how that would work.

I have not changed that.

Sure, just let me know what to do and I will try it.

Does this just mean setting,

server.folderWatcherType = poll

in the ./streamlit/config.toml file?

1 Like

Yes @darkb1u3 . That’s exactly how you would set it in the config.

Hey @DarkCSS and @darkb1u3 ! Sorry for the delay from the holiday weekend. Thank you for offering to help test the software. I created a release on GitHub.

https://github.com/kmcgrady/st-playground/releases/download/0.0.1/streamlit-1.24.0-py2.py3-none-any.whl

It’s a Python Wheel File. You can install the wheel file simply with pip install streamlit-1.24.0-py2.py3-none-any.whl so long as the wheel file is in the current directory. You can verify it’s installed by looking at the About Dialog and seeing .PreRelease after the version number.

Let me know if there’s anything else I can do to help.

Hopefully that will help tell you test out the bug. Let me know if it works out.

Also let me know if that config change works as well. That’s good information as well!

Ok, so I entered in “server.folderWatcherType = poll”, but it errors out on start.

"server.folderWatcherType" is not a valid config option. If you previously had this config option set, it may have been removed."

So I assume I was to set it as fileWatcherType instead of folderWatcherType, so I set the following in my config file.

[server]
fileWatcherType = "poll"

With this setting on, any file change I make, wether its in Visual Studio Code, Sublime or VI it’s instantly recognized and after a ReRun(R) of the Streamlit app its updated and there on the page. So it seems to be working good with this setting on.
Tested this on both Streamlit - 1.24.0 and 1.24.1
:white_check_mark:

For the next test,

Downloaded the file and installed it,
pip install streamlit-1.24.0-py2.py3-none-any.whl
Processing ./streamlit-1.24.0-py2.py3-none-any.whl
...
Installing collected packages: streamlit
Successfully installed streamlit-1.24.0

When I check the About section though there is no mention of .PreRelease.
image

However, I can confirm that with this version installed it seems to be working fine with any update I make, using either Visual Studio Code, Sublime, or VI. I have removed the

[server]
fileWatcherType = "poll"

config setting as well, so its not that causing it to work.
:white_check_mark:

1 Like

I don’t know what happened but I cannot reproduce the problem anymore on 1.24.0. Don’t know exactly what changed as I had managed to make it happen a couple times on this version.

Hi -

This post is a lot to follow and I’m not sure I can decipher the solution. I’m thinking this may be related to a question I was just about to post. This would have been my post:

I found another post with this same topic.(Other post here.)

The tips there were to:
1) Be sure you’re using the most recent version of streamlit. Run this code to upgrade:
pip install streamlit --upgrade
*2) Some example code was provided showing how to use data_editor. *

I have updated Streamlit and have verified I’m using 1.24.1.
I have also copied and pasted the example code into my code to see it work and still getting this AttributeError.

Can anyone tell me if this is related and if so, help me figure out what I need to do?

Thank you,

Stacey

I’m not sure if I’m causing more trouble for myself but previously I ran the pip install statement in the Visual Studio terminal. I just ran this from my command prompt. It says it successfully installed streamlit-1.24.1. What’s odd is the WARNING messages that follow this:
WARNING: Ignoring invalid distribution -treamlit (c:\users\myname\anaconda\lib\site-packages)

What may look like a typo here is not a typo, -streamlit is missing the s and it is -treamlit

With that said, I re-opened my app and it does work. I believe my computer has two different installs of Python which I need to correct.

Hey I just wanted to note a similar refresh issue to this.

For me, it would show that files had changed, I would press R, but it wouldn’t pick up the change. Strangely, error messages would show the new code in the trace, but it would error as if it was running the old code.

The code it wouldn’t pick up was imported from a folder. I was doing this:
from api.services.parser import *

By moving my streamlit app inside the api folder, and reducing my import to:
from services.parser import *

It then works fine. I’m not sure why exactly, I’m guessing its multi level import? Only one folder deep is allowed? Seems like a bug so figured I’d mention it here.

Running on Windows 11, version 1.25. I tried installing that custom version mentioned above (streamlit-1.24.0-py2.py3-none-any.whl) but it didn’t work either.

I had the same issue today, and updating config.toml worked for me:

[server]
fileWatcherType = "poll"

I’m developing in WSL2/Ubuntu using VSCode:

  • Ubuntu: 20.04.2 LTS
  • Python: 3.8.5
  • streamlit: 1.29.0
  • VSCode: 1.85.1
1 Like

Thank you @mmccarthy404. I’ve had the same problem with version 1.34.0
Your solution fixes the issue.
Does anyone know what is causing this problem?
It doesn’t pick up on changes in the files content.