Skip to content

Commit

Permalink
only use deprecated notebook_dir config if root_dir is not set
Browse files Browse the repository at this point in the history
if an existing jupyter_notebook_config file sets notebook_dir, this would override explicit setting of root_dir,
as the deprecated value was used even when the new value was also set
  • Loading branch information
minrk committed Feb 3, 2021
1 parent 479c8d3 commit db4f597
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,16 +1232,22 @@ def _update_pylab(self, change):

@observe('notebook_dir')
def _update_notebook_dir(self, change):
if self._root_dir_set:
# only use deprecated config if new config is not set
return
self.log.warning(_("notebook_dir is deprecated, use root_dir"))
self.root_dir = change['new']

root_dir = Unicode(config=True,
root_dir = Unicode(
config=True,
help=_("The directory to use for notebooks and kernels.")
)
_root_dir_set = False

@default('root_dir')
def _default_root_dir(self):
if self.file_to_run:
self._root_dir_set = True
return os.path.dirname(os.path.abspath(self.file_to_run))
else:
return py3compat.getcwd()
Expand All @@ -1262,6 +1268,10 @@ def _root_dir_validate(self, proposal):
raise TraitError(trans.gettext("No such notebook dir: '%r'") % value)
return value

@observe('root_dir')
def _root_dir_changed(self, change):
self._root_dir_set = True

@observe('server_extensions')
def _update_server_extensions(self, change):
self.log.warning(_("server_extensions is deprecated, use jpserver_extensions"))
Expand Down

0 comments on commit db4f597

Please sign in to comment.