-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
server extensions not loaded when installed to different locations #2063
Comments
Are they both listed as enabled? |
Yes, for example:
I get validation errors, but I think those are unrelated. With this setup, geonotebook's server extension is not initialized. Once I delete the user config at |
This appears to be due to a condition in traitlets Config.merge method. Config keys are only merged (as opposed to clobbered) if comparing two Config objects. In the case of server extension configurations the To illustrate: jupyter_notebook_config.json installed with (jupyter_2063) kotfic@minastirith:~/tmp/jupyter_2063 ⇒ \
cat ~/.venvs/jupyter_2063/etc/jupyter/jupyter_notebook_config.json
{
"NotebookApp": {
"nbserver_extensions": {
"geonotebook": true
}
}
} jupyter_notebook_config.json installed with (jupyter_2063) kotfic@minastirith:~/tmp/jupyter_2063 ⇒ \
cat ~/.jupyter/jupyter_notebook_config.json
{
"NotebookApp": {
"nbserver_extensions": {
"jupyter_nbextensions_configurator": true
}
}
} By the time we complete load_config_file nbserver_extensions will only contain
I have verified that the merge of I am happy to put together a PR but I need a little guidance on how to proceed. Thanks! |
Wow, thanks for that thorough investigation! Fixing it by capitalising a name doesn't seem ideal - especially as that will break all of people's existing config set with the lowercase name. Also, all other config options are lowercase. I'll have a go at thinking of a better way. I'd like to hear @minrk's thoughts too. |
The JSON config files for traitlets don't support merging items (setting to an empty dict needs to be possible for override in general). The frontend-specific I'm not sure of a decent way to fix this beyond moving the nbserver_extensions off of traitlets to the nbconfig loader, and I'm not sure we want to change how we do this yet again for 5.0. Conceivably, we could use that loader on the regular config files, but that seems like asking for trouble. I can sketch it out, if we think it's worth investigating, though. |
#2108 implements the last idea - use ConfigManager to load a merged config for nbserver_extensions, so it behaves like frontend extensions. It's not my favorite thing, but it gets the behavior we want, and might be worth the ickiness. |
Wait, this means that all of the |
Yes, traits in config are singletons, only class config is merged, so if you have: c.App.trait = {'a': 1} at one config level, and c.App.trait = {'b': 2} at another, the assignment at the later point takes precedent, and the result is the second assignment The best way to think about traitlets config loading is a series of consecutive assignments. If dict traits were always merged, there would be no way to specify that a value in higher-level config should not be there. Extensions work because the values are bools, and having a False value is equivalent to having removed that value. That's not true of dicts in general. |
In that case I don't think we should special-case the server extensions key amongst the others, as it will only worsen the existing confusion. |
@blink1073 would you prefer to move serverextensions over to the |
Yes, with a deprecation of the existing trait that still uses the current config data if it exists (removed in 6.0). |
What if instead we made a separate Dict-based Trait that had different semantics for merging? |
Then we could cleanly mark which parts of the config are merge-able. |
That would be a great solution. Unfortunately, the config object has finished merging before it knows which traits each value is for. @SylvainCorlay has plans for a different extension mechanism (based on #1706) for the separated Jupyter Server, and I'm a bit reticent to add another extension mechanism at the last minute for notebook 5.0 that we are going to deprecate immediately after releasing it, and there doesn't seem to be time between now and and 5.0 to fully implement #1706, since there's lots of changes regarding defaults, etc. Solving just the merge issue should be pretty simple - either by applying it in a band-aid fashion to the existing field (#2108) or moving it to nbconfig. |
I am 👎 to moving server-specific configuration to |
If two extensions are installed, one with flag
--user
and another with--sys-prefix
, then they are both listed byjupyter nbextension list
, but only one is actually loaded when the server starts. I suspect the configuration objects are being over-written rather than merged.See the following issue for more details: OpenGeoscience/geonotebook#70
The text was updated successfully, but these errors were encountered: