-
Notifications
You must be signed in to change notification settings - Fork 308
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
Add file system change notifier #783
Conversation
I verified that watchfiles is available on conda-forge and has an MIT license. |
Codecov Report
@@ Coverage Diff @@
## main #783 +/- ##
==========================================
- Coverage 70.29% 69.91% -0.38%
==========================================
Files 62 62
Lines 7554 7383 -171
Branches 1248 1225 -23
==========================================
- Hits 5310 5162 -148
+ Misses 1861 1848 -13
+ Partials 383 373 -10
Continue to review full report at Codecov.
|
I packaged it yesterday 😄 |
I was about to ask how it compares with watchgod - but actually that is the new name 😄 |
Indeed, but I think now almost everything is done in Rust using this library. |
b90053b
to
db610cd
Compare
db610cd
to
5548742
Compare
20fddae
to
3874a05
Compare
We use
Hmm. I see |
Apache is fine, I was mainly checking for not GPL |
@kevin-bates I had a previous experience with |
The question here is: if we are importing |
In JupyterLab I want to check if the contents manager supports watching file changes. For that I need to know if the underlying file system is the local file system: if isinstance(self.contents_manager, (FileManagerMixin, AsyncFileManagerMixin)): But this is not ideal since custom contents managers could target the local file system and not derive from @property
def watchfiles(self):
import watchfiles
return watchfiles.__all__
# ('watch', 'awatch', 'run_process', 'arun_process', 'Change', 'BaseFilter', 'DefaultFilter', 'PythonFilter', 'VERSION') Then, the user could inspect the objects returned by this property to know what is supported. |
In this last commit I added the |
d009821
to
c6dd0df
Compare
c6dd0df
to
1bec904
Compare
I am wondering what does that mean in terms of jupyter-server semantic versioning. I guess it means jupyter-server will have to follow watchfiles if it adopts its API? I suppose we don't want to be in a situation where watchfile don't follow semver and breaks on a patch release? If the watchfiles API is not too complicated, could the ContentManager just implement the methods it provides and privately make use of watchfiles? |
Yes that's what I meant with "loose specification". On the other hand, even if we implement the methods in ContentsManager and under the hood delegate to watchfiles, we still have no control over changes e.g. in the return values, etc. Or we would have to exactly pin the package, and manually sync with new releases. But maybe it is safer? |
@@ -34,6 +34,13 @@ | |||
copy_pat = re.compile(r"\-Copy\d*\.") | |||
|
|||
|
|||
class NoWatchfilesAPI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think NoWatchfilesAPI
should contain the desired APIs without concrete implementations. So it can be used as a type hint for the watchfiles
property of ContentsManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes so that would go in Martin's direction.
Thanks for working on this @davidbrochart. I agree with @martinRenou and believe we should introduce some form of abstraction that allows folks the ability to implement their own "watchfiles" integration (in their own |
@kevin-bates @martinRenou @trungleduc I added a I believe this is the minimum necessary for now (at least for my use-case 😄 ). We can add more in the future if needed. I also pinned |
cd8547c
to
029de4f
Compare
029de4f
to
7bd9f99
Compare
Isn't this just exposing the What do we need in addition to the file and its corresponding action: added, modified, or deleted? Are we going to allow subsets of c.ContentsManager.watched_directories = ["foo/bar/{*.ipynb, *.py}", "baz/{*.yaml}"] or, if only c.ContentsManager.watched_files = ["*.ipynb", "*.py", "*.yaml"] and non-None values indicate that "watch files" is enabled. |
I think we should adhere to
I think all your suggestions can be implemented with the |
The idea would be to constrain what is exposed via the API, otherwise, folks that don't use |
I get your point, on the other hand it would be nice to offer various level of functionalities depending on the file system. On a local file system, I would expect to be able to use all of |
We spent some time triaging PRs in the Server Meeting today. What's the current status of this PR? It seems to me that it might be better to offer this as an alternative implementation of the FileContentsManager that could be provided as a separate package/extension. Imposing a "file-watching" cost on all users can be quite expensive, so making it an opt-in feature might be better. |
TO;DR |
I think we should adhere to watchfiles's API.
Closes #778.