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

adding jupyterlab file paths for preview #925

Merged
merged 2 commits into from
Aug 15, 2019

Conversation

choldgraf
Copy link
Member

closes #645

I think that this should add support for JupyterLab paths in the nbviewer preview.

It is pretty simple, basically just adds a few lines to:

  • Check whether urlpath is provided in the URL
  • If so, check whether lab/tree/ exists in the urlpath
  • If so, set filepath to whatever is on the right side of lab/tree/.

I think this should work for at least vanilla jupyterlab paths. It might break in unpredicted ways if people start using jupyterlab but also other kinds of URL patterns, but we can beef up this function when we get to those situations.


# Check if we have a JupyterLab + file path, if so then use it for the filepath
urlpath = self.get_argument('urlpath', '').lstrip('/')
if 'lab/tree/' in urlpath:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if 'lab/tree/' in urlpath:
if urlpath.startswith("lab/tree"):

would this be an improvement/less prone to matching accidentally?

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 was originally doing it this way to allow for workspaces in the url too, but upon looking it seems like that'd actually be a more complicated rule. What if instead we did something like:

if urlpath.startswith("lab") and `/tree/` in urlpath:

and then do the split on /tree/ and take whatever is to the right of the first instance of /tree/?

Copy link
Member Author

@choldgraf choldgraf Aug 13, 2019

Choose a reason for hiding this comment

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

this is now in the latest push, it seemed to work for me locally (both regular lab URLs and workspace URLs)

Copy link
Member

Choose a reason for hiding this comment

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

What different kinds of URLs could we get here? I am not really familiar with what Jupyter Lab does/what workspaces are :-/

Copy link
Member Author

Choose a reason for hiding this comment

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

See the link I sent above, that's what I was using to figure out what urls to expect

@betatim
Copy link
Member

betatim commented Aug 14, 2019

Merge? If you've tested it locally I'd be happy to press merge and see what happens. Investigating and learning about URL schemes and how they could go wrong seems like a high effort thing compared to the worst that could happen if we just deploy it.

@choldgraf
Copy link
Member Author

I'm +1 on merging, the only thing that can go wrong is that it doesn't work, which would be our current situation :-)

@betatim betatim merged commit 8f31091 into jupyterhub:master Aug 15, 2019
yuvipanda pushed a commit to jupyterhub/helm-chart that referenced this pull request Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preview not working for Jupyter Lab link
2 participants