-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
222 lines (181 loc) · 7.15 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
VERSION = 0.6.0
USER = $(shell whoami)
PWD = $(shell pwd)
V ?=
BEAMLINE ?= e02
YEAR ?= 2023
visit ?= cm33902-1
# visit ?= nt32759-1
SAMPLE_SCAN ?= au_xgrating/20220823_103205
VISIT_DIRECTORY = /dls/$(BEAMLINE)/data/$(YEAR)/$(visit)
BATCH_MIB_CONVERT_PYTHONPATH = /dls_sw/e02/software
# ------------------------------------------------------------------
# This is the mib conversion code.
# MIB_PYTHONPATH = $(PWD)/../ePSIC-DLS-epsic_tools/epsic_tools/mib2hdfConvert
# Set up path local clone of dependencies supercede the installed ones.
# The paths should be absolute since tasks can be launched in their own working directories.
PYTHONPATH = $(BATCH_MIB_CONVERT_PYTHONPATH):$(PWD)/src:$(PWD)/../dls-bxflow/src:$(PWD)/../dls-servbase/src:$(PWD)/../dls-logformatter/src:$(PWD)/../dls-mainiac/src:$(PWD)/../dls-siggy/src:$(PWD)/../dls-utilpack/src:$(PWD)/../dls-pairstream/src
WORKFLOWS_DIRECTORY = $(VISIT_DIRECTORY)/processing/dls-bxflow-epsic-workflows
ISPYB_CREDENTIALS = $(WORKFLOWS_DIRECTORY)/configurations/ispyb-backup-restore-rw.cfg
BXFLOW_CONFIGFILE = $(WORKFLOWS_DIRECTORY)/configurations/multibox.yaml
# ------------------------------------------------------------------
# The possible services are: "all" or any of: {news dataface catalog launchers scheduler collector gui}
services ?= news dls_servbase_dataface dataface scheduler launchers catalog collector gui
start:
-pkill -9 -f Bx
PYTHONPATH=$(PYTHONPATH) \
BEAMLINE=$(BEAMLINE) \
BXFLOW_CONFIGFILE=$(BXFLOW_CONFIGFILE) \
ISPYB_CREDENTIALS=$(ISPYB_CREDENTIALS) \
python3 -m dls_bxflow_cli.main start_services \
--visit=$(visit) \
$(services) \
$(V)
# ------------------------------------------------------------------
_reprocess:
BEAMLINE=$(BEAMLINE) \
PYTHONPATH=$(WORKFLOWS_DIRECTORY)/workflows:$(PYTHONPATH) \
BXFLOW_CONFIGFILE=$(BXFLOW_CONFIGFILE) \
python3 -m $(workflow).workflow \
--data_label="$(data_label)" \
--visit=$(visit) \
$(V)
reprocess_show_versions:
PYTHONPATH=$(WORKFLOWS_DIRECTORY)/workflows:$(PYTHONPATH) \
BEAMLINE=$(BEAMLINE) \
BXFLOW_CONFIGFILE=$(BXFLOW_CONFIGFILE) \
python3 -m any_notebook.workflow \
--data_label="$(SAMPLE_SCAN)" \
--notebook=show_versions \
--visit=$(visit) \
$(V)
reprocess_mib_convert:
@make _reprocess \
workflow=mib_convert \
data_label="$(SAMPLE_SCAN)" \
V=$(V)
reprocess_basic_sed_datacheck:
@make _reprocess \
workflow=basic_sed_datacheck \
data_label="$(SAMPLE_SCAN)" \
V=$(V)
# ------------------------------------------------------------------
# Install into conda.
# This is where conda environment gets built.
# Global use is central to all, but slow to load.
# Local use is local to the current computer, but quicker to load.
CONDA_PREFIX_GLOBAL = /dls_sw/apps/bxflow/conda/envs
CONDA_PREFIX_LOCAL = /scratch/apps/bxflow/conda/envs
CONDA_PREFIX = $(CONDA_PREFIX_GLOBAL)/dls-bxflow-epsic/$(VERSION)
PYTHON_VERSION = 3.9
PIP_TARGET = $(CONDA_PREFIX)/lib/python3.9/site-packages
conda_clone:
module load mamba && \
mamba create --prefix $(CONDA_PREFIX) --clone $(CONDA_PREFIX_GLOBAL)/dls-bxflow/`ls -t $(CONDA_PREFIX_GLOBAL)/dls-bxflow | head -1`
pip_setup:
pip install --no-deps --python-version $(PYTHON_VERSION) --target $(PIP_TARGET) --upgrade git+https://gitlab.diamond.ac.uk/scisoft/bxflow/dls-bxflow-epsic.git@develop && rm -rf build
conda_all:
make conda_clone
make pip_setup
# -----------------------------------------------------------------------------------
# Command templates, expect "d=" command line argument.
DOCKER = docker
DOCKER_REGISTRY = gcr.io/diamond-privreg/kbp43231
DOCKER_PACKAGE = dls-bxflow-epsic
BUILD_DATE = $(shell date -Iseconds)
_docker_build:
$(DOCKER) build \
--tag $(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/$(d):$(VERSION) \
--tag $(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/$(d):latest \
--label "uk.ac.diamond.bxflow.make_command=make $@ d=$(d)" \
--label "uk.ac.diamond.bxflow.version=$(VERSION)" \
--label "uk.ac.diamond.bxflow.build_date=$(BUILD_DATE)" \
--build-arg DOCKER_PACKAGE="$(DOCKER_PACKAGE)" \
--build-arg IMAGE_BASENAME="$(d)" \
--build-arg DOCKER_IMAGE_VERSION="$(VERSION)" \
--build-arg BUILD_DATE="$(BUILD_DATE)" \
--file docker/$(d)/Dockerfile docker/$(d)
_docker_push:
$(DOCKER) push $(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/$(d):$(VERSION)
$(DOCKER) push $(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/$(d):latest
_docker_pull:
$(DOCKER) pull $(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/$(d):$(VERSION)
_docker_up:
$(DOCKER)-compose --file=$(d)/docker-compose.yml up
_docker_down:
$(DOCKER)-compose --file=$(d)/docker-compose.yml down
_docker_restart:
make _docker_down d=$(d)
make _docker_up d=$(d)
# ------------------------------------------------------------------
podman_pull:
podman pull $(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/services:latest
podman_run:
PYTHONPATH=$(WORKFLOWS_DIRECTORY)/workflows \
BEAMLINE=$(BEAMLINE) \
BXFLOW_CONFIGFILE=$(BXFLOW_CONFIGFILE) \
ISPYB_CREDENTIALS=$(ISPYB_CREDENTIALS) \
podman run --env-host \
--volume $(VISIT_DIRECTORY):$(VISIT_DIRECTORY) \
-it \
$(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/services:latest $(V)
podman_start_services:
PYTHONPATH=$(WORKFLOWS_DIRECTORY)/workflows \
BEAMLINE=$(BEAMLINE) \
BXFLOW_CONFIGFILE=$(BXFLOW_CONFIGFILE) \
ISPYB_CREDENTIALS=$(ISPYB_CREDENTIALS) \
podman run --env-host \
--volume $(VISIT_DIRECTORY):$(VISIT_DIRECTORY) \
$(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/services:latest \
python3 -m dls_bxflow_cli.main start_services \
--visit=$(visit) \
news dataface scheduler collector launcher gui \
$(V)
podman_show_versions:
PYTHONPATH=$(WORKFLOWS_DIRECTORY)/workflows \
BEAMLINE=$(BEAMLINE) \
BXFLOW_CONFIGFILE=$(BXFLOW_CONFIGFILE) \
podman run --env-host \
--volume $(VISIT_DIRECTORY):$(VISIT_DIRECTORY) \
$(DOCKER_REGISTRY)/$(DOCKER_PACKAGE)/services:latest \
python3 -m any_notebook.workflow \
--data_label="$(SAMPLE_SCAN)" \
--notebook=show_versions \
--visit=$(visit) \
$(V)
# ------------------------------------------------------------------
# Direct calls to the mib converter.
mib_convert:
# module load python/epsic3.7
PYTHONPATH=../ePSIC-DLS-epsic_tools/epsic_tools/mib2hdfConvert:$(PYTHONPATH) \
python3 -m mib2hdf_watch_convert --verbose e02 2022 cm31101-4 0 -folder "Merlin/au_xgrating"
# ------------------------------------------------------------------
# Rsync to copy files from developer computer to shared file system.
rsync:
../kbp43231_scripts/myrsync.py batch_mib_convert
../kbp43231_scripts/myrsync.py dls-bxflow-epsic
# ------------------------------------------------------------------
# Utility.
tree:
tree -I "__*" src
tree -I "__*" tests
.PHONY: list
list:
@awk "/^[^\t:]+[:]/" Makefile | grep -v ".PHONY"
clean:
find . -name '*.pyc' -exec rm -f {} \;
find . -name '__pycache__' -exec rm -rf {} \;
show_version:
PYTHONPATH=$(PYTHONPATH) python3 src/dls_bxflow_epsic/version.py --json
PYTHONPATH=$(PYTHONPATH) python3 src/dls_bxflow_epsic/version.py
# ------------------------------------------------------------------
# Version bumping. Configured in setup.cfg.
# Thanks: https://pypi.org/project/bump2version/
bump-patch:
bump2version --list patch
bump-minor:
bump2version --list minor
bump-major:
bump2version --list major
bump-dryrun:
bump2version --dry-run patch