Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. # We must allow others exactly use our script without modification
  2. # Or its not replicable by others.
  3. #
  4. REGISTRY=docker.io
  5. REPOSITORY=centerforopenneuroscience
  6. LATEX_IMAGE_NAME=latex-biber
  7. LATEX_TAG=0.0.1-beta
  8. IMAGE_NAME=opfvta
  9. IMAGE_TAG=2.0.0-alpha
  10. FQDN_IMAGE=${REGISTRY}/${REPOSITORY}/${IMAGE_NAME}:${IMAGE_TAG}
  11. FQDN_LATEX_IMAGE=${REGISTRY}/${REPOSITORY}/${LATEX_IMAGE_NAME}:${LATEX_TAG}
  12. # PATH for scratch directory storing intermidiate results etc;
  13. # By default -- all data including intermediate results are under this folder (YODA!)
  14. ifeq ($(SCRATCH_PATH),)
  15. SCRATCH_PATH = $(PWD)/scratch
  16. endif
  17. OCI_BINARY?=docker
  18. SING_BINARY?=singularity
  19. DISTFILE_CACHE_CMD :=
  20. check_defined = \
  21. $(strip $(foreach 1,$1, \
  22. $(call __check_defined,$1,$(strip $(value 2)))))
  23. __check_defined = \
  24. $(if $(value $1),, \
  25. $(error Undefined $1$(if $2, ($2))))
  26. ifeq ($(DISTFILE_CACHE_PATH),)
  27. # If not set, don't add it as an option
  28. else
  29. DISTFILE_CACHE_CMD =-v $(DISTFILE_CACHE_PATH):/var/cache/distfiles
  30. endif
  31. .PHONY: all
  32. all:
  33. @echo "Invoking default rule, which will just attempt to build the paper "
  34. @echo "without redoing the analysis. If you would like to redo the entire "
  35. @echo "analysis, run make analysis-oci or some other analysis-* flavor (check Makefile). "
  36. @echo "See README.md for more information."
  37. $(MAKE) article
  38. #
  39. # Data analysis
  40. #
  41. analysis-reproman:
  42. reproman run \
  43. -r discovery --sub slurm --orc datalad-no-remote \
  44. --jp num_processes=16 \
  45. --jp num_nodes=1 \
  46. --jp walltime=120:00:00 \
  47. make analysis-singularity
  48. analysis-singularity:
  49. $(if $(USER),,$(error USER is not defined and currently required for the SCRATCH_PATH variable))
  50. @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\`."
  51. mkdir -p $(SCRATCH_PATH)
  52. $(SING_BINARY) run \
  53. -e --no-home \
  54. -B ${PWD}:/opt \
  55. -B ${PWD}/inputs/opfvta_bidsdata:/usr/share/opfvta_bidsdata \
  56. -B ${PWD}/inputs/mouse-brain-templates/mouse-brain-templates:/usr/share/mouse_brain_atlases \
  57. -B $(SCRATCH_PATH):$(HOME)/.scratch/ \
  58. -B ${PWD}/code/empty:/opfvta/ \
  59. --pwd /opt/code \
  60. code/images/opfvta-singularity/opfvta.sing \
  61. ./produce-analysis.sh singularity
  62. analysis-oci:
  63. $(OCI_BINARY) run \
  64. -it \
  65. --rm \
  66. -v ${PWD}:/opt \
  67. -v ${PWD}/inputs/opfvta_bidsdata:/usr/share/opfvta_bidsdata \
  68. -v ${PWD}/inputs/mouse-brain-templates/mouse-brain-templates:/usr/share/mouse_brain_atlases \
  69. -v ${SCRATCH_PATH}:/root/.scratch \
  70. -v ${PWD}/code/empty:/opfvta/ \
  71. --workdir /opt/code \
  72. ${FQDN_IMAGE} \
  73. ./produce-analysis.sh ${OCI_BINARY}
  74. analysis-oci-interactive:
  75. $(OCI_BINARY) run \
  76. -it \
  77. --rm \
  78. -v ${PWD}:/opt \
  79. -v ${PWD}/inputs/opfvta_bidsdata:/usr/share/opfvta_bidsdata \
  80. -v ${PWD}/inputs/mouse-brain-templates/mouse-brain-templates:/usr/share/mouse_brain_atlases \
  81. -v ${SCRATCH_PATH}:/root/.scratch \
  82. -v ${PWD}/code/empty:/opfvta/ \
  83. --workdir /opt/code \
  84. ${FQDN_IMAGE} \
  85. /bin/bash -l
  86. #
  87. # Publishing builds
  88. #
  89. .PHONY: container-article
  90. container-article:
  91. $(MAKE) container-article -C publishing/
  92. .PHONY: article
  93. article:
  94. $(MAKE) -C publishing/
  95. .PHONY: container-poster
  96. container-poster:
  97. $(MAKE) container-poster -C publishing/
  98. .PHONY: poster
  99. poster:
  100. $(MAKE) poster -C publishing/
  101. .PHONY: article-upload
  102. article-upload:
  103. $(MAKE) upload -C publishing/
  104. .PHONY: clean-publishing
  105. clean-publishing:
  106. $(MAKE) clean -C publishing/
  107. #
  108. # Containers management. oci- for Open Container Initiative
  109. #
  110. # Build data analysis container
  111. analysis-oci-image:
  112. $(OCI_BINARY) build . $(DISTFILE_CACHE_CMD) \
  113. -f code/images/Containerfile \
  114. -t ${FQDN_IMAGE}
  115. analysis-singularity-image:
  116. datalad install code/images/opfvta-singularity
  117. rm code/images/opfvta-singularity/opfvta.sing
  118. $(SING_BINARY) build code/images/opfvta-singularity/opfvta.sing docker://${FQDN_IMAGE}
  119. # Build latex environment container
  120. latex-oci-image:
  121. $(OCI_BINARY) build . $(DISTFILE_CACHE_CMD) \
  122. -f code/images/Containerfile.latex \
  123. -t ${FQDN_LATEX_IMAGE}
  124. # Push containers
  125. analysis-oci-push:
  126. $(OCI_BINARY) push ${FQDN_IMAGE}
  127. latex-oci-push:
  128. $(OCI_BINARY) push ${FQDN_LATEX_IMAGE}
  129. #
  130. # Aux rules
  131. #
  132. # Fix and test this
  133. submodule-data:
  134. cat inputs.txt | xargs datalad get
  135. datalad get inputs/opfvta_bidsdata/*
  136. datalad get code/images/opfvta-singularity/*
  137. datalad get code/opfvta/*