-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fixing-issue-48' into singularity
- Loading branch information
Showing
8 changed files
with
191 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
all: build-server build-lb run-lb | ||
|
||
load-balancer-files = ../../LoadBalancer.cpp ../../LoadBalancer.hpp ../../lib/httplib.h ../../lib/json.hpp ../../lib/umbridge.h | ||
|
||
build-server: | ||
g++ -O3 -w -std=c++11 minimal-server.cpp -o server -lssl -lcrypto -pthread | ||
|
||
build-lb: | ||
g++ -O3 -Wno-unused-result -std=c++17 $(load-balancer-files) -o load-balancer -pthread | ||
|
||
run-lb: | ||
./load-balancer |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# export TEST_DELAY=1e4 | ||
|
||
echo "Sending requests..." | ||
|
||
for i in {1..300} | ||
do | ||
# Expected output: {"output":[[200.0]]} | ||
# Check if curl output equals expected output | ||
# If not, print error message | ||
|
||
if [ "$(curl -s http://localhost:4242/Evaluate -X POST -d '{"name": "forward", "input": [[100.0]]}')" == '{"output":[[200.0]]}' ]; then | ||
echo -n "y" | ||
else | ||
echo $(curl -s http://localhost:4242/Evaluate -X POST -d '{"name": "forward", "input": [[100.0]]}') | ||
echo -n "n" | ||
#echo "Error: curl output does not equal expected output" | ||
fi & | ||
|
||
done | ||
|
||
echo "Requests sent. Waiting for responses..." | ||
|
||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /bin/bash | ||
|
||
hq alloc add slurm --time-limit 10m \ | ||
--idle-timeout 3m \ | ||
--backlog 1 \ | ||
--workers-per-alloc 1 \ | ||
--max-worker-count 5 \ | ||
--resource "model=range(1-1)" \ | ||
--cpus=1 \ | ||
-- -p "devel" # Add any neccessary SLURM arguments | ||
# Any parameters after -- will be passed directly to sbatch (e.g. credentials, partition, mem, etc.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#! /bin/bash | ||
|
||
#HQ --resource model=1 | ||
#HQ --time-request=1m | ||
#HQ --time-limit=2m | ||
|
||
# Launch model server, send back server URL | ||
# and wait to ensure that HQ won't schedule any more jobs to this allocation. | ||
load_balancer_dir="./" | ||
# Write port to file identified by HQ job ID. | ||
mkdir -p "$load_balancer_dir/ports" | ||
|
||
function get_avaliable_port { | ||
# Define the range of ports to select from | ||
MIN_PORT=49152 | ||
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 -t; do | ||
# If the port is in use, generate a new random port number | ||
port=$(shuf -i $MIN_PORT-$MAX_PORT -n 1) | ||
|
||
done | ||
|
||
echo "$port" > "$load_balancer_dir/ports/$HQ_JOB_ID-1.txt" | ||
echo $port | ||
} | ||
|
||
|
||
port=$(get_avaliable_port) | ||
# sleep 1 # Wait for the port to be correctly assigned, otherwise it will sometimes get strange value in $port | ||
|
||
echo "$port" > "$load_balancer_dir/ports/$HQ_JOB_ID-2.txt" | ||
|
||
export PORT=$port && ./server & # Assume that server sets the port according to the environment variable 'PORT'. | ||
|
||
|
||
host=$(hostname -I | awk '{print $1}') | ||
|
||
# Wait for model server to start | ||
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" | ||
|
||
sleep infinity # keep the job occupied |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters