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
Changes from 1 commit
b750683
f32a57e
fcc893c
b4f5d2c
d9f7b9e
e3644c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,8 @@ function activateHubExtension( | |
): void { | ||
const hubHost = paths.urls.hubHost || ''; | ||
const hubPrefix = paths.urls.hubPrefix || ''; | ||
const hubUser = paths.urls.hubUser || ''; | ||
const hubServerName = paths.urls.hubServerName || ''; | ||
const baseUrl = paths.urls.base; | ||
|
||
// Bail if not running on JupyterHub. | ||
|
@@ -56,11 +58,16 @@ function activateHubExtension( | |
|
||
const { commands } = app; | ||
|
||
// TODO: use /spawn/:user/:name | ||
// but that requires jupyterhub 1.0 | ||
// and jupyterlab to pass username, servername to PageConfig | ||
// requires jupyterhub 1.0 | ||
const restartUrl = | ||
hubHost + URLExt.join(hubPrefix, `spawn?next=${hubPrefix}home`); | ||
hubHost + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
URLExt.join( | ||
hubPrefix, | ||
`spawn`, | ||
hubUser, | ||
hubServerName, | ||
`?next=${hubPrefix}home` | ||
); | ||
|
||
commands.addCommand(CommandIDs.restart, { | ||
label: 'Restart Server', | ||
|
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.
See here: https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/singleuser.py#L449
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')
, andhasattr(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#2089I 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.
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
toserver_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 thehasattr
. Sorry about that; I think I'm getting overly defensive/insecure about the changes I made/proposed.