File size: 1,606 Bytes
7ec48b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -euo pipefail
test_dir="$(cd "$(dirname "$0")" && pwd)"
HOME=/home/rct2 DISPLAY=:1 python3 /usr/local/lib/t39/collect.py --screenshot || true
mkdir -p /logs/verifier
rm -f /logs/verifier/reward.txt /logs/verifier/reward.json

# The controller saves the park at the moment an attempt settles, one file per
# attempt; the newest of those is the proof, and the newest save of any kind
# stands in when no attempt ever settled.
park="$(python3 - <<'PY'
from pathlib import Path
root = Path('/logs/artifacts/save')
# onetile-base.park is the pristine plot the run was launched from and
# 2nd-try.park and 3rd-try.park are the pristine copies the further attempts are
# taken from, all kept in the save directory so the agent's dialogs open usefully.
# None of them is evidence about this run.
pristine = {'onetile-base.park', '2nd-try.park', '3rd-try.park'}
parks = [p for p in root.rglob('*.park')
         if p.name not in pristine] if root.is_dir() else []
settled = [p for p in parks if p.name.startswith('t39-final')]
if settled:
    print(max(settled, key=lambda p: p.stat().st_mtime))
elif parks:
    print(max(parks, key=lambda p: p.stat().st_mtime))
PY
)"

args=()
if [[ -n "$park" ]]; then
    reopened=/logs/verifier/reopened.json
    if ! python3 "$test_dir/reopen.py" "$park" "$reopened" \
        >> /logs/verifier/reopen.log 2>&1; then
        echo "Native save could not be inspected; see reopen.log." \
            > /logs/verifier/evaluation-error.txt
        exit 2
    fi
    args+=(--saved-state "$reopened")
fi

python3 "$test_dir/grade.py" ${args[@]+"${args[@]}"}