Skip to content

Commit 66c3f8b

Browse files
author
Marc Henry de Frahan
committed
Added compute node functionality
1 parent 8952f91 commit 66c3f8b

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

dot_local/share/zinit/plugins/hpc/hpc.plugin.zsh.tmpl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,43 @@ if [[ -z "${SCRATCH}" ]] && [[ -d "{{ .scratch_root }}" ]]; then
2323
export SCRATCH="{{ .scratch_root }}"
2424
fi
2525

26+
function _select-compute-node() {
27+
if [[ ! -x "$(command -v squeue)" ]]; then
28+
echo "squeue not found." >&2
29+
return 1
30+
fi
31+
32+
if [[ ! -x "$(command -v fzf)" ]]; then
33+
echo "fzf not found." >&2
34+
return 1
35+
fi
36+
37+
local node=$(squeue -u ${USER} -o "%N %j %M" -h 2>/dev/null | fzf | awk '{print $1}')
38+
39+
if [ -z "${node}" ]; then
40+
echo "No node selected, exiting." >&2
41+
return 1
42+
fi
43+
44+
echo "${node}"
45+
}
46+
47+
function compute-ssh() {
48+
local node=$(_select-compute-node) || return 1
49+
50+
echo "Connecting to ${node}..."
51+
ssh -t -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${node}
52+
}
53+
54+
function compute-docker() {
55+
local node=$(_select-compute-node) || return 1
56+
57+
echo "Connecting to ${node} and attaching to Docker container..."
58+
ssh -t -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${node} \
59+
'docker exec -it `docker ps -q | head -1` /bin/zsh -l'
60+
}
61+
62+
2663
{{- if .nrel_hpc }}
2764
# Custom for NREL HPC machines
2865

0 commit comments

Comments
 (0)