Single script to automate the Jupyter Lab launch workflow on CHTC HTCondor - run from your laptop.
Automates the entire workflow:
- Scans ports - Finds a port available on both your laptop AND the AP
- Submits job - Runs
condor_submit jupyter.subon the AP via SSH - Waits for job - Monitors job status until it starts running
- Connects - Establishes SSH tunnel chain: laptop → AP → EP
- Launches Jupyter - Starts Jupyter Lab on the execution point
- Displays URL - Shows you the token URL to paste in your browser
On your laptop:
jupyter.sub- Your HTCondor submit file (will be copied to AP)launch_jupyter.sh- Script to launch Jupyter (will be copied to AP)- SSH access to CHTC AP (keys recommended)
- This
chtc-jupyterscript
On the AP (referenced in submit file):
- Container in
/staging/(referenced in submit file)
Basic (uses all defaults):
./chtc-jupyterCustom access point:
AP_HOST=ap2001.chtc.wisc.edu ./chtc-jupyterCustom username:
AP_USER=myusername ./chtc-jupyterCustom submit file:
SUBMIT_FILE=my-jupyter.sub ./chtc-jupyterCustom remote directory on AP:
SUBMIT_DIR=/home/username/my-jobs ./chtc-jupyterCustom port range:
PORT_START=9000 PORT_END=9100 ./chtc-jupyter-
On your laptop, prepare your files:
# Make sure you have the required files locally ls -l jupyter.sub launch_jupyter.sh # Make the launcher executable chmod +x chtc-jupyter
-
On the AP, make sure your container exists:
ssh username@ap2002.chtc.wisc.edu # Make sure your container is in /staging/ ls -l /staging/$(whoami)/jupyter.sif
Just run the script from your laptop:
./chtc-jupyterThe script will:
- Test SSH connection to the AP
- Scan for available ports (shows progress)
- Copy jupyter.sub to the AP (into ~/chtc-jupyter/ by default)
- Submit the job
- Wait for it to start (shows dots)
- Connect and launch Jupyter
- Display the URL
Copy the URL (looks like http://127.0.0.1:8889/lab?token=abc123...) and paste it into your browser.
That's it! You're now running Jupyter on an HTCondor execution point.
Press Ctrl+C in the terminal to disconnect.
Important: The job continues running until the time limit. Remove it manually:
# SSH to the AP
ssh username@ap2002.chtc.wisc.edu
# Remove the job
condor_rm <JobID>The script intelligently finds a port that works for everyone:
-
Scans your laptop (ports 8889-8999 by default)
- Finds ports not in use locally
-
Scans the AP via SSH
- Checks which of those ports are also free on the AP
-
Uses the first common port
- Ensures no conflicts with other users
This means you don't need to manually specify ports and multiple users can run simultaneously without conflicts!
| Variable | Default | Description |
|---|---|---|
AP_HOST |
ap2002.chtc.wisc.edu |
Access point hostname |
AP_USER |
$USER |
Username on AP |
SUBMIT_FILE |
jupyter.sub |
Local submit file to copy |
SUBMIT_DIR |
$HOME/chtc-jupyter |
Remote directory on AP |
PORT_START |
8889 |
Port range start |
PORT_END |
8999 |
Port range end |
# Make sure jupyter.sub exists on your laptop
ls -l jupyter.sub
# Or specify a different file
SUBMIT_FILE=~/jupyter-configs/my-jupyter.sub ./chtc-jupyterCurrently, if your connection drops, Jupyter stops. You'll need to:
- Run
./chtc-jupyter resume <JobID> <Port>, as specified in the output
This is expected behavior. HTCondor jobs run for their full duration.
To stop it:
ssh username@ap2002.chtc.wisc.edu
condor_rm <JobID>Future enhancement: Automatic cleanup (task-1.4)
Create multiple submit files:
# CPU-only session
SUBMIT_FILE=jupyter-cpu.sub ./chtc-jupyter
# GPU session
SUBMIT_FILE=jupyter-gpu.sub ./chtc-jupyter
# Large memory
SUBMIT_FILE=jupyter-bigmem.sub ./chtc-jupyterOn your laptop:
chtc-jupyter- This launcher scriptjupyter.sub- Your submit file (copied to AP automatically)
On the AP:
launch_jupyter.sh- EP launcher (transferred with job via submit file)- Container in
/staging/(referenced in submit file) ~/chtc-jupyter/- Created automatically by script (contains copied submit file)
For users who frequently connect to CHTC access points, you can optionally set up SSH configuration shortcuts to:
- Use short aliases instead of full hostnames (
ssh chtc-ap) - Enable connection reuse (no re-authentication for 10 minutes)
- Automatically keep connections alive during long sessions
This is completely optional - the chtc-jupyter script works perfectly without any SSH config customization.
Files:
ssh-config-template- Copy-paste SSH config examplesssh-config-guide.md- Comprehensive guide with security considerations
Security note: Some configurations (like ControlMaster) should only be used on personal, secure workstations. Read the guide before using.