Skip to content

Commit a94c8b8

Browse files
authored
Jupyter hub preliminary support (microsoft#12574)
* Move request header generation into password generation * Connecting to token api * Working jupyter hub connection * Use multistep input * Remove token on shutdown * Support certificate checking * Skip waiting on shutdown * Get old unit tests passing again * Fix xsrf token to remove extra cookie crap * Test plan changes and new unit test * Fix linter and input box result * Fix sonar warning * Review feedback * Actually cookie not sent back for hub
1 parent 2f5234a commit a94c8b8

13 files changed

Lines changed: 515 additions & 135 deletions

File tree

.github/test_plan.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,37 @@ def test_failure():
575575
1. Open the notebook editor on the host
576576
1. Run a cell on the host
577577
1. Verify the editor opens on the guest and the cell is run there too
578+
- [ ] Jupyter Hub support
579+
1. Install Docker Desktop onto a machine
580+
1. Create a folder with a file 'Dockerfile' in it.
581+
1. Mark the file to look like so:
582+
583+
```
584+
ARG BASE_CONTAINER=jupyterhub/jupyterhub
585+
FROM $BASE_CONTAINER
586+
587+
USER root
588+
589+
USER $NB_UID
590+
```
591+
592+
1. From a command prompt (in the same folder as the Dockerfile), run ```docker build -t jupyterhubcontainer:1.0 .```
593+
1. Run ```docker container create --name jupyterhub jupyterhubcontainer:1.0 jupyterhub```
594+
1. From the docker desktop app, start the jupyterhub container.
595+
1. From the docker desktop app, run the CLI
596+
1. From the new command prompt, run ```adduser testuser```
597+
1. Follow the series of prompts to add a password for this user
598+
1. Open VS code
599+
1. Open a folder with a python file in it.
600+
1. Run the ```Python: Specify local or remote Jupyter server for connections``` command.
601+
1. Pick 'Existing'
602+
1. Enter ```http://localhost:8000``` (assuming the jupyter hub container was successful in launching)
603+
1. Reload VS code and reopen this folder.
604+
1. Run a cell in a python file.
605+
[ ] Verify results
606+
1. Verify you are asked first for a user name and then a password.
607+
1. Verify a cell runs once you enter the user name and password
608+
1. Verify that the python that is running in the interactive window is from the docker container (if on windows it should show a linux path)
578609
579610
#### P2 Test Scenarios
580611

news/1 Enhancements/9679.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Support connecting to Jupyter hub servers. Use either the base url of the server (i.e. 'https://111.11.11.11:8000') or your user folder (i.e. 'https://111.11.11.11:8000/user/theuser).
2+
Works with password authentication.

package.nls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@
249249
"DataScience.jupyterInstall": "Install",
250250
"DataScience.jupyterSelectURIPrompt": "Enter the URI of the running Jupyter server",
251251
"DataScience.jupyterSelectURIInvalidURI": "Invalid URI specified",
252-
"DataScience.jupyterSelectPasswordPrompt": "Enter your notebook password",
252+
"DataScience.jupyterSelectUserAndPasswordTitle": "Enter your user name and password to connect to Jupyter Hub",
253+
"DataScience.jupyterSelectUserPrompt": "Enter your user name",
254+
"DataScience.jupyterSelectPasswordPrompt": "Enter your password",
253255
"DataScience.jupyterNotebookFailure": "Jupyter notebook failed to launch. \r\n{0}",
254256
"DataScience.jupyterNotebookConnectFailed": "Failed to connect to Jupyter notebook. \r\n{0}\r\n{1}",
255257
"DataScience.jupyterNotebookRemoteConnectFailed": "Failed to connect to remote Jupyter notebook.\r\nCheck that the Jupyter Server URI setting has a valid running server specified.\r\n{0}\r\n{1}",

src/client/common/utils/localize.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,14 @@ export namespace DataScience {
525525
'DataScience.jupyterSelectURINotRunningDetail',
526526
'Cannot connect at this time. Status unknown.'
527527
);
528+
export const jupyterSelectUserAndPasswordTitle = localize(
529+
'DataScience.jupyterSelectUserAndPasswordTitle',
530+
'Enter your user name and password to connect to Jupyter Hub'
531+
);
532+
export const jupyterSelectUserPrompt = localize('DataScience.jupyterSelectUserPrompt', 'Enter your user name');
528533
export const jupyterSelectPasswordPrompt = localize(
529534
'DataScience.jupyterSelectPasswordPrompt',
530-
'Enter your notebook password'
535+
'Enter your password'
531536
);
532537
export const jupyterNotebookFailure = localize(
533538
'DataScience.jupyterNotebookFailure',

src/client/common/utils/multiStepInput.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface IQuickPickParameters<T extends QuickPickItem> {
3939
// tslint:disable-next-line: interface-name
4040
export interface InputBoxParameters {
4141
title: string;
42+
password?: boolean;
4243
step?: number;
4344
totalSteps?: number;
4445
value: string;
@@ -155,6 +156,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
155156
value,
156157
prompt,
157158
validate,
159+
password,
158160
buttons,
159161
shouldResume
160162
}: P): Promise<MultiStepInputInputBoxResponseType<P>> {
@@ -165,6 +167,7 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
165167
input.title = title;
166168
input.step = step;
167169
input.totalSteps = totalSteps;
170+
input.password = password ? true : false;
168171
input.value = value || '';
169172
input.prompt = prompt;
170173
input.ignoreFocusOut = true;

src/client/datascience/jupyter/jupyterExecution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export class JupyterExecutionBase implements IJupyterExecution {
363363
}
364364
} else {
365365
// If we have a URI spec up a connection info for it
366-
return createRemoteConnectionInfo(options.uri, this.configuration.getSettings(undefined).datascience);
366+
return createRemoteConnectionInfo(options.uri);
367367
}
368368
}
369369

0 commit comments

Comments
 (0)