Wrapper functions to access the packages options for default working directories. Note: there is an active binding made to Paths, so a user can use Paths$cachePath for example instead of getPaths()$cachePath

.paths()

getPaths()

Paths

setPaths(
  cachePath,
  inputPath,
  modulePath,
  outputPath,
  rasterPath,
  scratchPath,
  terraPath,
  silent = FALSE
)

Format

An object of class list of length 7.

Arguments

cachePath

The default local directory in which to cache simulation outputs. If not specified, defaults to getOption("reproducible.cachePath").

inputPath

The default local directory in which to look for simulation inputs If not specified, defaults to getOption("spades.inputPath").

modulePath

The default local directory where modules and data will be downloaded and stored. If not specified, defaults to getOption("spades.modulePath").

outputPath

The default local directory in which to save simulation outputs. If not specified, defaults to getOption("spades.outputPath").

rasterPath

The default local directory in which to save transient raster files. If not specified, defaults to file.path(getOption("spades.scratchPath"), "raster"). Important note: this location may not be cleaned up automatically, so be sure to monitor this directory and remove unnecessary temp files that may contribute to excessive disk usage. This option will be deprecated in a future release.

scratchPath

The default local directory in which to save transient files. If not specified, defaults to getOption("spades.scratchPath"). Important note: this location may not be cleaned up automatically, so be sure to monitor this directory and remove unnecessary temp files that may contribute to excessive disk usage.

terraPath

The default local directory in which to save transient terra files. If not specified, defaults to file.path(getOption("spades.scratchPath"), "terra"). Important note: this location may not be cleaned up automatically, so be sure to monitor this directory and remove unnecessary temp files that may contribute to excessive disk usage.

silent

Logical. Should the messaging occur.

Value

getPaths returns a named list of the user's default working directories. setPaths is invoked for the side effect of setting these directories.

Author

Alex Chubaty

Examples

# \donttest{
getPaths()                       ## returns the current default working paths
#> $cachePath
#> [1] "/tmp/RtmpoLaiAE/myProject/cache"
#> 
#> $inputPath
#> [1] "/tmp/RtmpoLaiAE/myProject/inputs"
#> 
#> $modulePath
#> [1] "/tmp/RtmpoLaiAE/myProject/modules"
#> 
#> $outputPath
#> [1] "/tmp/RtmpoLaiAE/myProject/outputs"
#> 
#> $rasterPath
#> [1] "/tmp/RtmpoLaiAE/SpaDES/scratch/raster"
#> 
#> $scratchPath
#> [1] "/tmp/RtmpoLaiAE/SpaDES/scratch"
#> 
#> $terraPath
#> [1] "/tmp/RtmpoLaiAE/SpaDES/scratch/terra"
#> 

## set individual custom paths
setPaths(cachePath = file.path(tempdir(), "cache"))
#> Setting:
#>   options(
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/myProject/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE/myProject/outputs'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/myProject/modules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/SpaDES/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/SpaDES/scratch/terra'
setPaths(inputPath = file.path(tempdir(), "inputs"))
#> Setting:
#>   options(
#>     spades.inputPath = '/tmp/RtmpoLaiAE/inputs'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE/myProject/outputs'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/myProject/modules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/SpaDES/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/SpaDES/scratch/terra'
setPaths(modulePath = file.path(tempdir(), "modules"))
#> Setting:
#>   options(
#>     spades.modulePath = '/tmp/RtmpoLaiAE/modules'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE/myProject/outputs'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/modules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/SpaDES/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/SpaDES/scratch/terra'
setPaths(outputPath = file.path(tempdir(), "outputs"))
#> Setting:
#>   options(
#>     spades.outputPath = '/tmp/RtmpoLaiAE/outputs'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE/outputs'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/modules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/SpaDES/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/SpaDES/scratch/terra'
setPaths(scratchPath = file.path(tempdir(), "scratch"))
#> Setting:
#>   options(
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/scratch'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/SpaDES/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE/outputs'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/modules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/SpaDES/scratch/terra'

# NOTE: on loading and attaching SpaDES.core,
# an active binding is made to "Paths"

getPaths()
#> $cachePath
#> [1] "/tmp/RtmpoLaiAE/cache"
#> 
#> $inputPath
#> [1] "/tmp/RtmpoLaiAE/inputs"
#> 
#> $modulePath
#> [1] "/tmp/RtmpoLaiAE/modules"
#> 
#> $outputPath
#> [1] "/tmp/RtmpoLaiAE/outputs"
#> 
#> $rasterPath
#> [1] "/tmp/RtmpoLaiAE/scratch/raster"
#> 
#> $scratchPath
#> [1] "/tmp/RtmpoLaiAE/scratch"
#> 
#> $terraPath
#> [1] "/tmp/RtmpoLaiAE/scratch/terra"
#> 
Paths ## same as getPaths() above
#> $cachePath
#> [1] "/tmp/RtmpoLaiAE/cache"
#> 
#> $inputPath
#> [1] "/tmp/RtmpoLaiAE/inputs"
#> 
#> $modulePath
#> [1] "/tmp/RtmpoLaiAE/modules"
#> 
#> $outputPath
#> [1] "/tmp/RtmpoLaiAE/outputs"
#> 
#> $rasterPath
#> [1] "/tmp/RtmpoLaiAE/scratch/raster"
#> 
#> $scratchPath
#> [1] "/tmp/RtmpoLaiAE/scratch"
#> 
#> $terraPath
#> [1] "/tmp/RtmpoLaiAE/scratch/terra"
#> 
setPaths(outputPath = tempdir())
#> Setting:
#>   options(
#>     spades.outputPath = '/tmp/RtmpoLaiAE'
#>   )
#> Paths set to:
#>   options(
#>     rasterTmpDir = '/tmp/RtmpoLaiAE/scratch/raster'
#>     reproducible.cachePath = '/tmp/RtmpoLaiAE/cache'
#>     spades.inputPath = '/tmp/RtmpoLaiAE/inputs'
#>     spades.outputPath = '/tmp/RtmpoLaiAE'
#>     spades.modulePath = '/tmp/RtmpoLaiAE/modules'
#>     spades.scratchPath = '/tmp/RtmpoLaiAE/scratch'
#>   )
#>   terra::terraOptions(tempdir = '/tmp/RtmpoLaiAE/scratch/terra'
Paths # shows change
#> $cachePath
#> [1] "/tmp/RtmpoLaiAE/cache"
#> 
#> $inputPath
#> [1] "/tmp/RtmpoLaiAE/inputs"
#> 
#> $modulePath
#> [1] "/tmp/RtmpoLaiAE/modules"
#> 
#> $outputPath
#> [1] "/tmp/RtmpoLaiAE"
#> 
#> $rasterPath
#> [1] "/tmp/RtmpoLaiAE/scratch/raster"
#> 
#> $scratchPath
#> [1] "/tmp/RtmpoLaiAE/scratch"
#> 
#> $terraPath
#> [1] "/tmp/RtmpoLaiAE/scratch/terra"
#> 
# }