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/Rtmp45trFG/myProject/cache"
#> 
#> $inputPath
#> [1] "/tmp/Rtmp45trFG/myProject/inputs"
#> 
#> $modulePath
#> [1] "/tmp/Rtmp45trFG/myProject/modules"
#> 
#> $outputPath
#> [1] "/tmp/Rtmp45trFG/myProject/outputs"
#> 
#> $rasterPath
#> [1] "/tmp/Rtmp45trFG/SpaDES/scratch/raster"
#> 
#> $scratchPath
#> [1] "/tmp/Rtmp45trFG/SpaDES/scratch"
#> 
#> $terraPath
#> [1] "/tmp/Rtmp45trFG/SpaDES/scratch/terra"
#> 

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

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

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