-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
206 lines (155 loc) · 6.85 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
include common_parameters.env
export
SHELL = /bin/sh
CURRENT_UID := $(shell id -u)
CURRENT_GID := $(shell id -g)
export CURRENT_UID
export CURRENT_GID
## help : Print help info
help : Makefile
@sed -n 's/^##//p' $<
## clean : Clean temporary files, INCLUDES DELETING THE NEXTFLOW TEMPORY WORK DIRECTORY
clean:
find . -name ".nextflow.log.*" -exec rm -r {} +
find . -type d -name ".nextflow" -exec rm -r {} +
find . -name ".nextflow.log" -exec rm {} +
find . -type d -name "work" -exec rm -r {} +
## create_mamba : Create the socialgene conda enviornment
create_mamba:
mamba env create --file conda_environment.yml
## install_python : Install the socialgene python package
install_python:
pip3 install -e ./socialgene
##
## NEXTFLOW SPECIFIC TASKS
##
## chai : This is a specific Nextflow pipeline made to run on Chase's work computer
chai:
nextflow run nextflow -profile chicago --build_database true --mode dev -resume --enable_conda true
## nextflow_example: Run the example nextflow pipeline
run_nextflow_example:
nextflow run nextflow -profile conda,example --outdir_per_run "./nextflow_example/outdir_per_run" --outdir_neo4j "./nextflow_example/outdir_neo4j" --outdir_long_cache "./nextflow_example/outdir_long_cache" -resume --fasta_splits 3
##
## DJANGO SPECIFIC TASKS
##
##
# https://github.com/pydanny/cookiecutter-django/pull/1879#issuecomment-516251029
PROJECT_NAME=socialgeneweb
export COMPOSE_FILE=local.yml
.PHONY: up down stop prune ps shell logs
default: up
# necessary so docker won't create these as root
make_django_dirs:
mkdir -p django/local_postgres_data
mkdir -p django/local_postgres_data_backups
mkdir -p django/redis-data
django_build:
@echo "Building containers for for ${PROJECT_NAME}..."
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f ${COMPOSE_FILE} --env-file ./socialgene/src/socialgene/common_parameters.env build --parallel
## django_up : Start up containers.
django_up: make_django_dirs django_build
@echo "Starting up containers for for ${PROJECT_NAME}..."
# @see:https://github.com/docker/compose/issues/6464
#docker-compose pull
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f ${COMPOSE_FILE} --env-file ./socialgene/src/socialgene/common_parameters.env up --remove-orphans
upq: make_django_dirs
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f ${COMPOSE_FILE} --env-file ./socialgene/src/socialgene/common_parameters.env up --remove-orphans
## build : Build python image.
build:
@echo "Building python image for for ${PROJECT_NAME}..."
docker-compose build
## down : Stop containers.
down: stop
## start : Start containers without updating.
start: make_django_dirs
@echo "Starting containers for $(PROJECT_NAME) from where you left off..."
@docker-compose start
## stop : Stop containers.
stop:
@echo "Stopping containers for $(PROJECT_NAME)..."
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f ${COMPOSE_FILE} down
## prune : Remove containers and their volumes.
## You can optionally pass an argument with the service name to prune single container
## prune mariadb : Prune `mariadb` container and remove its volumes.
## prune mariadb solr : Prune `mariadb` and `solr` containers and remove their volumes.
prune:
@echo "Removing containers for $(PROJECT_NAME)..."
@docker-compose down -v $(filter-out $@,$(MAKECMDGOALS))
## ps : List running containers.
ps:
@docker ps --filter name='$(PROJECT_NAME)*'
## manage : Executes `manage.py` command.
## To use "--flag" arguments include them in quotation marks.
## For example: make manage "makemessages --locale=pl"
.PHONY: manage
manage: make_django_dirs
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f $(COMPOSE_FILE) run --rm django python manage.py $(filter-out $@,$(MAKECMDGOALS)) $(subst \,,$(MAKEFLAGS))
manage2:
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f $(COMPOSE_FILE) run --rm django python manage.py list_model_info
migrate:
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f $(COMPOSE_FILE) run --rm django python manage.py migrate
makemigrations:
docker-compose -f local.yml run --rm django python3 manage.py makemigrations
show_urls:
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f local.yml run --rm django python manage.py show_urls
createsuperuser: make_django_dirs
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f $(COMPOSE_FILE) run --rm django python manage.py createsuperuser
## django_logs: print the django docker compose logs
django_logs:
@docker-compose logs -f $(filter-out $@,$(MAKECMDGOALS))
##
## NEO4J SPECIFIC TASKS
##
## memrec: Get an estimate of the Neo4j memory settings your machine is capable of
memrec:
docker run \
--user="$(id -u)":"$(id -g)" \
--env NEO4J_AUTH=neo4j/test \
--interactive \
--tty \
neo4j:4.3.7 \
neo4j-admin \
memrec \
--memory=60G \
--verbose \
--docker
##
## DEVELOPMENT TASKS
##
## testnf: Run the test nextflow pipeline
testnf:
nextflow run nextflow -profile test --outdir_per_run "/tmp/socialgene/outdir_per_run" --outdir_neo4j "/tmp/socialgene/outdir_neo4j" --outdir_long_cache "/tmp/socialgene/outdir_long_cache" -resume --fasta_splits 100
## pytest : Run Python pacakge unit tests
pytest:
coverage run --omit="*/tests*" --source=./socialgene --module pytest ./socialgene/tests/python --cov=./socialgene/src/socialgene --failed-first --cov-report=html
## pytestnf : Run Nextflow pytest tests (first runs clean, install python and nextflow test run)
pytestnf: clean install_python testnf
coverage run --source=./socialgene --module pytest ./socialgene/tests/nextflow --neo4j_outdir $(neo4j_outdir)
## django_test : Run pytest for the Django code
django_test:
CURRENT_UID=$(shell id -u):$(shell id -g) docker-compose -f $(COMPOSE_FILE) run --rm django pytest
## run_ci : Run the Python continuous integration tests locally
run_ci: clean install_python pytest
@echo "TESTING WITH FLAKE8"
flake8 . --exclude temp_scripts,old_tests,old_act --ignore E203,E501,W503 --count --show-source
@echo "TESTING WITH BLACK"
black --check . --extend-exclude temp_scripts
## run_ci_full : Run the Python and nf-core continuous integration tests locally
ci:
nf-core -l lint_log.txt lint --dir .
nf-core modules lint --all --local
nf-core schema lint .
markdownlint ./docs ./nextflow --disable MD013 MD033 MD041
parameter_documentation:
nf-core schema docs > parameters.md
ci2:
# npm install -g editorconfig-checker
# checker -exclude README.md $(find . -type f | grep -v '.git\|.py\|.md\|json\|yml\|yaml\|html\|css\|work\|.nextflow\|build\|nf_core.egg-info\|log.txt\|Makefile')
prettier --check .
black .
nf-core -l lint_log.txt lint --dir . --markdown lint_results.md
# https://stackoverflow.com/a/6273809/1826109
%:
@:
###########################################################################################################
###########################################################################################################