-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_hellbender.sh
More file actions
69 lines (54 loc) · 2.09 KB
/
start_hellbender.sh
File metadata and controls
69 lines (54 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
# Script to allocate Hellbender resources and connect VS Code
# Default values
TIME="1:00:00"
PARTITION="interactive"
# Parse options
while getopts "t:p:" opt; do
case $opt in
t) TIME="$OPTARG" ;;
p) PARTITION="$OPTARG" ;;
*) echo "Usage: $0 [-t time] [-p partition]" >&2; exit 1 ;;
esac
done
echo "Requesting resources from Hellbender..."
# Get current job count before allocation
initial_jobs=$(ssh hellbender "squeue -u \$USER -h | wc -l")
# Run salloc in the background on hellbender and keep it alive
ssh -f hellbender "salloc --time=$TIME --partition=$PARTITION sleep 3600" > /dev/null 2>&1 &
# Wait a moment for allocation to start
sleep 2
# Check for the NEW allocated node ($PARTITION partition)
echo "Waiting for node allocation..."
for i in {1..30}; do
# Get the most recent interactive job
node=$(ssh hellbender "squeue -u \$USER -h -p $PARTITION -o '%N' | head -n 1")
jobid=$(ssh hellbender "squeue -u \$USER -h -p $PARTITION -o '%i' | head -n 1")
# Check if we have a new job
current_jobs=$(ssh hellbender "squeue -u \$USER -h | wc -l")
if [ -n "$node" ] && [ "$node" != "" ] && [ "$current_jobs" -gt "$initial_jobs" ]; then
echo "✓ Allocated node: $node"
echo "✓ Job ID: $jobid"
# Wait a moment for node to be fully ready
sleep 2
# Open VS Code and connect (let user choose folder)
echo "Opening VS Code and connecting to $node..."
code --new-window --remote ssh-remote+$node
echo ""
echo "✓ VS Code should now be connecting to $node"
echo "✓ Click 'Open Folder' in VS Code to select your working directory"
echo "✓ Your session will expire in $TIME"
echo ""
echo "Current jobs:"
ssh hellbender "squeue -u \$USER"
echo ""
echo "To cancel this specific job: ssh hellbender 'scancel $jobid'"
exit 0
fi
echo -n "."
sleep 2
done
echo ""
echo "✗ Timeout waiting for node allocation"
echo "Check status with: ssh hellbender 'squeue -u \$USER'"
exit 1