-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathesm.def
115 lines (93 loc) · 3.51 KB
/
esm.def
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Bootstrap: library
From: ubuntu:18.04
%post
# Here we put scripts to run immediatley after initialisation of the OS
# Update Ubuntu package repos
echo "deb http://gb.archive.ubuntu.com/ubuntu bionic main restricted" >> /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu bionic universe" >> /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu bionic-updates multiverse" >> /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://gb.archive.ubuntu.com/ubuntu bionic-security main restricted" >> /etc/apt/sources.list
# Install packages
apt-get update
apt-get install -y libssl-dev libgsl-dev libxml2-dev libcurl4-openssl-dev git r-base r-base-dev r-cran-littler r-cran-rjags r-cran-curl r-cran-car r-cran-mvtnorm r-cran-mcmcpack r-cran-openssl r-cran-xml2 pandoc
# Clone git repository
git clone https://github.com/oxacclab/ExploringSocialMetacognition ESM
# Run setup R script
r /ESM/analysis/ACv2/src/install-packages.R
%runscript
NOW=$(date)
# Commands to run when called
echo "Container created $NOW"
# Parse arguments
GIT=""
TIME=""
FILE="ACv2/directBenevolenceContext_v0.0.1"
VERBOSE=$false
while getopts ":g:t:f:v" opt; do
case ${opt} in
g )
GIT=$OPTARG
;;
t )
TIME=$OPTARG
;;
f )
FILE=$OPTARG
;;
v )
VERBOSE=$true
;;
\? )
echo "Invalid Option: -$OPTARG" 1>&2
exit 1
;;
: )
echo "Invalid Option: $OPTARG requires an argument" 1>&2
exit 1
;;
esac
done
echo "Arguments parsed with getopts"
# Look up GIT argument if a date and extract most recent commit given that date
if [ "$TIME" != "" ]; then
echo "TIME variable set"
if [ "$GIT" != "" ]; then
echo "GIT variable set"
echo "You cannot specify both a -t and -g argument."
exit 1
fi
# TIME=date --date="$TIME" --iso-8601=seconds
echo "Finding first commit made prior to $TIME"
cd /ESM
GIT=$(git rev-list -n 1 --before="$TIME" master)
fi
if [ "$GIT" != "" ]; then
cd /ESM
git checkout $GIT
echo "GIT: $GIT"
fi
if [ "$TIME" != "" ]; then
echo "(By TIME: ${TIME})"
fi
echo "FILE: $FILE"
if [ $VERBOSE ]; then
echo "VERBOSE: TRUE"
fi
if [ "$FILE" != "" ]; then
# Knit and return a specific file
echo "Knitting analysis script..."
R=rmarkdown::render\(\"/ESM/analysis/${FILE}.Rmd\"\)
echo $R
# r -e $R
# cat /ESM/analysis/${FILE}.html
fi
%test
# Check whether R installed properly
%labels
Author [email protected]
Version v0.0.2
Date 2019-12-29
%help
This container should provide a reproducible version of the study at a given point in its history. It should provide a useable version of the study on a local webserver, and access to the analysis scripts run in an environment identical to the one used for the write-up of the project.
By default it will print out an HTML file freshly generated from Rmarkdown code.