Skip to content

Commit 5a28ec1

Browse files
committed
only use deprecated notebook_dir config if root_dir is not set
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
1 parent 2477da6 commit 5a28ec1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

jupyter_server/serverapp.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,16 +1232,22 @@ def _update_pylab(self, change):
12321232

12331233
@observe('notebook_dir')
12341234
def _update_notebook_dir(self, change):
1235+
if self._root_dir_set:
1236+
# only use deprecated config if new config is not set
1237+
return
12351238
self.log.warning(_("notebook_dir is deprecated, use root_dir"))
12361239
self.root_dir = change['new']
12371240

1238-
root_dir = Unicode(config=True,
1241+
root_dir = Unicode(
1242+
config=True,
12391243
help=_("The directory to use for notebooks and kernels.")
12401244
)
1245+
_root_dir_set = False
12411246

12421247
@default('root_dir')
12431248
def _default_root_dir(self):
12441249
if self.file_to_run:
1250+
self._root_dir_set = True
12451251
return os.path.dirname(os.path.abspath(self.file_to_run))
12461252
else:
12471253
return py3compat.getcwd()
@@ -1262,6 +1268,10 @@ def _root_dir_validate(self, proposal):
12621268
raise TraitError(trans.gettext("No such notebook dir: '%r'") % value)
12631269
return value
12641270

1271+
@observe('root_dir')
1272+
def _root_dir_changed(self, change):
1273+
self._root_dir_set = True
1274+
12651275
@observe('server_extensions')
12661276
def _update_server_extensions(self, change):
12671277
self.log.warning(_("server_extensions is deprecated, use jpserver_extensions"))

0 commit comments

Comments
 (0)