-
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
merge nbserver_extensions #2108
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad01950
Merge nbserver_extensions
minrk 1797f34
test merging serverextensions from sys and user config
minrk e70e7be
remove unused code in nbextensions
minrk fde1c6e
handle self.config_dir and self.config_file_name in server_extensions
minrk 6b4ec57
Fix typos.
Carreau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,7 @@ | |
from jupyter_core.application import ( | ||
JupyterApp, base_flags, base_aliases, | ||
) | ||
from jupyter_core.paths import jupyter_config_path | ||
from jupyter_client import KernelManager | ||
from jupyter_client.kernelspec import KernelSpecManager, NoSuchKernel, NATIVE_KERNEL_NAME | ||
from jupyter_client.session import Session | ||
|
@@ -1232,9 +1233,28 @@ def init_server_extensions(self): | |
# in the new traitlet | ||
if not modulename in self.nbserver_extensions: | ||
self.nbserver_extensions[modulename] = True | ||
|
||
for modulename in sorted(self.nbserver_extensions): | ||
if self.nbserver_extensions[modulename]: | ||
|
||
# Load server extensions with ConfigManager. | ||
# This enables merging on keys, which we want for extension enabling,. | ||
# Regular config loading only merges at the class level, | ||
# so each level (use > env > system) clobbers the previous. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User* There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. r'd |
||
config_path = jupyter_config_path() | ||
if self.config_dir not in config_path: | ||
# add self.config_dir to the front, if set manually | ||
config_path.insert(0, self.config_dir) | ||
manager = ConfigManager(read_config_path=config_path) | ||
section = manager.get(self.config_file_name) | ||
extensions = section.get('NotebookApp', {}).get('nbserver_extensions', {}) | ||
|
||
for modulename, enabled in self.nbserver_extensions.items(): | ||
if modulename not in extensions: | ||
# not present in `extensions` means it comes from Python config, | ||
# so we need to add it. | ||
# Otherwise, trust ConfigManager to have loaded it. | ||
extensions[modulename] = enabled | ||
|
||
for modulename, enabled in sorted(extensions.items()): | ||
if enabled: | ||
try: | ||
mod = importlib.import_module(modulename) | ||
func = getattr(mod, 'load_jupyter_server_extension', None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Extra comma at the end
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.
removed.