-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
167 lines (137 loc) · 4.32 KB
/
Makefile
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# We must allow others exactly use our script without modification
# Or its not replicable by others.
#
REGISTRY=docker.io
REPOSITORY=centerforopenneuroscience
LATEX_IMAGE_NAME=latex-biber
LATEX_TAG=0.0.1-beta
IMAGE_NAME=opfvta
IMAGE_TAG=2.0.0-alpha
FQDN_IMAGE=${REGISTRY}/${REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}
FQDN_LATEX_IMAGE=${REGISTRY}/${REPOSITORY}/${LATEX_IMAGE_NAME}:${LATEX_TAG}
# PATH for scratch directory storing intermidiate results etc;
# By default -- all data including intermediate results are under this folder (YODA!)
ifeq ($(SCRATCH_PATH),)
SCRATCH_PATH = $(PWD)/scratch
endif
OCI_BINARY?=docker
SING_BINARY?=singularity
DISTFILE_CACHE_CMD :=
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
ifeq ($(DISTFILE_CACHE_PATH),)
# If not set, don't add it as an option
else
DISTFILE_CACHE_CMD =-v $(DISTFILE_CACHE_PATH):/var/cache/distfiles
endif
.PHONY: all
all:
@echo "Invoking default rule, which will just attempt to build the paper "
@echo "without redoing the analysis. If you would like to redo the entire "
@echo "analysis, run make analysis-oci or some other analysis-* flavor (check Makefile). "
@echo "See README.md for more information."
$(MAKE) article
#
# Data analysis
#
analysis-reproman:
reproman run \
-r discovery --sub slurm --orc datalad-no-remote \
--jp num_processes=16 \
--jp num_nodes=1 \
--jp walltime=120:00:00 \
make analysis-singularity
analysis-singularity:
$(if $(USER),,$(error USER is not defined and currently required for the SCRATCH_PATH variable))
@echo "Selected \`SCRATCH_PATH\` $(SCRATCH_PATH). You may want to customize this by setting it on the command line, after the make command, i.e. \`make SCRATCH_PATH=... target\`."
mkdir -p $(SCRATCH_PATH)
$(SING_BINARY) run \
-e --no-home \
-B ${PWD}:/opt \
-B ${PWD}/inputs/opfvta_bidsdata:/usr/share/opfvta_bidsdata \
-B ${PWD}/inputs/mouse-brain-templates/mouse-brain-templates:/usr/share/mouse_brain_atlases \
-B $(SCRATCH_PATH):$(HOME)/.scratch/ \
-B ${PWD}/code/empty:/opfvta/ \
--pwd /opt/code \
code/images/opfvta-singularity/opfvta.sing \
./produce-analysis.sh singularity
analysis-oci:
$(OCI_BINARY) run \
-it \
--rm \
-v ${PWD}:/opt \
-v ${PWD}/inputs/opfvta_bidsdata:/usr/share/opfvta_bidsdata \
-v ${PWD}/inputs/mouse-brain-templates/mouse-brain-templates:/usr/share/mouse_brain_atlases \
-v ${SCRATCH_PATH}:/root/.scratch \
-v ${PWD}/code/empty:/opfvta/ \
--workdir /opt/code \
${FQDN_IMAGE} \
./produce-analysis.sh ${OCI_BINARY}
analysis-oci-interactive:
$(OCI_BINARY) run \
-it \
--rm \
-v ${PWD}:/opt \
-v ${PWD}/inputs/opfvta_bidsdata:/usr/share/opfvta_bidsdata \
-v ${PWD}/inputs/mouse-brain-templates/mouse-brain-templates:/usr/share/mouse_brain_atlases \
-v ${SCRATCH_PATH}:/root/.scratch \
-v ${PWD}/code/empty:/opfvta/ \
--workdir /opt/code \
${FQDN_IMAGE} \
/bin/bash -l
#
# Publishing builds
#
.PHONY: container-article
container-article:
$(MAKE) container-article -C publishing/
.PHONY: article
article:
$(MAKE) -C publishing/
.PHONY: container-poster
container-poster:
$(MAKE) container-poster -C publishing/
.PHONY: poster
poster:
$(MAKE) poster -C publishing/
.PHONY: article-upload
article-upload:
$(MAKE) upload -C publishing/
.PHONY: clean-publishing
clean-publishing:
$(MAKE) clean -C publishing/
#
# Containers management. oci- for Open Container Initiative
#
# Build data analysis container
analysis-oci-image:
$(OCI_BINARY) build . $(DISTFILE_CACHE_CMD) \
-f code/images/Containerfile \
-t ${FQDN_IMAGE}
analysis-singularity-image:
datalad install code/images/opfvta-singularity
rm code/images/opfvta-singularity/opfvta.sing
$(SING_BINARY) build code/images/opfvta-singularity/opfvta.sing docker://${FQDN_IMAGE}
# Build latex environment container
latex-oci-image:
$(OCI_BINARY) build . $(DISTFILE_CACHE_CMD) \
-f code/images/Containerfile.latex \
-t ${FQDN_LATEX_IMAGE}
# Push containers
analysis-oci-push:
$(OCI_BINARY) push ${FQDN_IMAGE}
latex-oci-push:
$(OCI_BINARY) push ${FQDN_LATEX_IMAGE}
#
# Aux rules
#
# Fix and test this
submodule-data:
cat inputs.txt | xargs datalad get
datalad get inputs/opfvta_bidsdata/*
datalad get code/images/opfvta-singularity/*
datalad get code/opfvta/*