Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
195 lines (162 loc) · 5.32 KB
/
Copy pathMakefile
File metadata and controls
195 lines (162 loc) · 5.32 KB
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
BASHSRCS = $(wildcard ../.github/scripts/*) format setup
HELPERS = vx zarr
MODULES = data inference training visualization wxvx
PACKAGE = eagle
STEPS = data grids-and-meshes inference training vis-grid-global vis-grid-lam vis-obs-global vis-obs-lam vx-grid-global vx-grid-lam vx-obs-global vx-obs-lam vx-stageiv-lam
TOOLING = config devenv env format lint realize shellcheck test typecheck unittest validate yamllint
VERBOSE = $(if $(filter undefined,$(origin DEBUG)),, --verbose)
INSTALLDIR ?= conda
SHELL := $(shell which bash)
NOW := $(shell date -u +"%Y-%m-%dT%H:%M:%S")
export NOW
activate = @source $(INSTALLDIR)/etc/profile.d/conda.sh && conda activate $(1)
check = @$(if $(1),,$(error $(2)= argument required))
exec = set -x && uw execute$(VERBOSE) --config-file $(config) --module $(PACKAGE)/$(1)/$(2).py --classname $(3) --task $(4)
make = $(MAKE) --no-print-directory
modenv = $(env4mod_$(1))
modloop = @set -eo pipefail && for mod in $(PACKAGE) $(MODULES); do $(make) mod=$$mod $(1); done
tasklist = @(set -x && uw execute$(VERBOSE) --module $(PACKAGE)/$(1)/$(2).py --classname $(3)) || true
env4mod_$(PACKAGE) = base
env4mod_data = data
env4mod_inference = anemoi
env4mod_training = anemoi
env4mod_visualization = visualization
env4mod_wxvx = wxvx
.ONESHELL:
.PHONY: $(HELPERS) $(STEPS) $(TOOLING)
all:
@echo Available targets:
@echo
@echo Pipeline steps: $(STEPS)
@echo Tooling: $(TOOLING)
@echo
false
config:
$(call check,$(compose),compose)
$(call activate,base)
@(set -x && uw config compose$(VERBOSE) $(foreach x,$(subst :, ,$(compose)),config/$(x).yaml))
data:
$(call activate,data)
@$(make) grids-and-meshes
@for x in gfs hrrr; do if [[ -n "$$(uw config realize -i $(config) --key-path zarrs.$$x 2>/dev/null)" ]]; then $(make) zarr source=$$x; fi; done
devenv:
$(call check,$(cudascript),cudascript)
EAGLEDEV=1 INSTALLDIR=$(INSTALLDIR) ./setup cudascript=$(cudascript)
env:
$(call check,$(cudascript),cudascript)
INSTALLDIR=$(INSTALLDIR) ./setup cudascript=$(cudascript)
format:
$(call activate,base)
./format $(PACKAGE)
grids-and-meshes:
$(call activate,data)
ifeq ($(task),?)
$(call tasklist,data,grids_and_meshes,GridsAndMeshes)
else
$(call check,$(config),config)
$(call exec,data,grids_and_meshes,GridsAndMeshes,$(or $(task),provisioned_rundir))
endif
inference:
$(call activate,anemoi)
ifeq ($(task),?)
$(call tasklist,inference,inference,Inference)
else
$(call check,$(config),config)
$(call exec,inference,inference,Inference,$(or $(task),run) --batch)
endif
lint:
ifdef mod
@echo "=> Linting package: $$mod"
$(call activate,$(call modenv,$(mod)))
ruff check $(PACKAGE)/$(if $(filter $(PACKAGE),$(mod)),*.py,$(mod))
else
$(call modloop,lint)
endif
realize:
$(call check,$(config),config)
$(call activate,base)
@(set -x && uw config realize$(VERBOSE) --input-file $(config)$(if $(update), --update-file $(update)))
shellcheck:
$(call activate,base)
@echo "=> Checking shell scripts"
@(set -x && shellcheck --format=gcc --severity=info --shell=bash $(BASHSRCS))
test: lint shellcheck typecheck yamllint unittest
training:
$(call activate,anemoi)
ifeq ($(task),?)
$(call tasklist,training,training,Training)
else
$(call check,$(config),config)
$(call exec,training,training,Training,$(or $(task),run) --batch)
endif
typecheck:
ifdef mod
@echo "=> Typechecking package: $$mod"
$(call activate,$(call modenv,$(mod)))
mypy $(PACKAGE)/$(if $(filter $(PACKAGE),$(mod)),*.py,$(mod))
else
$(call modloop,typecheck)
endif
unittest:
ifdef mod
@echo "=> Unit testing package: $$mod"
$(call activate,$(call modenv,$(mod)))
pytest $(if $(filter $(PACKAGE),$(mod)),,--cov=$(PACKAGE).$(mod) )$(PACKAGE)/$(if $(filter $(PACKAGE),$(mod)),*.py,$(mod))
else
$(call modloop,unittest)
endif
validate:
$(call check,$(config),config)
$(call activate,base)
@(set -x && uw config validate$(VERBOSE) --input-file $(config) --schema-file $(PACKAGE)/$(PACKAGE).jsonschema)
vis:
$(call activate,visualization)
ifeq ($(task),?)
$(call tasklist,visualization,visualization,Visualization)
else
$(call check,$(config),config)
$(call check,$(extent),extent)
$(call check,$(truth),truth)
$(call exec,visualization,visualization,Visualization,$(or $(task),plots) --key-path visualization.grid2$(truth).$(extent))
endif
vis-grid-global:
@$(make) vis truth=grid extent=global
vis-grid-lam:
@$(make) vis truth=grid extent=lam
vis-obs-global:
@$(make) vis truth=obs extent=global
vis-obs-lam:
@$(make) vis truth=obs extent=lam
vx:
$(call activate,wxvx)
ifeq ($(task),?)
$(call tasklist,wxvx,wxvx,VX)
else
$(call check,$(config),config)
$(call check,$(extent),extent)
$(call check,$(truth),truth)
$(call exec,wxvx,wxvx,WXVX,$(or $(task),run) --key-path vx.grid2$(truth).$(extent) --batch)
endif
vx-grid-global:
@$(make) vx truth=grid extent=global
vx-grid-lam:
@$(make) vx truth=grid extent=lam
vx-obs-global:
@$(make) vx truth=obs extent=global
vx-obs-lam:
@$(make) vx truth=obs extent=lam
vx-stageiv-lam:
@$(make) vx truth=stageiv extent=lam
yamllint:
$(call activate,base)
@echo "=> Linting YAML configs"
@(set -x && yamllint --no-warnings config/ envs/)
zarr:
$(call activate,data)
ifeq ($(task),?)
$(call tasklist,data,zarr,Zarr)
else
$(call check,$(config),config)
$(call check,$(source),source)
$(call exec,data,zarr,Zarr,$(or $(task),run) --key-path zarrs.$(source) --batch)
endif