This repository contains a .vscode subdirectory with
settings.json- A file for controlling the Slurm batch flags used to start your debug job and for setting the TCP port used to connect from the cluster login node to the Slurm compute node.launch.json- File that defines the debug launch configurationstasks.json- File that defines tasks, specifically those used forpreLaunchTasksin thelaunch.jsonlaunch-batch.sh- Script that creates a batch script, submits a batch job to start a debugpy server on a compute node, and waits for the job to start before returning control back to VSCodeslurm-debug-connect.sh- Script that sets up a TCP proxy connection between yourlocalhost:${config:SOCAT_PORT}and the Slurm compute node's port 3000.
This is an example repository that allows the user to allocate SLURM resources for a python script upon pushing the "Run and Debug" button. We are assuming that you are using the Python and Remote Explorer extensions and have a remote session in VSCode on a login node of an HPC cluster with the Slurm job scheduler.
Follow these steps to run the example script in this repository:
- Edit the
.vscode/settings.jsonfile to set theSLURM_SBATCH_FLAGSto define the partition and other parameters for submitting the batch job for your debug session. Additionally, set theSOCAT_PORTto a port that other users on your cluster are not using. - Make sure that your desired python file (e.g.,
example.py) is the file the is currently open in VS Code. - Navigate to the Run and Debug section on the sideby

- Select the
Slurm-Pythonconfiguration . - Hit the play button to run the file (or hit F5).
Completing these steps will create a batch script and submit the batch job to the Slurm job scheduler. Once the job starts, the script will wait for the debugpy server on the compute node to start. Once the debugpy server starts, socat is used to set up a TCP proxy from the compute node (port 3000) to the login node of the cluster on the port set by SOCAT_PORT in .vscode/settings.json