Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postProcess operations not being cached when nested in prepInputs call? #383

Open
CeresBarros opened this issue Feb 28, 2024 · 4 comments
Open

Comments

@CeresBarros
Copy link
Member

I've noticed that my crop/mask/projection operations do not seem to be cached when running a prepInputs call:

reprex:

Require::Require("PredictiveEcology/reproducible")

options(reproducible.destinationPath = "~/reproducible_test/data",
        reproducible.cachePath = "~/reproducible_test/cache")

shpUrl <- "http://sis.agr.gc.ca/cansis/nsdb/ecostrat/zone/ecozone_shp.zip"

studyArea <- SpaDES.tools::randomStudyArea(size = 20000)

ecozoneFilename <- file.path(options("reproducible.cachePath"), "ecozones.shp")
ecozoneFiles <- c(
  "ecozones.dbf", "ecozones.prj",
  "ecozones.sbn", "ecozones.sbx", "ecozones.shp", "ecozones.shx"
)

shpEcozone <- prepInputs(
  url = shpUrl,
  targetFile = reproducible::asPath(ecozoneFilename),
  alsoExtract = reproducible::asPath(ecozoneFiles),
  to = studyArea
)

shpEcozone <- prepInputs(
  url = shpUrl,
  targetFile = reproducible::asPath(ecozoneFilename),
  alsoExtract = reproducible::asPath(ecozoneFiles),
  to = studyArea
)
@eliotmcintire
Copy link
Contributor

When terra was used under the hood, most (all?) of the internal caching was removed as it tended to be less effective as the terra operations were so much faster. I believe the best option is to cache the entire call:


shpEcozone <- prepInputs(
  url = shpUrl,
  targetFile = reproducible::asPath(ecozoneFilename),
  alsoExtract = reproducible::asPath(ecozoneFiles),
  to = studyArea
) |>
Cache()

@CeresBarros
Copy link
Member Author

CeresBarros commented Feb 29, 2024

I see -- I either forgot or didn't realise that. In that case the documentation for prepInputs(..., useCache) needs to be clarified as it currently suggests caching will happen up on these operations. I'm happy to PR a doc fix -- is development still the best branch to PR to?

@eliotmcintire
Copy link
Contributor

Yes. Please use @modsForLargeArchives for PR.

@CeresBarros
Copy link
Member Author

please ignore first PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants