Skip to content

Commit

Permalink
adding bash scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
SD3004 committed May 4, 2022
1 parent 1eddf3e commit eefcd36
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
#!/usr/bin/env bash
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

docker build -t slcn_algorithm "$SCRIPTPATH" --rm
5 changes: 5 additions & 0 deletions export.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

./build.sh

docker save slcn_algorithm | gzip -c > SLCN_algorithm.tar.gz
41 changes: 41 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

./build.sh

VOLUME_SUFFIX=$(dd if=/dev/urandom bs=32 count=1 | md5sum | cut --delimiter=' ' --fields=1)
MEM_LIMIT="16g" # Maximum is currently 30g, configurable in your algorithm image settings on grand challenge

docker volume create slcn_algorithm-output-$VOLUME_SUFFIX

# Do not change any of the parameters to docker run, these are fixed
docker run --rm \
--memory="${MEM_LIMIT}" \
--memory-swap="${MEM_LIMIT}" \
--gpus 0 \
--network="none" \
--cap-drop="ALL" \
--security-opt="no-new-privileges" \
--shm-size="128m" \
--pids-limit="256" \
-v $SCRIPTPATH/test/:/input/images/cortical-surface-mesh/ \
-v slcn_algorithm-output-$VOLUME_SUFFIX:/output/ \
slcn_algorithm

docker run --rm \
-v slcn_algorithm-output-$VOLUME_SUFFIX:/output/ \
python:3.9-slim cat /output/birth-age.json | python -m json.tool

docker run --rm \
-v slcn_algorithm-output-$VOLUME_SUFFIX:/output/ \
-v $SCRIPTPATH/test/:/input/images/cortical-surface-mesh/ \
python:3.9-slim python -c "import json, sys; f1 = json.load(open('/output/birth-age.json')); f2 = json.load(open('/input/images/cortical-surface-mesh/expected_output.json')); sys.exit(f1 != f2);"

if [ $? -eq 0 ]; then
echo "Tests successfully passed..."
else
echo "Expected output was not found..."
fi

docker volume rm slcn_algorithm-output-$VOLUME_SUFFIX

0 comments on commit eefcd36

Please sign in to comment.