I'm trying to use setupProjector setupModules to download/source .R files from github. I'm clearly doing something wrong as the following is not adding any modules to the simPath$modulePath as I would expect it to? Or is it not supposed to do that?
In particular I want to:
- create a new SpaDES project called "SpaDES4Dummies_Part2" in a temporary directory ()
- in
<tempdir>/SpaDES4Dummies_Part2I want to create the necessary folder structure (inputs, modules, outputs, cache, etc) - I want to "populate"
<tempdir>/SpaDES4Dummies_Part2/moduleswith modules from the CeresBarros/SpaDES4Dummies GitHub repo
mainPath <- file.path(tempdir(), "SpaDES4Dummies_Part2")
pkgPath <- file.path(mainPath, "packages", version$platform,
paste0(version$major, ".", strsplit(version$minor, "[.]")[[1]][1]))
dir.create(pkgPath, recursive = TRUE)
.libPaths(pkgPath, include.site = FALSE) ## install packages in project library (proj-lib)
if (!"Require" %in% installed.packages(lib.loc = pkgPath))
install.packages("Require")
## use binary linux packages if on Ubuntu
Require::setLinuxBinaryRepo()
Require::Require(c("PredictiveEcology/SpaDES.project@4fbd77466d5b1f3bef15d7fd383ed797fd92aa7a",
"SpaDES.core"),
require = FALSE, upgrade = FALSE, standAlone = TRUE)
library(SpaDES.project)
## setup project paths
SpaDES.core::setPaths(cachePath = file.path(mainPath, "cache"),
inputPath = file.path(mainPath, "inputs"),
modulePath = file.path(mainPath, "modules"),
outputPath = file.path(mainPath, "outputs"))
simPaths <- SpaDES.core::getPaths()
simPaths$packagePath <- pkgPath
setupProject(name = "SpaDES4Dummies_Part2",
paths = simPaths,
modules = c("https://github.com/CeresBarros/SpaDES4Dummies/blob/master/modules/climateData/climateData.R",
"https://github.com/CeresBarros/SpaDES4Dummies/blob/master/modules/speciesAbundanceData/speciesAbundanceData.R",
"https://github.com/CeresBarros/SpaDES4Dummies/blob/master/modules/projectSpeciesDist/projectSpeciesDist.R"),
options = list("reproducible.cachePath" = simPaths$cachePath,
"reproducible.destinationPath" = simPaths$inputPath,
"reproducible.rasterRead" = "terra::rast",
"reproducible.useTerra" = TRUE))
There were multiple issues in the code above:
.Rfiles will not be sufficient asSpaDESmodules involve more than one .R script. Instead we need to get the full contents of the CeresBarros/SpaDES4Dummies repository and then keep only the desired modules.SpaDES.project.setupProjectdeals with this and with copying any necessary packages to the project-level package directoryAs a result, the code can be much simplified to achieve the desired output: