-
Notifications
You must be signed in to change notification settings - Fork 0
/
04-options.R
70 lines (62 loc) · 2.57 KB
/
04-options.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
cache_conn <- if (config::get("cachedb") == "sqlite") {
NULL ## default to sqlite
} else if (config::get("cachedb") == "postgresql") {
Require("RPostgres", require = FALSE)
DBI::dbConnect(drv = RPostgres::Postgres(),
host = Sys.getenv("PGHOST"),
port = Sys.getenv("PGPORT"),
dbname = Sys.getenv("PGDATABASE"),
user = Sys.getenv("PGUSER"),
password = Sys.getenv("PGPASSWORD"))
} else {
stop("Unsupported cache database type '", config::get("cachedb"), "'")
}
maxMemory <- 5e+12
terra::terraOptions(tempdir = checkPath(file.path(scratchDir, "terra"), create = TRUE))
raster::rasterOptions(default = TRUE)
opts <- options(
"encoding" = "UTF-8",
"LandR.assertions" = FALSE,
"LandR.verbose" = 1,
"rasterMaxMemory" = maxMemory,
"rasterTmpDir" = file.path(scratchDir, "raster"),
"reproducible.cachePath" = file.path(scratchDir, "cache"),
"reproducible.cacheSaveFormat" = cacheFormat,
"reproducible.conn" = cache_conn,
"reproducible.destinationPath" = normPath(defaultPaths[["inputPath"]]),
"reproducible.inputPaths" = userInputPaths,
"reproducible.nThreads" = 2,
"reproducible.overwrite" = TRUE,
"reproducible.polygonShortcut" = FALSE,
"reproducible.quick" = FALSE,
"reproducible.showSimilar" = TRUE,
"reproducible.useCache" = TRUE,
"reproducible.useCloud" = TRUE,
"reproducible.useGDAL" = FALSE,
"reproducible.useMemoise" = useMemoise,
"reproducible.useNewDigestAlgorithm" = reproducibleAlgorithm,
"reproducible.useRequire" = useRequire,
"reproducible.useTerra" = useTerra,
"spades.messagingNumCharsModule" = messagingNumCharsModule,
"spades.moduleCodeChecks" = codeChecks,
"spades.nThreads" = 4,
"spades.recoveryMode" = FALSE,
"spades.restartR.restartDir" = defaultPaths[["outputPath"]],
"spades.scratchPath" = scratchDir,
"spades.useRequire" = useRequire
)
httr::set_config(httr::config(http_version = 0))
httr::timeout(seconds = 10)
token <- Require::normPath(list.files(".", "western-boreal-initiative-.*[.]json")[1])
haveToken <- all(isTRUE(length(token) == 1), !is.na(token))
if (haveToken) {
drive_auth(path = token)
} else {
message(crayon::red("No Google service account token found. Trying user authentication..."))
googledrivecache <- config::get("cloud")[["googledrivecache"]]
if (!is.null(googledrivecache)) {
options(gargle_oauth_cache = googledrivecache)
}
drive_auth(email = config::get("cloud")[["googleuser"]], use_oob = quickPlot::isRstudioServer())
}
message(crayon::silver("Authenticating as: "), crayon::green(drive_user()$emailAddress))