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

JupyterHub with username/password #14367

Closed
3 of 6 tasks
DonJayamanne opened this issue Sep 26, 2023 · 7 comments
Closed
3 of 6 tasks

JupyterHub with username/password #14367

DonJayamanne opened this issue Sep 26, 2023 · 7 comments

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Sep 26, 2023

Refs: #13973

Complexity: 5

Authors: @DonJayamanne

Create Issue


Pre-Requisites

  • Install VS Code insiders
  • Jupyter pre-relese extension
  • JupyterHub extension

Install and launch Jupyter Hub

https://jupyterhub.readthedocs.io/en/1.2.0/installation-guide-hard.html

  1. Create a new folder
  2. Create a file named jupyterhub_config.py and paste the below contents into that file
    1. Custom config to make auth easier, else you need use your login creds, which I guess you don't want to use.
# Configuration file for jupyterhub.

c = get_config()  #noqa
c.JupyterHub.authenticator_class = 'jupyterhub.auth.DummyAuthenticator'
c.DummyAuthenticator.password = "pwd" # Feel free to change the default password
c.Spawner.args = ['--NotebookApp.allow_origin=*']
from jupyterhub.spawner import SimpleLocalProcessSpawner
c.JupyterHub.spawner_class = SimpleLocalProcessSpawner
  1. Create a virtual env in this folder using Python extension
  2. Install Jupyterhub using the CLI python -m pip install jupyterlab jupyterhub
  3. Install the npm package configurable-http-proxy globally via the cli npm i -g configurable-http-proxy
  4. Now start Jupyter Hub using the cli jupyterhub (ensuring the cwd in the terminal is the same folder in step 1 and your virtual env is in the same folder under .venv)
  5. In the browser navigate to Jupyter Hub login page, genrally http://localhost:8000

Note:

  • There is no need to log into JupyterHub

Steps to test

  1. Go into VS Code, open a notebook
  2. From the kernel picker select Existing JupyterHub Server...
  3. Enter the Jupyter Hub Url http://localhost:8000 (that shouldbe all)
  4. Verify you are prompted for your user name and password (remember password is pwd)
    Note: Remember to use the same user name (else it will not work, these are things to be ironed out later)
  5. Verify you now get a list of Kernels in the kernel picker
  6. Verify you can select a kernel and run code against this kernel
@DonJayamanne DonJayamanne added the bug Issue identified by VS Code Team member as probable bug label Sep 26, 2023
@DonJayamanne DonJayamanne changed the title Jupyter Hub with username/password JupyterHub with username/password Sep 26, 2023
@DonJayamanne DonJayamanne added this to the September 2023 milestone Sep 26, 2023
@DonJayamanne DonJayamanne removed the bug Issue identified by VS Code Team member as probable bug label Sep 26, 2023
@ghost ghost assigned rebornix, amunger and joyceerhl Sep 26, 2023
@amunger
Copy link
Contributor

amunger commented Sep 26, 2023

Remember to use the same user name

The same as what? My windows username does not work.
Also tried adding c.DummyAuthenticator.username to the config without success

@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Sep 26, 2023

Also tried adding c.DummyAuthenticator.username to the config without success

Looks like Jupyterhub doesn't work on windows,
Please could you try swapping with one of the Python ext engineers or please try WSL or linux
I recall Joyce too running into issues with windows.

The same as what? My windows username does not work.

The same as your standard windows user name.

@DonJayamanne
Copy link
Contributor Author

@amunger perhaps you can try codespaces, see Joyces comment here #14202 (comment)

@joyceerhl
Copy link
Contributor

I couldn't validate this in web--I started a JupyterHub server on a codespace and made the port public, but JupyterHub in web throws a CORS error when connecting to this URL. IMHO this scenario should work:

Access to fetch at 'https://potential-guacamole-4gpg4g6xx53jx55-8000.preview.app.github.dev/hub/api' from origin 'https://v--1spn32jgg8dd74pu3nk0781ur063qr0kcgsei7j1lqn7jmf4leqi.vscode-cdn.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

image

I was able to test this "locally" by running a JupyterHub server on a codespace and forwarding the port privately

@rebornix
Copy link
Member

I can get it working on macOS. The setting I use to launch jupyter hub is as below, so I was able to use user name dummy and password pwd to connect to the Hub.

c.JupyterHub.authenticator_class = "dummy"
c.DummyAuthenticator.password = "pwd" # Feel free to change the default password
c.Spawner.args = ['--NotebookApp.allow_origin=*']
c.Spawner.default_url = '/lab'
from jupyterhub.spawner import SimpleLocalProcessSpawner
c.JupyterHub.spawner_class = SimpleLocalProcessSpawner

@rebornix rebornix removed their assignment Sep 26, 2023
@amunger
Copy link
Contributor

amunger commented Sep 26, 2023

WSL did not work, but I was able to use the same technique as Joyce.
Pretty sure I needed to log in to the browser first to get the username/password to work though, it sounds like Joyce did as well.

@amunger amunger removed their assignment Sep 26, 2023
@amunger amunger closed this as completed Sep 26, 2023
@DonJayamanne
Copy link
Contributor Author

Pretty sure I needed to log in to the browser first to get the username/password to work though, it sounds like Joyce did as well.

Thanks for that comment @amunger , I found the reason why you'd have to do that, created an issue to try and address that at least in desktop (for vscode.dev there's nothing we can do about it)
microsoft/vscode-jupyter-hub#29

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants