Skip to content

Commit

Permalink
Do not violently remove config_dir kwarg of config manager.
Browse files Browse the repository at this point in the history
though, jupyter#893 argues that we might need it and that it will be complex to
reintroduce it.

This use a convoluted way to :

 - warn that this kwarg might not be given to config managers in future version
 - but do not warn on default installs with default config.
 - warn that the keyword is ignored when people use subclasses of out
   config manager, and pass the keyword to super().

Thus this actually advertise that the keyword **might** be removed,
by still allowing us to keep it if in the end it appears that we need
it.

Should help with jupyter#893 without un-fixing jupyter#882.
  • Loading branch information
Carreau committed Dec 24, 2015
1 parent a963647 commit ccb0936
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
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'),
)


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

0 comments on commit ccb0936

Please sign in to comment.