-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_run.sh
67 lines (51 loc) · 1.94 KB
/
test_run.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
62
63
64
65
66
67
#!/usr/bin/env bash
# Stop at first error
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCKER_TAG="puma-challenge-evaluation-track1"
DOCKER_NOOP_VOLUME="${DOCKER_TAG}-volume"
INPUT_DIR="${SCRIPT_DIR}/input"
OUTPUT_DIR="${SCRIPT_DIR}/output"
echo "=+= (Re)build the container"
docker build "$SCRIPT_DIR" \
--platform=linux/amd64 \
--tag $DOCKER_TAG 2>&1
docker volume create puma-eval-output
echo "=+= Doing an evaluation"
docker volume create "$DOCKER_NOOP_VOLUME" > /dev/null
docker run --rm \
--memory=4g \
--platform=linux/amd64 \
--network none \
--gpus all \
-v $SCRIPT_DIR/test/:/input/ \
-v puma-eval-output:/output/ \
--volume "$DOCKER_NOOP_VOLUME":/tmp \
$DOCKER_TAG
docker volume rm "$DOCKER_NOOP_VOLUME" > /dev/null
# Ensure permissions are set correctly on the output
# This allows the host user (e.g. you) to access and handle these files
docker run --rm \
--quiet \
--env HOST_UID=`id --user` \
--env HOST_GID=`id --group` \
--volume "$OUTPUT_DIR":/output \
alpine:latest \
/bin/sh -c 'chown -R ${HOST_UID}:${HOST_GID} /output'
# Check if the output files exist after the container has run
echo "=+= Checking output files..."
docker run --rm \
-v puma-eval-output:/output/ \
python:3.7-slim sh -c "ls /output/"
EXPECTED_FILE_METRICS="/output/metrics.json"
if docker run --rm -v puma-eval-output:/output/ python:3.7-slim sh -c "[ -f $EXPECTED_FILE_METRICS ]"; then
echo "=+= Expected output for metrics is correct."
# Copy metrics.json to the output directory
docker run --rm -v puma-eval-output:/output/ -v "$OUTPUT_DIR":/local_output python:3.7-slim sh -c "cp $EXPECTED_FILE_METRICS /local_output/"
echo "=+= metrics.json copied to ${OUTPUT_DIR}."
else
echo "=+= Expected output for metrics not found!"
exit 1
fi
echo "=+= Wrote results to ${OUTPUT_DIR}"
echo "=+= Save this image for uploading via save.sh \"${DOCKER_TAG}\""