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

add notebook_dir as trait to be deprecated #36

Merged
merged 3 commits into from
Dec 14, 2019

Conversation

Zsailer
Copy link
Member

@Zsailer Zsailer commented Nov 30, 2018

This fixes issue #35.

@validate('notebook_dir')
def _update_notebook_dir(self, change):
self.log.warning(_("\n notebook_dir is deprecated, use root_dir.\n"))
self.root_dir = change['value']
Copy link
Contributor

Choose a reason for hiding this comment

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

  • With this behavior, there may be an issue when setting root_dir, and reading notebook_dir.

  • Maybe an observer on root_dir setting the notebook_dir trait through set_trait (bypassing validation) would be better.

  • However, we should be careful about incompatible setting of one vs the other?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, that should be an observe decorator.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, you're right. If root_dir changes, notebook_dir doesn't change.

I think setting notebook_dir in the root_dir observer should fix that. Why bypass validation? They should end up having the same validation logic right?

Copy link
Member Author

Choose a reason for hiding this comment

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

How about adding a

if self.notebook_dir != change['new']:
    self.notebook_dir = change['new']

to the root_dir observer, and

if self.root_dir != change['new']:
    self.root_dir = change['new']

to the notebook_dir observer?

Copy link
Member Author

Choose a reason for hiding this comment

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

This ensures the traits are equal.

Copy link
Contributor

Choose a reason for hiding this comment

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

I need to do some experiments. But it is not trivial.

Copy link
Member Author

Choose a reason for hiding this comment

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

totally agree it's not trivial.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the check above if you want to test it. Just checks notebook_dir and root_dir are equal. If not, update the other trait.

@Zsailer
Copy link
Member Author

Zsailer commented Dec 3, 2018

@SylvainCorlay

The pattern used in the classic notebook is to observe the deprecated trait for changes; when it is changed 1) warn the user and 2) allow it to change the new trait. Changing the new trait does not update the deprecated trait.

Two examples in the classic notebook are base_project_url and server_extensions.

Should I simply follow that pattern here?

@observe('notebook_dir')
def _update_notebook_dir(self, change):
    self.log.warning(_('deprecation_warning'))
    self.root_dir = change['new']

@SylvainCorlay
Copy link
Contributor

Should I simply follow that pattern here?

I think we can do that.

@krinsman
Copy link
Contributor

Will deprecating and then eventually removing notebook_dir make this incompatible with JupyterHub, and thus prevent jupyter_server from being used as a backend for jupyterhub-singleuser/SingleUserNotebookApp?

JupyterHub uses it in a pretty essential way, since that's what c.Spawner.notebook_dir hooks into:
https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/spawner.py#L467
https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/spawner.py#L930

@Zsailer
Copy link
Member Author

Zsailer commented Dec 14, 2019

Will deprecating and then eventually removing notebook_dir make this incompatible with JupyterHub

@krinsman. We'll have to change this trait in JupyterHub, too.

@Zsailer
Copy link
Member Author

Zsailer commented Dec 14, 2019

I think we can do that.

👍 @SylvainCorlay merging.

@Zsailer Zsailer merged commit 3a98032 into jupyter-server:master Dec 14, 2019
@Zsailer Zsailer deleted the notebook_dir branch January 10, 2020 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants