-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_cicero.sh
61 lines (50 loc) · 1.46 KB
/
run_cicero.sh
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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_FILE=$(realpath "$0")
SCRIPT_NAME=$(basename "$SCRIPT_FILE")
function show_usage() {
{
echo "usage: bash $SCRIPT_NAME [--help] BOT_TAG BOT_TYPE BOT_ARGS..."
echo
echo 'Run CICERO from an OCI image using Docker.'
echo '- BOT_TAG is the tag assigned when building the image ("latest" by default).'
echo '- BOT_TYPE is the type of bot to run and must be either "advisor" or "player".'
echo '- BOT_ARGS are passed as arguments to the script within the running container.'
} >&2
}
if [[ $# -lt 2 ]] || [[ ${1:-} = --help ]]; then
show_usage
exit 1
fi
BOT_TAG=$1
BOT_TYPE=$2
shift 2
if [[ $BOT_TYPE != advisor ]] && [[ $BOT_TYPE != player ]]; then
{
echo 'Invalid BOT_TYPE given: must be "advisor" or "player".'
echo
} >&2
show_usage
exit 1
fi
set -x
CICERO_DIR=/media/volume/cicero-base-models
GAME_COMMAND=(
python fairdiplomacy_external/mila_api_"$BOT_TYPE".py
--game_type 2
"$@"
)
mkdir -p logs/
NOW=$(date -u +'%Y_%m_%d_%H_%M_%S')
LOG_FILE=logs/$NOW.txt
time docker run \
--rm \
--gpus all \
--name cicero_"$BOT_TAG"_"$RANDOM" \
--volume "$CICERO_DIR"/agents:/diplomacy_cicero/conf/common/agents:ro \
--volume "$CICERO_DIR"/gpt2:/usr/local/lib/python3.7/site-packages/data/gpt2:ro \
--volume "$CICERO_DIR"/models:/diplomacy_cicero/models:ro \
--workdir /diplomacy_cicero \
ghcr.io/allan-dip/diplomacy_cicero:"$BOT_TAG" \
"${GAME_COMMAND[@]}" |&
tee "$LOG_FILE"