JupyterHub can integrate with VSCode, which might be useful for certain situations such as research, or lab environments where keeping the files locally is preferred. This might be where predictability and consistency are desired for the runtime environments, or where you need more resources than what you have locally. In fact, Python and R don't even need to be installed on the machine at all.
Caveats to this Method
Users won't have direct access to the files inside the container. This isn't an issue if they're solely working from inside of VSCode, but you should make note of these limitations before electing to use this method:
- Professors, TA's and other Admins won't be able to access your instance to troubleshoot or review your code since you're running code from your local computer. Unless it's a very small sized class, it's likely that this method won't be the best solution for you. TAs and other admins won't be able to troubleshoot or check your work without gaining access to your personal device by either physically obtaining it, or using some other software gain remote access to your computer.
- Files and code stay local. If the data you're working with changes frequently, then it may be a challenge to constantly re-uploading and replacing data through the web interface. Likewise, there are no safeguards, like data encryption, which may be a requirement for some research datasets.
- Your work has no backup from UCSB. When you elect to use VSCode, you choose to not store data in our cloud storage, so there's no backups or redundancy for keeping your data. You'll need to ensure that you data can survive hardware failure, disaster, or theft.
How-To Setup VSCode and JupyterHub
- Download and install VSCode
- Install the VSCode Jupyter extension. Click on the extensions on the sidebar (Or View > Extensions) , search for Jupyter, then click on the blue install button.
- Generate an API token from your JupyterHub instance.
- Go to your JupyterHub instance and log in to the web page. The address should be something like https://example.lsit.ucsb.edu
- Edit the URI to `/hub/token` (ie: https://example.lsit.ucsb.edu/hub/token - (1) pictured above)
- Enter a note to help you identify the purpose of token at a later date ( (2) pictured above)
- Set when you want the token to expire. ( (3) pictured above)
- Generate the token by clicking on the orange "Request new API token" button ( (4) pictured above)
- Copy the API token and store it somewhere safe. (pictured below)
- Configure the Jupyter Extension with your new API token.
- Launch the Command Palette (Ctrl+Shift+P or View > Command Palette ) and search for "Jupyter Server Connections" (note: If the Server Connections option does not appear in the list, you likely need to enable VSCode's workspace trust)
- Choose existing to enter the url for a new server.
- Create the URL with your instance's hostname and /user/<YourUCSBNetID>?token=<token> for the uri. (ie: https://example.lsit.ucsb.edu/user/juangaucho?token=efghijkl0123456789mnopqrstuvwx9876543210 )
- Launch the Command Palette (Ctrl+Shift+P or View > Command Palette ) and search for "Jupyter Server Connections" (note: If the Server Connections option does not appear in the list, you likely need to enable VSCode's workspace trust)
- Create a new Notebook
- File->New File... and pick Jupyter Notebook
- This should launch a new notebook with Python as default, but operations will be ran against JupyterHub. The status should be displayed along the bottom of the window.
- If an RStudio image was picked, R can be used by changing the kernel at the top right.