2020-03-20 12:43:57 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
rm -f last_checkpoint.out
|
|
|
|
pkill -f cartpole_server.py
|
|
|
|
sleep 1
|
|
|
|
|
2020-05-30 22:48:34 +02:00
|
|
|
if [ -f test_local_inference.sh ]; then
|
|
|
|
basedir="../../examples/serving"
|
2020-03-20 12:43:57 -07:00
|
|
|
else
|
|
|
|
basedir="rllib/examples/serving" # In bazel.
|
|
|
|
fi
|
|
|
|
|
2021-01-14 20:44:26 +01:00
|
|
|
# Do not attempt to restore from checkpoint; leads to errors on travis.
|
2021-06-23 09:09:01 +02:00
|
|
|
(python $basedir/cartpole_server.py --run=DQN --num-workers=2 --no-restore 2>&1 | grep -v 200) &
|
|
|
|
server_pid=$!
|
2020-03-20 12:43:57 -07:00
|
|
|
|
|
|
|
echo "Waiting for server to start"
|
2020-05-30 22:48:34 +02:00
|
|
|
while ! curl localhost:9900; do
|
2020-03-20 12:43:57 -07:00
|
|
|
sleep 1
|
|
|
|
done
|
2021-06-23 09:09:01 +02:00
|
|
|
while ! curl localhost:9901; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
# Start client 1 (port 9900).
|
|
|
|
sleep 2
|
|
|
|
(python $basedir/cartpole_client.py --inference-mode=remote --port=9900) &
|
|
|
|
client1_pid=$!
|
2020-03-20 12:43:57 -07:00
|
|
|
|
2021-06-23 09:09:01 +02:00
|
|
|
# Start client 2 (port 9901).
|
2020-03-20 12:43:57 -07:00
|
|
|
sleep 2
|
2021-06-23 09:09:01 +02:00
|
|
|
(python $basedir/cartpole_client.py --inference-mode=remote --port=9901) &
|
|
|
|
client2_pid=$!
|
|
|
|
|
|
|
|
# Start client 3 (also port 9901) and run it until it reaches 150.0
|
|
|
|
# reward. Then stop everything.
|
|
|
|
sleep 2
|
|
|
|
python $basedir/cartpole_client.py --stop-reward=150.0 --inference-mode=remote --port=9901
|
|
|
|
|
|
|
|
kill $server_pid $client1_pid $client2_pid || true
|
2020-03-20 12:43:57 -07:00
|
|
|
|