-
Notifications
You must be signed in to change notification settings - Fork 0
/
abcd-test_aws.sh
executable file
·68 lines (56 loc) · 2.01 KB
/
abcd-test_aws.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
68
#!/bin/bash
echo "abcd-test_aws.sh: Running dcanlabs/abcd-hcp-pipeline in test mode container on ABCD S3 BIDS case on aws"
# This is the main script, that lives on the aws instance itself, that, given
# the S3 path to an anatomic case, manages its fetch, kwyk run, and 'post' to
# the ReproNim S3 results location
# At the moment it is expecting to run via the AWS-RunShellScript System
# Management functions, as user = root
# Check usage, 1 argument expected.
if [ $# -ne 1 ]; then
echo "Illegal number of parameters provided"
echo "Expected usage: abcd-test_aws.sh Output_Basename"
echo "I would terminate"
exit 10
fi
basenam=$1
bucket=abcd-test/output
localdir=abcd-test
# We are using aws 'profile' for credential management.
# We expect the .aws/configuration file to be pushed from your local system
# move creds from user ubuntu to root
#cp ~ubuntu/.aws/credentials /root/.aws/credentials
# Clear Prior BIDS directory, if present...
if [ -d ~ubuntu/BIDS ] ; then
echo "BIDS Directory exists, removing it"
rm -r ~ubuntu/BIDS
fi
# Fetch Case
echo "ABCD Fetching BIDS"
python3 ~ubuntu/nda-abcd-s3-downloader/download.py -o ~ubuntu/BIDS \
-s ~ubuntu/$localdir/subj.txt \
-i ~ubuntu/$localdir/datastructure_manifest.txt \
-l ~ubuntu/nda-abcd-s3-downloader/log/ \
-d ~ubuntu/$localdir/subsets.txt
# Prepare output directory
if [ -d ~ubuntu/DCAN ] ; then
echo "DCAN Directory exists, removing it"
rm -r sudo ~ubuntu/DCAN
fi
mkdir ~ubuntu/DCAN
# Run Container
docker run --rm -v /home/ubuntu/BIDS:/bids_input:ro \
-v /home/ubuntu/DCAN:/output -v /home/ubuntu/$localdir/license.txt:/license \
dcanlabs/abcd-hcp-pipeline /bids_input /output \
--freesurfer-license=/license --print-commands-only >>\
/home/ubuntu/DCAN/log
# Transfer data out
echo "Copying result to s3://abcd_test/output/$basenam"
aws s3 cp ~ubuntu/DCAN s3://${bucket}/$basenam --recursive --profile reprodnk
# cleanup original tmp
sudo rm -r ~ubuntu/DCAN
sudo rm -r ~ubuntu/BIDS
# the end
echo "Done, thanks!"
#echo "Terminating"
#poweroff
exit