-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
In suppliedElsewhere
there is a for
loop which iterates over other module's depenencies. Because del
is either filtered or re-assigned to dd
within each iteration, the only load order that is being considered is that of the final module in otherModDeps
.
inFutureInit <- if (any(c("i", "c") %in% forms$where)) {
del <- depsEdgeList(sim, plot = FALSE)
# if ("c" %in% forms$where) {
# The next line is subtle -- it must be provided by another module, previously loaded (thus in the depsEdgeList),
# but that does not need it itself. If it needed it itself, then it would have loaded it already in the simList
# which is checked in a different test of suppliedElsewhere -- i.e., "sim"
dd <- del[objName %in% objDeparsed][from != to][!(from %in% c("_INPUT_")), ]
d <- depends(sim)
otherModsDeps <- d@dependencies[which(!names(d@dependencies) %in% currentModule(sim))]
for (mod in otherModsDeps) {
lo <- mod@loadOrder
if (!is.null(lo$after)){
del <- dd[from %in% lo$after]
} else del <- dd #THIS LINE IS CAUSING THE ISSUE
}
# if (any(c("i", "c") %in% forms$where)) {
# The next line is subtle -- it must be provided by another module, previously loaded (thus in the depsEdgeList),
# but that does not need it itself. If it needed it itself, then it would have loaded it already in the simList
# which is checked in a different test of suppliedElsewhere -- i.e., "sim"
# if (exists("aaaa", envir = .GlobalEnv)) browser()
out <- del[!(from %in% c("_INPUT_", currentModule(sim))), ][
objName %in% objDeparsed]
out <- out[, .(objName, noFeedback = all(from != to)), by = from][noFeedback %in% TRUE]
objDeparsed %in% out$objName
Reprex (the tricky part was getting box and AI to install correctly)
The error will be an geographic extent error if Biomass_core supplies the object (because it is at the extent of rasterToMatch
, not rasterToMatchLarge
), or it will be an error that speciesLayers is missing in the Init of BBDP if Biomass_core does not supply it. In this case, it appears to depend on loadOrder
and whether Biomass_core's loadOrder
metadata is updated to include after = c("Biomass_borealDataPrep")
.
repos <- c("https://predictiveecology.r-universe.dev", getOption("repos"))
source("https://raw.githubusercontent.com/PredictiveEcology/pemisc/refs/heads/development/R/getOrUpdatePkg.R")
getOrUpdatePkg(c("Require", "SpaDES.project"), c("1.0.1.9003", "0.1.1.9009")) # only install/update if required
projPath = file.path(getwd(), "suppliedElsewhere_reprex")
Require::Require("PredictiveEcology/reproducible@AI")
Require::Require("PredictiveEcology/SpaDES.core@box")
out <- SpaDES.project::setupProject(
paths = list(projectPath = projPath),
modules = c("PredictiveEcology/Biomass_borealDataPrep@development",
"PredictiveEcology/Biomass_core@main",
"PredictiveEcology/Biomass_regeneration@development" #need some extra module to trigger bug
),
options = list("reproducible.inputPaths" = "~/data"),
params = list(),
packages = c('RCurl', 'XML', 'snow', 'googledrive', 'httr2', "gert", "remotes",
"PredictiveEcology/LandR@development"),
times = list(start = 2011, end = 2012),
studyArea = {
sa <- LandR::randomStudyArea(size = 10000*6.25*5000)
},
studyAreaLarge = {
terra::buffer(studyArea, 2000)
},
rasterToMatchLarge = {
rtml<- terra::rast(studyAreaLarge, res = c(250,250))
rtml[] <- 1
rtml <- terra::mask(rtml, studyAreaLarge)
},
rasterToMatch = {
rtm <- reproducible::postProcess(rasterToMatchLarge, cropTo = studyArea, maskTo = studyArea)
},
sppEquiv = {
speciesInStudy <- LandR::speciesInStudyArea(studyAreaLarge, dPath = "inputs")
species <- LandR::equivalentName(speciesInStudy$speciesList, df = LandR::sppEquivalencies_CA, "LandR")
sppEquiv <- LandR::sppEquivalencies_CA[LandR %in% species]
sppEquiv <- sppEquiv[grep("_spp", KNN, invert = TRUE)]
},
loadOrder = unlist(modules)
)
outSim <- SpaDES.core::simInitAndSpades2(out)
Metadata
Metadata
Assignees
Labels
No labels