-
Notifications
You must be signed in to change notification settings - Fork 316
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
Make preferred_dir content manager trait #983
Conversation
@kevin-bates highlighted to check if a change needs to happen in JupyterLab to pick up the value from the new trait or not |
Thanks for submitting this PR @vidartf! I had a chance to run with your branch a bit and agree these related (and duplicated) trait scenarios are difficult! If I run server with a $ jupyter lab --ServerApp.preferred_dir=~/dev --ServerApp.root_dir=~/notebooks will produce this output...
with this dialog in Lab (which I know is unrelated but thought I'd include)... However, setting preferred_dir on the CM (or $ jupyter lab --ContentsManager.preferred_dir=~/dev --ServerApp.root_dir=~/notebooks
...
[C 2022-09-15 11:50:30.021 ServerApp] Bad config encountered during initialization: No such directory: ''/Users/kbates/dev'' ((I wonder if we should change this messaging to something like f"Preferred_dir {value} does not exist or is not a sub-directory or root_dir"?)) I'm also not seeing the deprecation warning under any circumstances - nor hitting a breakpoint in |
Codecov ReportBase: 80.01% // Head: 80.06% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #983 +/- ##
==========================================
+ Coverage 80.01% 80.06% +0.04%
==========================================
Files 68 68
Lines 8021 8040 +19
Branches 1587 1588 +1
==========================================
+ Hits 6418 6437 +19
Misses 1181 1181
Partials 422 422
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Yes, a change to jupyterlab-server would be needed here: https://github.com/jupyterlab/jupyterlab_server/blob/4263852881fd2bd181712dcabac1bda176886cd5/jupyterlab_server/handlers.py#L90-L99 |
Thanks for the update @vidartf. Lately, I've been hearing that it's not uncommon for a given installation to be using multiple instances (and types) of ContentsManager simultaneously. For references like that above in |
Lab server would read out the preferred dir from the main/root contents manager, and pass that path to JupyterLab. That path could ofc then be a path into any proxied "inner" contents manager. That would be an internal detail for them to sort out. |
Given that these traits are being deprecated, I think it will probably be okay if their validation behavior is not the most user friendly, as long as it is eventually correct. But I will have a look to see if I can force a validation at some point during startup if the deprecated traits are being set.
Makes sense.
I'll have a look. |
Please test it with jupyterlab/jupyterlab_server#324 |
Thanks @vidartf - I'll try to take this (and 324) for a spin this afternoon. |
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.
Hi @vidartf - the changes look good. In one of the comments I provide analysis relative to an arguably questionable scenario that winds up in a rabbit hole - although I think the jupyterlab_server handler could be a bit more robust, I just wasn't sure if errors can be raised at that level.
@kevin-bates Thanks for the review. I pushed a new commit here, and one on the jupyterlab_server branch to help address some of the concerns. I didn't end up changing the warning stack level after all, since I figured it was better to be consistent with other deprecations:
|
Thanks for the updates. I'm finding the test failures getting tangled between catching Here's the commit. I was hesitant to push it in case you wanted to take a different approach or this behavior is indicative of another issue. |
@kevin-bates You commit looks good to me! Please push it onto the branch 👍 |
@vidartf - My commit has been pushed. The merge was more involved than I expected. The tests passed locally, but I'm hoping I didn't mess anything up. 😊 |
ba0fbb1
to
77f06f2
Compare
@kevin-bates I did a rebase anyway to pull in latest changes from main. I took the opportunity to clean up the commit order then. |
I pushed a change to satisfy pre-commit. What's odd is that the set of pre-commit actions used in CI is different than what is used in the git hook. The latter doesn't call |
The ones that are listed as hook-stage: manual are only run in CI by default, because they can't be fixed automatically, and we didn't want them to prevent pushing. You can run |
The latest merge from master highlights that I was missing a sync/async compat for the |
@blink1073 If you did mean the ioloop one, that raises:
|
5ed6074
to
01e7d2e
Compare
@kevin-bates I've fixed things up now (re-added validator using run_sync, fixed tests), and also added back the default value of the ServerApp.preferred_dir, so that it will be backwards compatible with older versions of jupyterlab-server. |
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.
Thank you @vidartf - definitely one of those "easier said than done" PRs!
@kevin-bates I changed to not having a leading |
Heads up, this PR picked up a couple conflicts from the linting refactor in #1114 |
Move the preferred_dir trait to content manager, but keep the old one for backwards compatibility. The new location should also cause the value to be read later in the init, allowing us to avoid the deferred validation. Also fixes an issue with escaping the root dir on Windows if an absolute path is passed.
Also validates set value to strip any leading slashes
Will transparently convert to API path in validator.
Thanks for the great work here @vidartf - merging. |
@meeseeksdev Please backport to 1.x |
I guess I was a little surprised to see this backport request since it introduces a deprecation. As a result, this warning message may be a little confusing to folks running 1.x.
Had we known this was to be backported this warning could have been worded...
That said, I don't think this is worth the fuss to change - but perhaps something to consider down the road. |
@vidartf do we need to revert this prior to making a patch release, since it seems to depend on jupyterlab/jupyterlab_server#324? |
We do not strictly need it (nothing will fail directly), but it might be cleaner. If we release this as-is, people that use the |
This to me indicates that we should either depend on the unreleased |
This reverts commit a55bc58.
jupyterlab_server 2.18.0 has been released with this feature |
Move the preferred_dir trait to content manager, but keep the old one for backwards compatibility. The new location should also cause the value to be read later in the init, allowing us to avoid the deferred validation. Also fixes an issue with escaping the root dir on Windows if an absolute path is passed.