-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_targets.R
executable file
·159 lines (139 loc) · 4.29 KB
/
_targets.R
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
library(targets)
library(tarchetypes)
library(future)
library(future.batchtools)
library(dplyr)
library(
beethoven,
lib.loc = "/ddn/gs1/home/manwareme/R/x86_64-pc-linux-gnu-library/4.3"
)
library(tidymodels)
library(bonsai)
# library(
# torch,
# lib.loc = "/ddn/gs1/biotools/R/lib64/R/library"
# )
Sys.setenv("LD_LIBRARY_PATH" = paste("/ddn/gs1/biotools/R/lib64/R/customlib", Sys.getenv("LD_LIBRARY_PATH"), sep = ":"))
# replacing yaml file.
tar_config_set(
store = "/ddn/gs1/home/manwareme/beethoven/beethoven_targets"
)
# maximum future exportable object size is set 50GB
# TODO: the maximum size error did not appear until recently
# and suddenly appeared. Need to investigate the cause.
# Should be removed after the investigation.
# options(future.globals.maxSize = 50 * 2^30)
options(future.globals.maxSize = 60 * 1024^3) # 60 GiB
generate_list_download <- FALSE
arglist_download <-
set_args_download(
char_period = c("2018-01-01", "2022-12-31"),
char_input_dir = "input",
nasa_earth_data_token = NULL,#Sys.getenv("NASA_EARTHDATA_TOKEN"),
mod06_filelist = "inst/targets/mod06_links_2018_2022.csv",
export = generate_list_download,
path_export = "inst/targets/download_spec.qs"
)
generate_list_calc <- FALSE
arglist_common <-
set_args_calc(
char_siteid = "site_id",
char_timeid = "time",
char_period = c("2018-01-01", "2022-12-31"),
num_extent = c(-126, -62, 22, 52),
char_user_email = paste0(Sys.getenv("USER"), "@nih.gov"),
export = generate_list_calc,
path_export = "inst/targets/calc_spec.qs",
char_input_dir = "/ddn/gs1/group/set/Projects/NRT-AP-Model/input"
)
tar_source("inst/targets/targets_initialize.R")
tar_source("inst/targets/targets_download.R")
tar_source("inst/targets/targets_calculate_fit.R")
tar_source("inst/targets/targets_calculate_predict.R")
tar_source("inst/targets/targets_baselearner.R")
tar_source("inst/targets/targets_metalearner.R")
tar_source("inst/targets/targets_predict.R")
# bypass option
Sys.setenv("BTV_DOWNLOAD_PASS" = "TRUE")
#
# bind custom built GDAL
# Users should export the right path to the GDAL library
# by export LD_LIBRARY_PATH=.... command.
# arglist_common is generated above
plan(
list(
tweak(
future.batchtools::batchtools_slurm,
template = "inst/targets/template_slurm.tmpl",
resources =
list(
memory = 8,
log.file = "slurm_run.log",
ncpus = 1, partition = "geo", ntasks = 1,
email = arglist_common$char_user_email,
error.file = "slurm_error.log"
)
),
multicore
)
)
# # invalidate any nodes older than 180 days: force running the pipeline
# tar_invalidate(any_of(tar_older(Sys.time() - as.difftime(180, units = "days"))))
# # nullify download target if bypass option is set
if (Sys.getenv("BTV_DOWNLOAD_PASS") == "TRUE") {
target_download <- NULL
}
# targets options
# For GPU support, users should be aware of setting environment
# variables and GPU versions of the packages.
# TODO: check if the controller and resources setting are required
tar_option_set(
packages = c(
"beethoven", "amadeus", "chopin", "targets", "tarchetypes",
"data.table", "sf", "terra", "exactextractr",
#"crew", "crew.cluster",
"tigris", "dplyr",
"future.batchtools", "qs", "collapse", "bonsai",
"tidymodels", "tune", "rsample", "torch", "brulee",
"glmnet", "xgboost",
"future", "future.apply", "future.callr", "callr",
"stars", "rlang", "parallelly"
),
library = c("/ddn/gs1/group/set/isong-archive/r-libs"),
repository = "local",
error = "abridge",
memory = "transient",
format = "qs",
storage = "worker",
deployment = "worker",
garbage_collection = TRUE,
seed = 202401L
)
# should run tar_make_future()
list(
target_init,
target_download,
target_calculate_fit,
target_baselearner,
target_metalearner,
target_calculate_predict#,
# target_predict,
# # documents and summary statistics
# targets::tar_target(
# summary_urban_rural,
# summary_prediction(
# grid_filled,
# level = "point",
# contrast = "urbanrural"))
# ,
# targets::tar_target(
# summary_state,
# summary_prediction(
# grid_filled,
# level = "point",
# contrast = "state"
# )
# )
)
# targets::tar_visnetwork(targets_only = TRUE)
# END OF FILE