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

_MultiPathWatcher unnecessarily watches parent folder of given path #7467

Open
3 of 4 tasks
gorogm opened this issue Oct 1, 2023 · 5 comments
Open
3 of 4 tasks

_MultiPathWatcher unnecessarily watches parent folder of given path #7467

gorogm opened this issue Oct 1, 2023 · 5 comments
Labels
feature:cli Related to the command line interface good first issue Good for newcomers priority:P3 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working

Comments

@gorogm
Copy link

gorogm commented Oct 1, 2023

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

When starting streamlit in a standard way, it unexpectedly printed OSError: [Errno 24] inotify instance limit reached message, even though high number of files were not around.

_MultiPathWatcher in streamlit/watcher/event_based_path_watcher.py watches parent directories of a given path, thereby possibly including unrelated directories with files of no interest.

I believe watching for the requested directory is enough, without watching for it's parent.

Reproducible Code Example

At Streamlit startup streamlit starts watching for the important files and folders.

1. _register_necessary_watchers() in streamlit/watcher/local_sources_watcher.py calls into
2. EventBasedPathWatcher() in streamlit/watcher/event_based_path_watcher.py, which calls into
3. _MultiPathWatcher::watch_path()
4. Here, the following line steps up in the hierarchy, possibly including lot of unrelated files and folders:
folder_path = os.path.abspath(os.path.dirname(path))

Steps To Reproduce

  1. Have a directory structure like this:
  • main
  • --code
  • --data
  1. Place your minimal streamlit project into code, or include something from code, so LocalSourcesWatcher will watch it
  2. Place a dataset with 10000s of files into data
  3. Start streamlit
  4. Observe that you are out of inotify watches

Expected Behavior

Only code folder is watched for changes, which has only 10-100 code files.

Current Behavior

The parent of code: the main folder is watched for changes. With this, data folder is also watched, and as it contains 10000s of files, inotify is over the limits, and even code will not watched in reality.

Increasing the inotify limit or choosing poll policy are workarounds, but that is not the proper solution.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.27
  • Python version: 3.9
  • Operating System: Ubuntu
  • Browser: Firefox (not related)

Additional Information

No response

@gorogm gorogm added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Oct 1, 2023
@github-actions
Copy link

github-actions bot commented Oct 1, 2023

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@gorogm
Copy link
Author

gorogm commented Oct 25, 2023

My idea is changing
folder_path = os.path.abspath(os.path.dirname(path))
to

        if os.path.isdir(path):
            folder_path = os.path.abspath(path)
        else:
            folder_path = os.path.abspath(os.path.dirname(path))

@AnOctopus AnOctopus added good first issue Good for newcomers status:confirmed Bug has been confirmed by the Streamlit team priority:P3 and removed status:needs-triage Has not been triaged by the Streamlit team labels Jan 9, 2024
@watana318
Copy link

@gorogm
Hi, still having this problem? If it is not resolved, I will investigate.
The version I'm using is 1.31.0.

@benjaminkzm
Copy link

Hi @gorogm , I am trying to work on this. Could you clarify how to reproduce the error? From the above steps to reproduce, it seems a bit vague. Thank you

@senthil1288
Copy link

Hi @gorogm The interns aren't able to reproduce this issue by following the steps described above. Can you please help? How do we reach out? Are you available for a quick meet?

@LukasMasuch LukasMasuch added the feature:cli Related to the command line interface label Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:cli Related to the command line interface good first issue Good for newcomers priority:P3 status:confirmed Bug has been confirmed by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants