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

Attempted fix for minor JupyterHub compatibility issue. #6931

Merged
merged 6 commits into from Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions jupyterlab/extension.py
Expand Up @@ -211,6 +211,9 @@ def load_jupyter_server_extension(nbapp):
page_config['hubPrefix'] = nbapp.hub_prefix
page_config['hubHost'] = nbapp.hub_host
page_config['hubUser'] = nbapp.user
# Assume the server_name property indicates running JupyterHub 1.0.
if hasattr(nbapp, 'server_name'):
page_config['hubServerName'] = nbapp.server_name
api_token = os.getenv('JUPYTERHUB_API_TOKEN', '')
page_config['token'] = api_token

Expand Down
2 changes: 2 additions & 0 deletions packages/application/src/frontend.ts
Expand Up @@ -274,6 +274,8 @@ export namespace JupyterFrontEnd {
readonly workspaces: string;
readonly hubPrefix?: string;
readonly hubHost?: string;
readonly hubUser?: string;
readonly hubServerName?: string;
};

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/application/src/lab.ts
Expand Up @@ -246,7 +246,9 @@ export namespace JupyterLab {
tree: PageConfig.getOption('treeUrl'),
workspaces: PageConfig.getOption('workspacesUrl'),
hubHost: PageConfig.getOption('hubHost') || undefined,
hubPrefix: PageConfig.getOption('hubPrefix') || undefined
hubPrefix: PageConfig.getOption('hubPrefix') || undefined,
hubUser: PageConfig.getOption('hubUser') || undefined,
hubServerName: PageConfig.getOption('hubServerName') || undefined
},
directories: {
appSettings: PageConfig.getOption('appSettingsDir'),
Expand Down
13 changes: 7 additions & 6 deletions packages/hub-extension/src/index.ts
Expand Up @@ -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.
Expand All @@ -54,13 +56,12 @@ function activateHubExtension(
hubPrefix: hubPrefix
});

const { commands } = app;
// If hubServerName is set, use JupyterHub 1.0 URL.
const restartUrl = hubServerName
? hubHost + URLExt.join(hubPrefix, 'spawn', hubUser, hubServerName)
: hubHost + URLExt.join(hubPrefix, `spawn?next=${hubPrefix}home`);

// TODO: use /spawn/:user/:name
// but that requires jupyterhub 1.0
// and jupyterlab to pass username, servername to PageConfig
const restartUrl =
hubHost + URLExt.join(hubPrefix, `spawn?next=${hubPrefix}home`);
const { commands } = app;

commands.addCommand(CommandIDs.restart, {
label: 'Restart Server',
Expand Down