-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_targets.R
133 lines (106 loc) · 5.3 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
library(Matrix)
library(targets)
# targets::tar_make() to run the pipeline in a single thread.
# targets::tar_make_future(workers = 8) to execute across multiple cores.
# targets::tar_make(callr_function = NULL) to debug.
# targets::tar_read(<<target_name>>) to view the results.
# targets::tar_invalidate(<<target_name>>) to re-compute <<target_name>> and its dependents.
# targets::tar_destroy() to start over with everything,
# Set control parameters for the pipeline.
# Set the countries to be analyzed.
# countries <- c("GBR", "USA", "MEX")
# countries <- c("ZWE", "USA", "WRLD")
# countries <- "USA"
# countries <- "WRLD"
# countries <- "CHNM"
# countries <- "GHA"
# countries <- "all" # Run all countries in the PSUT target.
# Countries with unique allocation data plus BEL and TUR (for Pierre).
# countries <- c("BRA", "CAN", "CHNM", "DEU", "DNK", "ESP", "FRA", "GBR", "GHA", "GRC",
# "HKG", "HND", "IDN", "IND", "JOR", "JPN", "KOR", "MEX", "NOR", "PRT",
# "RUS", "USA", "WABK", "WMBK", "ZAF", "BEL", "TUR")
countries <- c(PFUPipelineTools::canonical_countries, "WRLD") |> as.character()
# Set the years to be analyzed.
# years <- 1971:1973
# years <- 1971:1978
# years <- 1971
# years <- 1960
# years <- 1960:1961
years <- 1960:2020
# Tells whether to do the R and Y chops.
do_chops <- FALSE
setup_version <- "v1.3"
output_version <- "v1.3b2"
# Set the release to be used for input.
# psut_release <- "20230309T184624Z-7ace5" # v0.9 (USA only)
# psut_release <- "20221109T152414Z-7d7ad" # v1.0 (with matrix objects)
# psut_release <- "20230312T211924Z-007da" # v1.0 (with Matrix objects)
# psut_release <- "20230618T131003Z-4c70f" # v1.1 (with Matrix objects)
# psut_release <- "20230915T185731Z-c48a0" # v1.2a1 (Lacks new phi values and updated IEA data)
# psut_release <- "20230924T185331Z-13381" # v1.2a2 (Includes new phi values, removes CHNM as RUS exemplar. Lacks updated IEA data)
# psut_release <- "20231207T124854Z-73744" # v1.2
# psut_release <- "20221219T143657Z-964a6" # For WRLD
# psut_release <- "20230130T150642Z-631e2" # For WRLD, 1971
# psut_release <- "20230130T192359Z-1d3ec" # For WRLD, 1971-2019
psut_release <- PFUSetup::pin_versions(output_version)[["psut"]]
Y_fu_U_EIOU_fu_details_release <- PFUSetup::pin_versions(output_version)[["Y_fu_U_EIOU_fu_details"]]
# psut_without_neu_release <- "20231207T124907Z-bdcbc" # v1.2 (hopefully) final
psut_without_neu_release <- PFUSetup::pin_versions(output_version)[["psut_without_neu"]]
# phi_vecs_release <- "20231207T124813Z-c8827" # v1.2
phi_vecs_release <- PFUSetup::pin_versions(output_version)[["phi_vecs"]]
# Should we release the results?
release <- FALSE
# End user-adjustable parameters.
#
# Set up some machine-specific parameters,
# mostly for input and output locations.
#
sys_info <- Sys.info()
if (startsWith(sys_info[["nodename"]], "Mac")) {
setup <- PFUSetup::get_abs_paths(version = setup_version)
} else if (endsWith(sys_info[["nodename"]], "arc4.leeds.ac.uk")) {
uname <- sys_info[["user"]]
setup <- PFUSetup::get_abs_paths(version = setup_version,
home_path <- "/nobackup",
dropbox_path = uname)
# Set the location for the _targets folder.
targets::tar_config_set(store = file.path(setup[["output_data_path"]], "_targets/"))
} else if ((sys_info[["sysname"]] == "Linux") && (sys_info[["user"]] == "eeear")){
setup <- PFUSetup::get_abs_paths(version = setup_version)
setup["pipeline_releases_folder"] <- "/home/eeear/Documents/Datasets/GPFU_database/Releases"
setup[["aggregation_mapping_path"]] <- paste0("/home/eeear/Documents/Datasets/GPFU_database/InputData/",
setup_version,
"aggregation_mapping.xlsx")
setup[["country_concordance_path"]] <- "inst/exiobase_data/Country_Concordance_Full.xlsx"
} else {
stop("Unknown system in _targets.R for PFUAggPipeline. Can't set input and output locations.")
}
# Set up for multithreaded work on the local machine.
future::plan(future.callr::callr)
# Set options for all targets.
targets::tar_option_set(
packages = "PFUAggPipeline",
# Indicate that storage and retrieval of subtargets
# should be done by the worker thread,
# not the main thread.
# These options set defaults for all targets.
# Individual targets can override.
storage = "worker",
retrieval = "worker",
# Tell targets to NOT keep everything in memory ...
memory = "transient",
# ... and to garbage-collect the memory when done.
garbage_collection = TRUE
)
# Pull in the pipeline
PFUAggPipeline::get_pipeline(countries = countries,
years = years,
do_chops = do_chops,
psut_release = psut_release,
psut_without_neu_release = psut_without_neu_release,
phi_vecs_release = phi_vecs_release,
Y_fu_U_EIOU_fu_details_release = Y_fu_U_EIOU_fu_details_release,
aggregation_maps_path = setup[["aggregation_mapping_path"]],
pipeline_releases_folder = setup[["pipeline_releases_folder"]],
pipeline_caches_folder = setup[["pipeline_caches_folder"]],
release = release)