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
Attempted fix for minor JupyterHub compatibility issue. #6931
Conversation
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
We actually rely on named servers in our JupyterHub deployment, so this is actually presenting an issue right now. |
Do we know how widespread jupyterhub 1.0 is? This seems like it demands jhub 1.0, so we might not be able to do it until jupyterlab 2.0 for backwards compatibility. Is there a way to support jupyterhub 1.0 and previous jupyterhub? |
jupyterlab/extension.py
Outdated
@@ -211,6 +211,7 @@ def load_jupyter_server_extension(nbapp): | |||
page_config['hubPrefix'] = nbapp.hub_prefix | |||
page_config['hubHost'] = nbapp.hub_host | |||
page_config['hubUser'] = nbapp.user | |||
page_config['hubServerName'] = nbapp.server_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a guard here for hasattr(nbapp, 'server_name')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that the default server name is the empty string (as @rcthomas said). If URLExt.join is smart and ignores empty strings as a no-op then presumably such a switch would be unnecessary. That being said I am not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the issue is that the server wouldn't have that attribute if it was just a single person running JupyterLab on their laptop, then why aren't guards hasattr(nbapp, 'hub_prefix')
, hasattr(nbapp, 'hub_host')
, and hasattr(nbapp, 'user')
also necessary? I'm a little confused.
If the issue is that it might not have that attribute when JupyterHub is being run, I don't think that's possible although I guess better safe than sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is to check whether the property exists as a way to detect whether we are using jupyterhub 1.0 or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright then it seems like it might not be necessary since the server_name
attribute existed pre-1.0. jupyterhub/jupyterhub#2089
I think it was called name
before my PR (although I'm not 100%), but it was in master at least as early as September 2018.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was in master at least as early as September 2018.
FYI, it looks like that PR was merged and released starting with 1.0 (jupyterhub/jupyterhub@f2fa067 - see the tags that contain that commit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasongrout Oh oops, you're right. I'm not very good with understanding how the versioning for these things work. Just because it was merged doesn't mean it was in the current most recent release for that time. It does make sense, since the UI for named servers only showed up with 1.0 and not any earlier versions.
Now I feel dumb. I thought changing the name from name
to server_name
would make the code easier to understand/work with, but that seems to not have been the case. Anyway @blink1073 is definitely right about needing the hasattr
. Sorry about that; I think I'm getting overly defensive/insecure about the changes I made/proposed.
packages/hub-extension/src/index.ts
Outdated
const restartUrl = | ||
hubHost + URLExt.join(hubPrefix, `spawn?next=${hubPrefix}home`); | ||
hubHost + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we switch here on whether there is a server name and choose the simplified url if there isn't one? Does the simplified url work in jupyterhub 1.0?
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope sorry I think I was wrong: https://github.com/jupyterhub/jupyterhub/blob/1a26c1fb817f44acffd3907d0ec94d7de115c2e6/jupyterhub/handlers/pages.py#L131
You're right that switch is the right approach as far as I can tell.
@jasongrout The fix also needs to work for JupyterHub>=1 where the JupyterHub config doesn't have named servers turned on (it's off by default). One way of looking at it is that the default server already has a name, it's just "" (empty string). We're going to try to get a test set up of this hopefully today and I'm thinking we'll test against JupyterHub 1 with named servers turned off to make sure everything is right. That said, what version of Hub would be late enough for compatibility? 0.9.6? Thanks! |
My big concern is that people may have deployed jlab 1.0 already to jhub 0.x, and it stops working in a minor update to jlab. What version of jhub do we support currently? 0.9.0 was released a year ago - is there any difference in supporting 0.9.0 vs 0.9.6? A year seems like a reasonable support timeline. |
(We should make our support for a specific version of jhub explicit in the docs somewhere, and perhaps even in the setup.py and/or conda recipe if we can) |
what I had suggested would support both pre and post 1.0 of jupyterhub, but I agree in principle about being explicit. |
I am not sure if JupyterHub compatibility is actually an issue, since JupyterHub has supported named servers via an API (and thus the URLs) for a while, with the default server name just being the empty string (e.g. when named servers are turned off or none exist). The only change in 1.0 is the existence of a UI for named servers. jupyterhub/jupyterhub#2089 That having been said the important thing for me to do right now first would be to test this to make sure it works the way I expect/think it does. EDIT: See this line in the JupyterHub source -- the |
How does I.e. what is My guess is that there'd be a problem with the PR in the former case but not necessarily the latter. |
@krinsman was reporting some issues on NERSC's deployment running this PR that I wasn't seeing on my separate fork. I think the only differences between this PR and my fork were that I'd added the Now that I have gained push rights here, I went ahead and implemented those changes so that at least @krinsman and I are on the same page. I still think it's worth considering his comments above questioning what makes these changes necessary. EDIT: To be clearer, he was reporting trouble launching lab to begin with, whereas I have only seen trouble with server restarts (which these changes have yet to remedy) |
If y'all get it working with both JupyterHub 1.0 and pre-1.0, I'll make a backport release of JupyterLab 1.0 with this change. Thanks for working on this! |
I think there were some bugs @rcthomas resolved in jupyterhub/jupyterhub#2682 and issues with our setup at NERSC that were making it difficult to test the behavior of the restart flow due to the JupyerLab code in isolation before. Now that I am able to play with it, I don't think the following code is quite right (as proposed):
When Removing
I don't yet have a good understanding of why we might want to keep the |
What is the behavior with a named server when you do not specify |
@tslaton This sounds right to me -- I added the last Have you added/merged those changes into the PR? This page seems to explain it the best, although doesn't really address the
EDIT: Actually probably the more relevant portion of the page for our case:
I think the big takeaway here would be that the routing/redirects actually are substantially different between pre- and post-1.0, so it's understandable why this has been more difficult than expected. (At least I personally had incorrectly assumed that they were largely the same.) |
Case 1: Restarting a named server with I had been getting a 404 error attempting this previously, but that was due to an extra Case 2: Restarting a named server without I think the second case is the behavior I'd expect to see. EDIT: The changes required to the PR if we desire Case 1 behavior are simply removing an extra |
I think it is fair to have different behavior between pre-1.0 and post-1.0. I actually agree with |
Unless the failing tests pose an issue (not sure they're related to this PR), it should be ready now. It follows the |
LGTM, thanks! |
@meeseeksdev please backport to 1.0.x |
@meeseeksdev backport to 1.0.x |
…tibility issue.
…1-on-1.0.x Backport PR #6931 on branch 1.0.x (Attempted fix for minor JupyterHub compatibility issue.)
This is an attempt to address the TODO in
/packages/hub-extension/src/index.ts
.