Skip to content

Commit 89f9d5a

Browse files
authored
Merge branch 'cli' into main
2 parents 5c70ea3 + 7c8c478 commit 89f9d5a

File tree

2 files changed

+63
-17
lines changed

2 files changed

+63
-17
lines changed

README.md

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,84 @@
11
# PyBS
22

3-
43
## Installation
54

5+
#### 1. Install `pybs`
66
`pip install pythonpbs`
77

8-
## SSH Configuration
8+
#### 2. SSH Configuration
99

10-
OpenSSH
10+
You will need to add the following to your `~/.ssh/config` file:
1111

12+
```
13+
# the host details of your login node:
14+
Host YOUR_LOGIN_SERVER_ALIAS
15+
Hostname YOUR_LOGIN_SERVER_HOSTNAME
16+
User YOUR_USERNAME
17+
```
18+
19+
20+
For better ssh performance, you can optionally add the following:
1221
```
1322
Host *
1423
ControlMaster auto
1524
ControlPath ~/.ssh/controlmasters/%r@%h:%p
1625
ControlPersist yes
1726
1827
```
19-
Create directory
28+
Then, create directory:
2029
```bash
2130
mkdir -p ~/.ssh/controlmasters
2231
```
32+
To prevent disconnecting from timeouts, you can also add:
33+
```
34+
# Send keepalive packets to prevent SSH disconnecting...
35+
Host *
36+
ServerAliveInterval 60
37+
```
38+
2339

24-
## VScode
40+
#### 3. VS code setup
2541

26-
To use the `launch` command, you will need to have `VS code` added to your `$PATH`.
27-
#### Using command palette
42+
To use the `code` command, you will need to have `VS code` added to your `$PATH`.
43+
##### Using command palette
2844

2945
In VS code, open the **command palette** (`Cmd+Shift+P`), type "shell command",
3046
and run the `Shell Command: Install 'code' command in PATH` command.
31-
#### Manually configure the path
47+
##### Manually configure the path
3248

33-
##### Zsh
49+
###### Zsh
3450

3551
```zsh
3652
cat << EOF >> ~/.zprofile
3753
# Add Visual Studio Code (code)
3854
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
3955
EOF
4056
```
41-
##### Bash
57+
###### Bash
4258
```bash
4359
cat << EOF >> ~/.bash_profile
4460
# Add Visual Studio Code (code)
4561
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
4662
EOF
4763
```
4864
Restart your shell to register your changes. You can check with `which code`.
49-
### Enable tab completion for Bash, Fish, or Zsh
65+
66+
67+
#### 4. Enable tab completions
68+
69+
You can enable CLI tab completion for Bash, Fish, or Zsh.
5070

5171

5272
> After modifying `.rc` files for your shell, you may have to restart the shell to enable completions.
53-
#### Zsh
73+
##### Zsh
5474

5575
```zsh
5676
_PYBS_COMPLETE=zsh_source pybs > ~/.zsh/pybs-complete.zsh
5777
```
5878
> NOTE: you may have to add `source ` to your `~/.zshrc` if this does not work.
5979
6080

61-
#### Oh My Zsh
81+
##### Oh My Zsh
6282

6383
```zsh
6484
mkdir $ZSH_CUSTOM/plugins/pybs
@@ -72,7 +92,7 @@ plugins(
7292
...
7393
)
7494
```
75-
#### Bash
95+
##### Bash
7696
```bash
7797
_PYBS_COMPLETE=bash_source pybs > ~/.pybs-complete.bash
7898
```
@@ -84,3 +104,31 @@ Add the following to your `~/.bashrc`:
84104
```fish
85105
_PYBS_COMPLETE=fish_source pybs > ~/.config/fish/completions/pybs.fish
86106
```
107+
#### 5. Create job script
108+
109+
To use the `code` command to launch a VS code instance on a compute node, you will need to create a
110+
PBS-compatible job script with a `sleep infinity` command or similar to prevent early exiting of the
111+
job script.
112+
113+
##### Example job script
114+
115+
```bash
116+
#! /usr/bin/env bash
117+
118+
#PBS -I
119+
#PBS -l select=1:ncpus=6:ngpus=1:mem=46gb
120+
#PBS -l walltime=4:00:00
121+
#PBS -M YOUR_EMAIL_ADDRESS
122+
#PBS -m ae
123+
#PBS -j oe
124+
125+
sleep infinity
126+
```
127+
128+
129+
Then, you can run `code` as follows:
130+
131+
```bash
132+
pybs code YOUR_SERVER_NAME '$HOME/path/to/notebook.ipynb' path/to/job_script.pbs
133+
```
134+

pybs/console/remote/code.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from pybs.console.tabcomplete import complete_remote_path, complete_hostname, complete_job_script
2222
from pybs.console.ui import CompactTimeColumn
2323

24+
2425
console = Console(
2526
theme=custom_theme,
2627
# stderr=True,
@@ -168,9 +169,6 @@ def code(
168169

169170
console.print(syntax)
170171

171-
172-
173-
174172
# Expand path
175173
with progress:
176174
task = progress.add_task(

0 commit comments

Comments
 (0)