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

Do not violently remove config_dir kwarg of config manager. #899

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import sys
import threading
import webbrowser
import warnings


from jinja2 import Environment, FileSystemLoader
Expand Down Expand Up @@ -825,10 +826,28 @@ def init_configurables(self):
kernel_manager=self.kernel_manager,
contents_manager=self.contents_manager,
)
self.config_manager = self.config_manager_class(
parent=self,
log=self.log
)
if self.config_manager_class is ConfigManager:
# We know our ConfigManager ignore `config_dir`,
# and will warn/raise a PendingDeprecation warning
# if given, so do not pass it (not to annoy user and show the
# warning on default install. .
self.config_manager = self.config_manager_class(
parent=self,
log=self.log,
)
else :
# In case it is a custom ConfigManager,
# for potentially not breaking future backward
# compatibility, will still pass it.
if issubclass(self.config_manager_class, ConfigManager):
warnings.warn('Object `%s` will be passed a `config_dir` kwarg, which might be removed'
'in future Notebook versions. Please make sure to handle this case.' % (self.config_manager_class),)
self.config_manager = self.config_manager_class(
parent=self,
log=self.log,
config_dir=os.path.join(self.config_dir, 'nbconfig'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the whole thing... we don't need the config_dir from the notebookapp for the custom ConfigManager... this is my simple implementation of a CustomConfig manager: https://github.com/Anaconda-Server/nb_config_manager/blob/master/nb_config_manager/nb_config_manager.py

Since the config_dir is "calculated" inside the ConfigManager class (by the _config_dir_default), my subclass take that info and make further modifications from there... so, we are happy with just the if branch above, where the config_dir is not harcoded at the notebook level... maybe I am not clear enough in my explanations... sorry about that.

Check my comment in #893 (comment), with that diff you keep the things as now (I mean, not config option at the ConfigManager and the default config pointing to the user space), but you "hardcode" the config_dir at the ConfigManager level, so we can then subclass and just setup the config_dir to our desires without touching the notebookapp at all...

)


def init_logging(self):
# This prevents double log messages because tornado use a root logger that
Expand Down
9 changes: 9 additions & 0 deletions notebook/services/config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
from jupyter_core.paths import jupyter_config_dir
from traitlets import Unicode

import warnings

class ConfigManager(BaseJSONConfigManager):
"""Config Manager used for storing notebook frontend config"""

def __init__(self, **kwargs):

if kwargs.get('config_dir', None) is not None:
warnings.warn('ConfigManager `config_dir` kwarg will likely have no effect and might be removed in future Notebook versions.')
super(ConfigManager, self).__init__(**kwargs)


config_dir = Unicode(config=True)
def _config_dir_default(self):
Expand Down