-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path1_wqdata.yml
246 lines (215 loc) · 8.81 KB
/
1_wqdata.yml
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
target_default: 1_wqdata
packages:
- dplyr
- dataRetrieval
- feather
- LAGOSNE
- scipiper
- yaml
- xml2
- doParallel
- foreach
- kableExtra
- pander
- GenKern
file_extensions:
- feather
- ind
sources:
- lib/src/check_gd_config.R
- lib/src/render_rmd.R
- 1_wqdata/src/0_wqp.R
targets:
1_wqdata:
depends:
- confirm_gd_config
- 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
- 1_wqdata/doc/2_combined_wqp_munge.html
- 1_wqdata/doc/3_wqp_merge_widen.html
- 1_wqdata/doc/4_wqp_lagos_merge.html
confirm_gd_config:
command: check_gd_config()
#### shared config info ####
wq_dates:
command: yaml.load_file("1_wqdata/cfg/wq_dates.yml")
#### WQP ####
# -- prepare for data pull --
# load wqp-specific config info
wqp_states:
command: yaml.load_file("1_wqdata/cfg/wqp_states.yml")
wqp_codes:
command: yaml.load_file("1_wqdata/cfg/wqp_codes.yml")
wqp_state_codes:
command: get_wqp_state_codes()
wqp_pull:
command: yaml.load_file("1_wqdata/cfg/wqp_pull.yml")
# prepare destination folders for intermediate and final output.
# tmp=temporary folder for holding files to only be created on 1 computer.
# out=folder to hold .ind and data files corresponding to shared cache or everybody's local build.
# log=folder for the few indicator files that don't correspond to a data file.
1_wqdata/tmp/wqp:
command: dir.create(target_name, recursive=I(TRUE), showWarnings=I(FALSE))
1_wqdata/out/wqp:
command: dir.create(target_name, recursive=I(TRUE), showWarnings=I(FALSE))
1_wqdata/log:
command: dir.create(target_name, recursive=I(TRUE), showWarnings=I(FALSE))
wqp_pull_folders:
command: list(
tmp='1_wqdata/tmp/wqp',
out='1_wqdata/out/wqp',
log='1_wqdata/log')
# -- get inventory of observations available to download --
# get an inventory of WQP sites and sample counts. for this and all
# shared-cache targets (and those that depend on any shared-cache targets),
# the heavy lifting is done by the .ind recipe, which writes the data (.feather)
# file, posts the file to google drive, and writes the .feather.ind file.
# (the local data creation and drive posting could be separated into two
# remake targets, but let's risk having to redo the inventory for the sake of
# keeping this remake file a touch simpler and practicing the two-target option
# for gd_put/gd_get)
1_wqdata/tmp/wqp_inventory.feather.ind:
command: inventory_wqp(
ind_file=target_name,
wqp_state_codes=wqp_state_codes,
wqp_states=wqp_states,
wqp_codes=wqp_codes)
1_wqdata/out/wqp_inventory.feather.ind:
command: gd_put(
target_name,
'1_wqdata/tmp/wqp_inventory.feather.ind')
# the only job of the data target is to pull data from the shared cache
1_wqdata/out/wqp_inventory.feather:
command: gd_get('1_wqdata/out/wqp_inventory.feather.ind')
# use the inventory. because this is an object, everybody will end up
# pulling wqp_inventory.feather and building this object locally, if only
# to know whether 1_wqdata/log/tasks_1_wqp.ind is up to date
wqp_pull_partitions:
command: partition_inventory(
inventory_ind='1_wqdata/out/wqp_inventory.feather.ind',
wqp_pull=wqp_pull,
wqp_state_codes=wqp_state_codes,
wqp_codes=wqp_codes)
# -- pull the data --
# prepare a remake-style plan for running each state as a separate
# remake target in a separate remake file (tasks_1_wqp.yml)
wqp_pull_plan:
command: plan_wqp_pull(partitions=wqp_pull_partitions, folders=wqp_pull_folders)
tasks_1_wqp.yml:
command: create_wqp_pull_makefile(makefile=target_name, task_plan=wqp_pull_plan)
# run the data pulls
1_wqdata/log/tasks_1_wqp.ind:
command: loop_tasks(
task_plan=wqp_pull_plan, task_makefile='tasks_1_wqp.yml',
num_tries=I(30), sleep_on_error=I(20))
# --combine the data --
# prepare a remake-style plan for combining and munging the data for each constituent
wqp_merge_plan:
command: plan_wqp_merge(partitions=wqp_pull_partitions, pull_plan=wqp_pull_plan, folders=wqp_pull_folders)
tasks_1_wqp_merge.yml:
command: create_wqp_merge_makefile(makefile=target_name, task_plan=wqp_merge_plan, pull_makefile='tasks_1_wqp.yml')
# combine the raw data files
#task_names=I('cdom'), step_names=I('munge'),
1_wqdata/log/tasks_1_wqp_merge.ind:
command: loop_tasks(
task_plan=wqp_merge_plan, task_makefile='tasks_1_wqp_merge.yml',
num_tries=I(1), sleep_on_error=I(1))
# side effects of 1_wqdata/log/tasks_1_wqp_merge.ind include the following
# *.feather.ind files. the following targets declare that relationship and
# also provide retrival instructions for getting the corresponding *.feather files
1_wqdata/out/wqp/all_raw_secchi.feather:
depends: 1_wqdata/log/tasks_1_wqp_merge.ind
command: gd_get(I('1_wqdata/out/wqp/all_raw_secchi.feather.ind'))
1_wqdata/out/wqp/all_raw_tss.feather:
depends: 1_wqdata/log/tasks_1_wqp_merge.ind
command: gd_get(I('1_wqdata/out/wqp/all_raw_tss.feather.ind'))
1_wqdata/out/wqp/all_raw_doc.feather:
depends: 1_wqdata/log/tasks_1_wqp_merge.ind
command: gd_get(I('1_wqdata/out/wqp/all_raw_doc.feather.ind'))
1_wqdata/out/wqp/all_raw_chlorophyll.feather:
depends: 1_wqdata/log/tasks_1_wqp_merge.ind
command: gd_get(I('1_wqdata/out/wqp/all_raw_chlorophyll.feather.ind'))
# --- MUNGING --- #
# main effect of 1_wqdata/src/1_wqp_data_harmonize_explorer.Rmd:
1_wqdata/doc/1_wqp_data_harmonize_explorer.html:
depends:
- 1_wqdata/log/tasks_1_wqp_merge.ind
command: render_rmd(
input='1_wqdata/src/1_wqp_data_harmonize_explorer.Rmd',
output_file=target_name)
# side effects of 1_wqdata/src/1_wqp_data_harmonize_explorer.Rmd:
1_wqdata/tmp/harmonized/secchi_harmony.feather:
depends: 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
command: c()
1_wqdata/tmp/harmonized/chl.a_harmony.feather:
depends: 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
command: c()
1_wqdata/tmp/harmonized/tss_harmony.feather:
depends: 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
command: c()
1_wqdata/tmp/harmonized/doc_harmony.feather:
depends: 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
command: c()
1_wqdata/tmp/harmonized/tis_harmony.feather:
depends: 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
command: c()
1_wqdata/tmp/harmonized/sand_harmony.feather:
depends: 1_wqdata/doc/1_wqp_data_harmonize_explorer.html
command: c()
# main effect of 1_wqdata/src/2_combined_wqp_munge.Rmd:
1_wqdata/doc/2_combined_wqp_munge.html:
depends:
- 1_wqdata/tmp/harmonized/secchi_harmony.feather
- 1_wqdata/tmp/harmonized/chl.a_harmony.feather
- 1_wqdata/tmp/harmonized/tss_harmony.feather
- 1_wqdata/tmp/harmonized/doc_harmony.feather
- 1_wqdata/tmp/harmonized/tis_harmony.feather
- 1_wqdata/tmp/harmonized/sand_harmony.feather
command: render_rmd(
input='1_wqdata/src/2_combined_wqp_munge.Rmd',
output_file=target_name)
# side effects of 1_wqdata/src/2_combined_wqp_munge.Rmd:
1_wqdata/out/unity/secchi_unity.feather:
depends: 1_wqdata/doc/2_combined_wqp_munge.html
command: c()
1_wqdata/out/unity/chl.a_unity.feather:
depends: 1_wqdata/doc/2_combined_wqp_munge.html
command: c()
1_wqdata/out/unity/tss_unity.feather:
depends: 1_wqdata/doc/2_combined_wqp_munge.html
command: c()
1_wqdata/out/unity/doc_unity.feather:
depends: 1_wqdata/doc/2_combined_wqp_munge.html
command: c()
1_wqdata/out/unity/tis_unity.feather:
depends: 1_wqdata/doc/2_combined_wqp_munge.html
command: c()
1_wqdata/out/unity/sand_unity.feather:
depends: 1_wqdata/doc/2_combined_wqp_munge.html
command: c()
# main effect of 1_wqdata/src/3_wqp_merge_widen.Rmd:
1_wqdata/doc/3_wqp_merge_widen.html:
depends:
- 1_wqdata/out/unity/secchi_unity.feather
- 1_wqdata/out/unity/chl.a_unity.feather
- 1_wqdata/out/unity/tss_unity.feather
- 1_wqdata/out/unity/doc_unity.feather
- 1_wqdata/out/unity/tis_unity.feather
- 1_wqdata/out/unity/sand_unity.feather
command: render_rmd(
input='1_wqdata/src/3_wqp_merge_widen.Rmd',
output_file=target_name)
# side effects of 1_wqdata/src/3_wqp_merge_widen.Rmd:
1_wqdata/out/wqp_unity_wide.feather:
depends: 1_wqdata/doc/3_wqp_merge_widen.html
command: c()
# main effect of 1_wqdata/src/4_wqp_lagos_merge.Rmd:
1_wqdata/doc/4_wqp_lagos_merge.html:
depends:
- 1_wqdata/out/wqp_unity_wide.feather
command: render_rmd(
input='1_wqdata/src/4_wqp_lagos_merge.Rmd',
output_file=target_name)
# side effects of 1_wqdata/src/4_wqp_lagos_merge.Rmd:
1_wqdata/out/wqp_lagos_unity.feather:
depends: 1_wqdata/doc/4_wqp_lagos_merge.html
command: gd_get(I('1_wqdata/out/wqp_lagos_unity.feather.ind'))