A terminal user interface to automate the process of allocating a slurm-session on a remote machine and connecting VSCode to it.
Supported Platforms: Linux, MacOS
- VSCode with the ssh-remote extension:
ms-vscode-remote.remote-ssh
- VSCode can be opened from the terminal with the command
code
. On linux, this should be the case by default. On MacOS, you have to launch VSCode, open the command palette withCmd+Shift+P
and search for:
Shell Command: Install 'code' command in PATH
- 'ssh' and 'ssh-keygen' installed, and a config file under
~/.ssh/config
. You can create the config file by executing
touch ~/.ssh/config
in the terminal.
openssl
installed. Openssl can be installed on debian based systems (Debian, Ubuntu, Linux Mint)
sudo apt-get install libssl-dev
On macos, it can be installed using homebrew:
brew install openssl
- Slurm installed: Check with
scontrol show partition
, if it returns a list of partitions, you are good to go.
To build the binary from source, you must have rust and cargo installed.
- Check if rust and cargo is installed, to do this, type
cargo --version
, if it returns a version, cargo is already installed, if it returns an error, you need to install cargo and rust with
curl https://sh.rustup.rs -sSf | sh
- Clone the repository with
git clone https://github.com/Gordi42/code-remote.git
- Change into the directory with
cd code-remote
- Build the binary with
cargo build --release
- Move the binary to a directory that is in your PATH. The binary will be in the
target/release
directory.
- Select the 'Create New' option and press enter. You will be asked to enter a name for the remote host. This name is only for your convenience and can be anything you like. Press enter after you have entered the name.
- You can navigate through the entries with the arrow keys. Select the 'Host' entry and press enter. You will be asked to enter the hostname of the remote machine. This is the name that you use to connect to the remote machine with 'ssh user@host'.
- Select the 'User' entry and press enter. You will be asked to enter the username that you use to connect to the remote machine with 'ssh user@host'.
- If you have a private key that you use to connect to the remote machine, select the 'IdentityFile' entry and press enter. Enter the absolute path to the private key file. If you do not have a private key, you can leave this entry empty, and you will be asked for the password when connecting to the remote machine.
- Press 'tab' to switch the focus back to the Cluster list. You can later change the entries by selecting the host and pressing 'tab' to focus on the entry menu.
- You can navigate through the host list with the arrow keys. Select the host that you want to connect to and press enter.
- You will be asked to enter a password if you did not provide a private key.
- After you have entered the password, the program tries to establish a connection to the remote machine. If the connection is successful, you will be directed to the spawner menu. Otherwise, an error message will be displayed.
Select the host that you want to remove and press 'd'. You will be asked to confirm the deletion. If you confirm, the host will be removed from the list.
- Select the 'Create New' option and press enter. You will be asked to enter a name for the session.
- Specify the account that you want to use (where the resources are billed to).
- Specify the partition that you want to use. You can check the available partitions with
scontrol show partition
on your remote machine. - Specify the maximum time that the session is allowed to run. The format is
hours:minutes:seconds
. - Specify the working directory. This is the directory that you want to open in VSCode. The default is the home directory of the user on the remote machine.
- Specify other options if you want to. These are appended to the salloc command. For example, you can specify the memory that you want to use with
--mem=8G
(for 8 gigabytes of memory). - Press 'tab' to switch the focus back to the session list. You can later change the entries by selecting the session and pressing 'tab' to focus on the entry menu.
Similar to selecting a host: Navigate through the session list with the arrow keys and select the session that you want to spawn. Press enter to spawn the session. If the session is successfully spawned, you will be directed to the VSCode menu. Otherwise, an error message will be displayed.
The configuration files are located in ~/.config/code-remote
. You can edit the files with a text editor. The clusters.toml
file contains the remote hosts, and the ($Hostname).toml
file contains the information about the corresponding sessions.
Silvano Rosenau