Skip to content

Commit

Permalink
Merge pull request #39 from UM-Bridge/hpc-merge-job-scripts
Browse files Browse the repository at this point in the history
HPC: Merge old model setup with new job submission script
  • Loading branch information
linusseelinger committed Dec 22, 2023
2 parents 20427e3 + 97a7cd1 commit 1662173
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 51 deletions.
28 changes: 24 additions & 4 deletions hpc/hq_scripts/job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@
#HQ --stdout none
#HQ --stderr none

# Launch model server, send back slurm job ID
# and wait to ensure that HQ won't schedule any more jobs to this allocation
# Launch model server, send back server URL
# and wait to ensure that HQ won't schedule any more jobs to this allocation.

/your/model/server/call & # CHANGE ME!
function get_avaliable_port {
# Define the range of ports to select from
MIN_PORT=1024
MAX_PORT=65535

# Generate a random port number
port=$(shuf -i $MIN_PORT-$MAX_PORT -n 1)

# Check if the port is in use
while lsof -Pi :$port -sTCP:LISTEN -t >/dev/null; do
# If the port is in use, generate a new random port number
port=$(shuf -i $MIN_PORT-$MAX_PORT -n 1)
done

port=4242
echo $port
}

port=$(get_avaliable_port)
export PORT=$port

# Assume that server sets the port according to the environment variable 'PORT'.
/your/model/server/call & # CHANGE ME!

load_balancer_dir="/load/balancer/directory" # CHANGE ME!

Expand All @@ -23,6 +42,7 @@ while ! curl -s "http://$host:$port/Info" > /dev/null; do
sleep 1
done

# Write server URL to file identified by HQ job ID.
mkdir -p "$load_balancer_dir/urls"
echo "http://$host:$port" > "$load_balancer_dir/urls/url-$HQ_JOB_ID.txt"

Expand Down
47 changes: 0 additions & 47 deletions hpc/hq_scripts/setup_model.sh

This file was deleted.

0 comments on commit 1662173

Please sign in to comment.