resolve path when registering watcher for module paths #8372
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes
I am developing a streamlit app in Bazel, which creates many symlinks when building a project, e.g.
I usually edit files in
foo/
during development, and I found that when updating module file (utils.py
), the change is not detected by streamlit and the browser does not refresh, automatically. However, updating the page file (e.g.0_Overview.py
) would lead to auto refresh. Then, after debugging, I think it's due to the inconsistency in resolutions of page and module paths.Specifically, when streamlit is run and registering watchers, only the paths of page files get resolved (make absolute path and resolve symlink), the relevant code snippets are
streamlit/lib/streamlit/watcher/local_sources_watcher.py
Lines 54 to 58 in 4589b13
streamlit/lib/streamlit/source_util.py
Line 132 in 4589b13
streamlit/lib/streamlit/source_util.py
Line 147 in 4589b13
However, the module paths don't get resolved
streamlit/lib/streamlit/watcher/local_sources_watcher.py
Line 150 in 4589b13
which explains the inconsistent auto refresh behavior and is what this PR updates. In essence, we only want to watch the change in the resolved paths, the content of the symlink path, which just holds a link to the source file, does not change.
GitHub Issue Link (if applicable)
Testing Plan
manually tested it's working.
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.