- minor changes for CRAN submission
- use
qs2package instead ofqs(being removed from CRAN) for improved object serialization (#291; #316); This may causeqsbased event caching to fail and will have to be re-run/re-cached;
- fix a memory leak associated with
simList'smodobject: Themodobject was previously placed insim@.xData[[moduleName]]$.objects; even though it hadparent.envthat wasemptyenv(), because it was attached to the environmentsim@.xData[[moduleName]], this meant that the objects inmodwould become part of the environment where the functions were defined. This created a memory leak, resulting in inflated caches when events for that module were cached. It is now insim@.xData$.modObjs, which appears to no longer suffer from the memory leak. This change in location required many changes throughout all exportedreproduciblefunctions that hadsimListmethods, e.g.,.robustDigest, etc. - several corrections to messaging when there are nested
simListobjects, i.e., whensimInitis called within a module; - fix warning capture in
spades()debug logging; - fix use of
debugasverbosewhen caching (#322); - several small bugfixes, including in
.robustDigest.simList,Plots,allowInitDuringSimInit,.prepareOutput,defineParameter; - fix for
moduleVersionwhen there are many paths - small changes to caching of simList during event caching; missing ability to pass explicit classOptions for params
- This is primarily a large update to address changes in
reproducible::Cacheand its many exported methods; cacheChaining: a new experimental feature that will reduce time spent on digesting objects when there is an unbroken sequence of cached events. Event level caching will assess whether the most recent event was Cached. If it was, then the current cache will skip digesting and use only the functions (and parameters) and the previous event'scacheIdto assess whether thesimcan recover the current event from the cache repository. Turned on viaoptions(spades.cacheChaining = TRUE)- many changes to accommodate updates to
reproduciblepackage, specifically theCachefunction; clearCacheEventsOnlyis a convenience wrapper that will remove all event-level cached objects in the cache repository;- two internal helpers,
dotObjsanddotModwhich create a canonical pointer in thesimListto these two parts of module-specific objects or functions, respectively; - messaging updates when Caching events and
.inputObjects; Plotscan now have aquote(data)argument, allowing the whole call to beCached more easily;- new function
doCallSafethat can be used fordoCallSafe(simInitAndSpades, out), and it does not suffer from the slow downs ofdo.call; .depsEdgeListgains a new argument,outputObjects, which will return "hanging" outputs as_OUTPUTS_, analogous to the hanging inputs as_INPUTS_. This is needed to address a new case ofsuppliedElsewherewhere the object is contained within anobjectSynonym, and has not yet been made, but is only listed as anoutputObjectin a module;evalPostEventandoptions(spades.evalPostEvent), where a user can passquoted code that will be evaluated at the end of each event and.inputObjectcall;- documentation improvements;
- changes to a sporadically failing test;
- drop support for R 4.2;
- fix edge case with caching of events;
outputswould create false positives (i.e., a change, when there wasn't one); this meant that caching would only be successful after the 2nd time running the event, if another module had put objects in theoutputslist, especially by usingPlots. - fix issue with
Plots()where plots were discarded if no filename was specified; - fixed timeunit test failures (#297);
- add package anchors to Rd links (#300);
- minor documentation improvements;
- new option:
spades.reqdPkgsDontLoad, a character vector. If anything is specified, then it will not be loaded withrequireorlibrary, but it will be installed, if needed, and ifspades.useRequire = TRUE, which is the default. Default for this new option is "box", which is one of potentially many in the R universe that throws an error if it is loaded.
- fix issue with Windows short paths in tests;
- improved documentation;
- removal of
globals(sim)in Sample modules
- fixed bug in
restartSpades();
newModule, neweventsargument bugs that caused unwanted objects to be put in the module. Fixed..wrap.simListdid not anticipate objects with pointers in the metadata, so recovery from Cache failed if there was, e.g., aSpatExtentobject in the metadata. Fixed.- improved loading of
simListobjects, when loading e.g., lists of lists;
- "sequential caching" can now be turned on with
options("spades.allowSequentialCaching" = TRUE). When a series of events of events in sequence are cached, setting this option will treat them as a single Cache, so it may be much faster. Experimental and should be used with caution. - fix issue with event queue
colnamesincompleted<-andall.equal.simList(#272); - fixed issue saving
simListobjects when multiple paths were used (e.g.,length(modulePath) > 1); - events can be defined directly in calls to
newModule(); - checkpoints are assumed to be used locally, and no longer invoke simulation file archiving and re-extraction of files (i.e., uses
saveSimList(..., inputs = FALSE, outputs = FALSE, cache = FALSE, files = FALSE)); - improved recovery of interrupted simulations via
savedSimEnv()$.sim--savedSimEnv()is now exported for easier discovery -- an internal package environment is used, unless the user specifiesoptions(reproducible.memoisePersist = TRUE), which will use the global environment to store the.simobject; - switch from
crayon(superseded) toclifor message colours;
- require
reproduciblev2.1.0 or higher;
- due to upstream changes in
reproducible,loadSimList()is incompatible withsimListobjects saved with earlier versions ofSpaDES.core.
- fix a failing test on R-devel and latest R-release (#275)
- drop support for R 4.1 due to changes in dependency packages;
- improve
saveSimListdocumentation (#260); newModulenow correctly defaults to current working directory (#273);
- new accessor function
figurePath()to get the directory of a module's output figures, which is now uses a separate subdirectory per module (i.e.,file.path(outputPath(sim), "figures", <moduleName>));Plots()defaults to using this path, and module developers are encouraged to update their module code to usefigurePath(sim)wherePlots()is not being used. - re-Caching of a
simListno longer triggers on changes to.useCacheparameter, when it doesn't pertain to the event or module in question. - many historical modules used
bind_rowsfromdplyrwithinexpectsInputorcreatesOutput. Now, if a module usesbind_rowsand doesn't havedplyrinstalled,SpaDES.corewill intercept and useSpaDES.core::bindrows. saveSimList()better handles relative paths and symbolic links (#263)saveSimList()does an improved job at handling file-backed objects (previously, tests were passing because object was still there; now object is deleted,simListreloaded, and file-backed objects put back into place)- deal with upstream
reproduciblechanges to.wrap - deal with upstream
reproduciblechanges toCachemessaging, specifically, remove cases wherefunctionwas auserTagfor an outer function call. Now these will display asotherFunction, so that individual functions can be more easily isolated. - overhaul of messaging during
simInitandspadesthat allows for nested calls tosimInitand/orspades - elapsed time during
simInitis now reported elapsedTimenow displays the largest time unit, which may not besecs- some parts of any warning messages are now muffled for clarity: e.g.,
In modCall...is removed. optionsthat are eitherRequireOptions(),spadesOptions()orreproducibleOptions()can now be set during thesimInitby passing them as arguments, e.g.,simInit(useMemoise = FALSE). See?simInit, specifically the...parameter description. This is not passed as an argument namedoptions: these are just options. For convenience, user can omit the package prefix, e.g.,useMemoiseforreproducible.useMemoise- all necessary updates to deal with
reproducibleupdates to exported methods - new function:
dminto go with the otherd*SpaDES times. - updates to unit tests to accommodate all these changes.
dplyris removed (again)
coltab<-fromterrachanged how it deals with multi-layerSpatRasters. Two sample modules have been modified to set colours on these multi-layerSpatRasters- loading of
ascraster-type files usinginputsdid not work; fixed. - fixed bug in
simInitparameter checking - A number of new edge cases dealt with for reducing false positive and false negative
Cacheing of events and modules. Now, for example, a change to the parameter.useCache = c("init")to.useCache = c("init", ".inputObjects")will not trigger a rerun of theinitevent. Also,.inputObjectsis no longer evaluated forCacheing ofdoEvent Error in if (is.na(sim@params[[m]][[x]]))fixed.ascspatial map files were incorrectly loaded byterrapackage: fixed.
- none
- none
- new helpers for getting copies of sample files (
getSampleModules()andgetMapPath()) now used throughout examples, vignettes, and tests to avoid writing files in package installation directories.
options(spades.futureEvents = TRUE)has been reworked and now works under a wider array of conditions.Copy,.wrap,wrapandunwrapall have fairly robust methods forsimListclass. The generics are inreproducibleorterra- updated
sampleModulesto usePlotsand.plotparameter. - new function:
registerOutputscan be used by a developer to add saved files to theoutputs(sim)data.frame. - messaging during nested
simInitorspadescalls will now not duplicate time prefix paramsand.globalswere previously not expected to change duringCached events. Thus returned cached values were always the same as input asparamsand.globals. They are now assessed and returned as part of theCache, as expected.- updates to handle upstream changes in
Requireandreproducible, including renamingcacheRepotocachePathin some inherited functions. - updates to sample modules to use
SpaDES.tools::neutralLandscapeMapinstead ofNLMRpackage directly - migration complete to use
terraandsfinstead ofraster,sp,rgeos, andrgdalas defaults. Attempts have been made to maintain backwards compatibility in all cases. moduleMetadatanow handles multiple module paths- updates to
memoryUse - new option: setting
options("spades.allowInitDuringSimInit" = TRUE), a user will haveinitevents of one ore more modules run during thesimInitcall, but only if they have no upstream dependencies, i.e., theirexpectsInputscannot be supplied by another module'screatesOutputs.simInitwill determine which modules have no upstream dependencies and only these will be selected for running only theirinitevents. This can be useful e.g., if there is a module thatcreatesOutputsfor astudyArea. .plotsarg inspadescan be set toNAto turn of all plotting. This can also be set withoption(spades.plots = NA),- minor bugfixes
moduleMetadatano longer runs.inputObjects. In addition to being unnecessary and slow, it was also failing withreproducible (==1.2.16)because it was trying to runCache, which had a bug for this case. Now,moduleMetadatano longer runs the.inputObjectsinternally, so this bug is no longer relevant.- two new options --
spades.loadReqdPkgs, so a user can turn off loading of packages, andspades.dotInputObjects, so a user can omit running of the.inputObjectsfunction in modules duringsimInit. These are updated inspadesOptions. - some tests and examples have been shortened, to fit within the CRAN guidelines
- improved documentation
- new hidden function
runScheduleEventsOnlywill extract only thescheduleEventscall; needed foroptions(spades.futureEvents = TRUE) - new option:
spades.saveFileExtensionswhich allows users to use theoutputs(sim)mechanism for saving, for file extensions that are not already supported by.saveFileExtensions() - many issues addressed and closed
- drop support for R 4.0 as dependency packages no longer support it;
- require
reproduciblev2.0.5 or higher; - require
quickPlotv1.0.2 or higher; - removed
googledrivefrom Suggests.
- several minor, e.g.,
Plotswhen not specifyingfn, butusePlot = FALSE - many examples that were protected behind
\dontrunor\donttestwere stale; these have been updated saveFilesbugfix: multiple objects names can now be passed to.saveOutputsmodule parameters.
- several previously-deprecated functions have been made defunct:
remoteFileSize(),updateList(). These will be removed by mid-2023.
- messaging in a module can now handle "same line" messages --> simply use the standard
"\b"in the message, and it will occur on same line as previous message Plotsnow appends the filename any file saved duringPlotsto theoutputsslot of thesim, i.e., it will show up inoutputs(sim)logPathis now a function that points to a sub-folder offile.path(outputPath(sim), "log")defineEventis a new function that allows a different way of specifying events than thedoEventfunction. This is not yet being used in the module templates, so does not appear withnewModule.spadescan now run correctly, with "incomplete" modules that don't have metadata or even a module file. Now, a "module" will work withsimInitandspadesif adoEvent.XXXexists somewhere e.g., in the.GlobalEnv.spadeswill find it through inheritance and no longer complain if specific structures are absent. This may make it easier to learn how to useSpaDESas it mimics a more normal user experience where functions are all in the.GlobalEnv.- new option
spades.DTthreadsto limit the number of threads used bydata.table(default 1). Users can override this default if needed; modules cansetDTthreads()as needed, but should restore the original valueon.exit. saveSimList()andloadSimList()accept.qsor.rdsfilesspadesandsimInitnow force UTF-8 encoding; this is reseton.exit. If a module needs a different character encoding, then it can be set within the module code..studyAreaNameparameter added to default module metadata when usingnewModule.- changes to template module documentation - removal of "module usage" as it is not relevant within a module, and minor restructuring
- new option
spades.scratchPath, to be used for e.g., temporary raster files and temporary SpaDES recovery mode objects. - The default temporary
rasterTmpDirhas changed to be a subdirectory ofscratchPath.rasterPathwill be deprecated in a future release. - New default temporary
terraTmpDirset as a subdirectory ofscratchPath. - Old way of naming module functions with full module name plus "Init" ('non namespaced') no longer works. Message now converted to
stop. - use
README.mdinstead ofREADME.txtin new modules.
- removed
RandomFieldsdependency, as that package is no longer maintained; - added
NLMRto Suggests to provide random landscape generation capabilities previously provided byRandomFields.
memoryUsewas not correctly handling timezones; if the system call to get time stamps was in a different timezone compared to the internal SpaDES event queue, then the memory stamps were not correctly associated with the correct events.- improved handling of
data.tableobjects usingloadSimList() - Fixed caching of
.inputObjectsto correctly capture objects that were assigned tomod$xxx. - Fixed caching of
simListobjects where changes to functions appeared to be undetected, and so a Cache call would return a stale module with function code from the CachedsimList, which was incorrect. - fix recovery mode bug: use scratch directory specified by the user via
options(spades.scratchPath)(see above). objSizecould have infinite recursion problem if there aresimListobjects insidesimListobjects. Fixed with newreproducible::objSize, which useslobstr::obj_size.- several minor fixes, including in
Plots - fixes to
saveFilesrelated todata.tableassignment and use inoutputs(sim) - fix to
paramCheckOtherModsto deal withcallparameters
- experimental new feature
SpaDESmodules can now be R packages. The simplest way to convert a module to a package is using the new functionconvertToPackage. Benefits of doing this are so that a SpaDES module can benefit from the infrastructure of an R package (e.g.,devtools::document,devtools::check, setting up Continuous Integration systems etc.). Any documentation written using#'i.e.,roxygen2will be copied immediately above the function where it was sitting. newModulenow correctly places theSpaDES.corepackage dependency in thereqdPkgselement of the metadata, instead of# SpaDES.core. It will put the full GitHub reference if SpaDES.core was installed directly from GitHub.- There is a bug in
qspackage: eitherqsaveorqreadconvertsdata.tableobjects tolistobjects.loadSimListhas a work around internally to convert these objects back todata.table, if the metadata indicate that the objects should bedata.tableobjects. - new function:
paramCheckOtherMods. Can be used within a module to assert that a parameter has the same value as the same parameter in other modules. This is therefore a check of a parameter that might be considered a.globaland passed withinsimInit(..., params = list(.globals = list(someParam = "someValue"))), but the user did not do that. - now
spadesmessaging when e.g.,debug = 1can correctly accommodate nestedspadescalls, i.e., a SpaDES module callingspadesinternally. newModulenow putsSpaDES.coredependency in the correctreqdPkgsinstead of# SpaDES.coremetadata element- to further the transition to using
.plotsinstead of.plotInitialTime,Plotswill check whether.plotInitialTimeis actually set in the module metadata first. Only if it is there, will it evaluate its value. Currently, modules get default values for.plotInitialTimeeven if the module developer did not include it in the module metadata.
- drop support for R 3.6 (#178)
- minor bugfix when
debugarg ofspadesis set to an event type that is also in the core modules (e.g., save, load), such as "init" Cache-ing of asimList, whenquickis a character vector, errored. Now fixed.moduleMetadataincorrectly droppeddefineModuleListItemsunder certain signatures.
moduleCoveragehas been rewritten to estimate code coverage of a module usingcovrpackage.Pnow has a replacement method. So, to update a parameter within a module (where it is namespaced, i.e., don't have to specify the module name):P(sim, "paramName") <- 1. If using this outside a module, thenmodule(3rd argument) will have to be specified.Pargument order changed to accommodate the fact that namespacing is used to detect module name: the user does not need to supplymodule, so it should not be second. This is for the normalPmethod and the new replace method above: it is nowP(sim, param, module); there are attempts to capture errors (i.e., parameter supplied that matches a module, but not a parameter; vice versa) and give a warning for user to change code. This may have little downstream effect as all known cases use theP(sim)$paramName, which will still work fine, instead ofP(sim, "paramName").Plotsdoes a better job withRasterStackobjects plotted to screen withoutggplot2- removed
.isFALSE: usebase::isFALSEnow Plotscan now omit thedataargument; just use the named arguments in ...defineParameternow allows multi-linedescor multiple strings;pasteis no longer needed for longdescmoduleCodeFilesa new function that identifies all the code files in a collection of modules.globalsfunctionality is modified. If a user specifies a.globalsin the parameters object (passed intosimInit), then all identical parameters in all modules will be overridden with these.globalvaluesdefineParameter,expectsInputandcreatesOuptutcan all now have multi-linedesc, without needing to usepasteorpaste0. Extraneous spaces and carriage returns will all be stripped. This can either be using a single multi-line quote or via multiple lines, each with its own"".- the module environment in the
simListis no longer "locked" withlockBinding. It is already hidden insim$.mods, and sincesim$.modscan be modified, this was a weak caution against user modification. Further, formoduleCoverage, the module environment needed to be unlocked, which is not allowed by CRAN.
- no changes
- When
.inputObjectswas cached (via settinguseCache = '.inputObjects'parameter), it was "too sensitive". Changes to any module's parameters, not just the current module, would cause rerun of.inputObjects. Now it correctly identifies parameter changes only in the current module. THIS WILL CAUSE some existing caches to trigger a rerun once; after this, it will be less sensitive restartSpadesdid not correctly deal with objects that did not yet exist prior to the event. Fixed with: 24b9cd12973aa81a9a4923a02225e095fa28f77a.restartSpadeswas losing the previous completed events list. This has been fixed; it is now kept afterrestartSpades- Plots - fixed issues with plot layer names and plot overlaying when passing
dataonly (e.g.quickPlot::Plot-like behaviour) simInitAndSpadesnow has.plotsarg to matchspades- fix raster file name query for GDAL 3.3.2 (#174; @rsbivand)
Plotsfunction can be used likePlot, but withtypesspecified. The devices to save on disk will have some different behaviours to the screen representation, since "wiping" an individual plot on a device doesn't exist for a file device.
Plotsfunction that will produce zero to 4 types of items that are relevant for plotting: 1) Visual on screen, 2) The plot object saved to disk, 3) The raw data that went into the plot and 4) The plot as one or more image files, e.g.,.pngor.pdfviaggsavespadesnow accepts aneventsargument, which will limit the events that are run to those specified in the argument. This seems to be most useful for theinitcase, e.g.,spades(sim, events = "init"). See?spades.- messaging during
simInitnow is prefixed withSys.time()and"simInit" - messaging during
spadesis simplified to take up fewer characters:INFO::has been removed simInitnow checks for minimum # SpaDES.core ofSpaDES.coreneeded in a module and stops if it fails, giving instructions how to upgrade.- several human-readable only elements of a module metadata are no longer enforced, including
spatialExtent, as they are not used by the spades algorithms - new function:
anyPlottingto test whether plotting of one form or another should occur - line-by-line messaging during
spadescall is now more informative, including module name (by default shortened -- can be changed withoptions("spades.messagingNumCharsModule"))) defineParametercan now accept a vector of "class", so a parameter can be more than one class. Presumably this should generally not be used, but a good reason could be, say,c("numeric", "function"), where the use can pass either a numeric or a function that would calculate that numeric.- new helper function
simFileto generate file names for use with e.g.,saveSimList zipSimListis now exportedspadeswill now attempt to loadreqdPkgs, which is already done insimInit. In cases wheresimInitwas not run, e.g.,Cache(simInitAndSpades, ..., events = "init"), then modules will not have access to packages. For cases wheresimInitwas called, then this should add very little overhead.saveSimListwill now convert file-backedRaster*class objects to memory iffileBackend = 0. Previously, it left them as is (on disk if on disk, in memory if in memory).- For code/documentation contributors, markdown syntax is now turned on and can be used when writing function documentation
- The first event will now run if it is scheduled to be prior to
time(sim)in the case where it is equal to or afterend(sim). Previously, this would not run any events iftime(sim)>=end(sim)&&events(sim)[[1]] < time(sim). - minor documentation modifications
- Add optional
.seedparameter for modules (#163)
defineParameterwas throwingis.na(default)warning when a parameter was not an atomic.- recovery mode did not work correctly if the file-backed rasters were in the temporary directory, as it would collide with the temporary directory of the recovery mode mechanism. Now recovery mode uses a dedicated temporary directory
- other minor bugfixes,
- more informative message re: module package # SpaDES.cores when
spades.useRequire = FALSE(#141) - now detects user-created memory leaks when a user adds a closure or formula to the
sim; user informed with awarning
- no changes
- use
try()withcommunities()to skip tests on systems withoutigraphGLPK support. - prevent package (re)installation during examples, tests, vignettes.
- fix failures on R-devel caused by
RandomFieldsbeing unavailable. - minor bug fixes
- New experimental
spades.futureEventsoption. If set toTRUE, spades will run module events in a "future" (seefuturepackage), if they do not produce outputs for other modules. - enable automated module code checking with GitHub Actions (
use_gha()and corresponding vignette; #74) newProjectcreates Rstudio.Rprojfile if invoked in Rstudio- moved
paddedFloatToCharto reproducible; but re-exported here, so still usable. - modules can now use a parameter called
.seedwhich is a named list where names are the events and the elements are the seed with which to run the event. DuringdoEvent,SpaDES.corewill nowset.seed(P(sim)$.seed[[currentEvent]])and reset to random number stream afterwards.
- completely removed
dplyr,lubridate,R.utils,tools,backportsandrlangfrom dependencies - move
tcltktoSuggests - remove
devtools,microbenchmarkfromSuggests
- minor bug fixes
- use new
all.equal(..., check.environment = FALSE)for internal testing
- none
- completely removed
RCurldependency (#120) - Suggests
spbecause it's linked in documentation (#120)
- fix
pkgDepsexample for new # SpaDES.core ofRequire - minor bug fixes
descargument indefineParameter,expectsInput, andcreatesOutputcan now have extraneous spaces and End-of-Line characters. This means that they can now be written more easily with a single set of quotes, without needingpaste. The accessor functions,moduleParams,moduleInputs, andmoduleOutputsall will strip extraneous spaces and End-of-Line characters.- new helper functions for debugging:
writeEventInfo()andwriteRNGInfo()to write info to file.
- drop support for R < 3.6
- removed imports from
stringi
- minor bug fixes in sample modules
- module template has full path instead of
..formoduleParamsetc. This is more accurate. - address changes to active bindings in R-devel
- fix CRAN check errors
- reduced the number of tests run on CRAN (extended tests still run on GitHub Actions)
Paris now anactiveBinding(similar tomod) pointing toP(sim); this allows for tab autocomplete to function correctly.- new helper functions to extract parameters, inputs, and outputs tables from module metadata:
moduleParams(),moduleInputs(),moduleOutputs(). These are now used in default.Rmdtemplate. - better testing of
memoryUsefunctionality - A pointer to
simis now created at.pkgEnv$.simat the start ofspadescall, rather thanon.exit; failures due to "out of memory" were not completing theon.exit - improved templating of new modules, including support for automated module code checking using GitHub Actions (
newModule()setsuseGitHub = TRUEby default).
- add
usethisto Suggests for use with GitHub Actions
- none
- tests for
Filenamesfunction coming fromreproduciblepackage options('spades.recoverMode')was creating temp folders every event and not removing them; now it does.
- several efforts made to reduce memory leaks over long simulations; if memory leaks are a problem, setting
options('spades.recoveryMode' = 0)may further help - Updates to deal with new backend with
reproducible - better assertions inside list elements of
simInit, e.g.,simInit(times = list(start = "test"))now fails because times must be a list of 2numericobjects - messaging is now all with
messageinstead of a mixture ofmessage,catandprint. This allows for easier suppressing of messaging, e.g., viasuppressMessages. This was requested in a downstream package,SpaDES.experimentthat was submitted to CRAN but rejected due to the now former inability to suppress messages. restartRsaves simulation objects usingqs::qsave()which is faster and creates smaller file sizes.
- moved packages from Imports to Suggests:
codetools,future,httr,logging, andtcltk - removed
archivist qsnow used for improved object serialization to disk
.objSizeInclEnviros and removed
- removed mention of 'demo' from intro vignette (#110)
objectSynonymscaused a breakage under some conditions related to recovering a module fromCache.
- Changed all internal
printandcatstatements to message to allow use ofsuppressMessages, as recommended by CRAN - added file based logging via
loggingpackage, invoked by settingdebugargument inspadesfunction call to alist(...).?spadesdescribes details
restartRminor bug fixes
- Removed dependency packages
DEoptim,future.apply,Matrix,parallel,pryr,purrr, andrgenoud, which are no longer required. See "deprecated" info below. - added
whiskerto Imports to facilitate module file templating (#100)
- memory and peak memory estimation is now available for *nix-type systems, when
futureis installed. See new vignetteiv-advancedand?memoryUse. - new function and capacity:
restartR. Restarts R mid-stream to deal with apparent memory leaks in R. In our experience with large projects that have long time horizons, there appears to be a memory leak at a low level in R (identified here: https://github.com/r-lib/fastmap). This has prevented projects from running to completion. Without diagnosing the root cause of the memory inflation, we have noticed that interrupting a simulation, saving thesimList, restarting R, resets the memory consumption back to levels near the start of a simulation. The new functionality allows a user who is hitting this memory leak issue to restart R as a work around. See?restartRfor instructions. - new function
newProjectto initialize a SpaDES project with subdirectoriescache/,inputs/,modules/, andoutputs/, andsetPaths()accordingly.
newModule()now usesopen = interactive()as default to prevent files being left open during tests.- various bug fixes and improvements.
experiment(),experiment2(), andPOM()have been moved to theSpaDES.experimentpackage
- R 3.5.0 is the minimum # SpaDES.core required for
SpaDES.core. Too many dependency packages are not maintaining their backwards compatibility. - added
backportsto Imports for R-oldrel support - removed
googledrivedependency (this functionality moved toreproducible)
- improved documentation for
P,params, andparameters, thanks to Louis-Etienne Robert.
- update
objSize.simListmethod with 2 new arguments fromreproduciblepackage .robustDigestmethod forsimListclass objects now does only includes parameters that are listed within the module metadata, ifCacheor.robustDigestis called within a module. This means that changes to parameter values in "other" modules will not affect the Caching of "the current" module.- New function
outputObjectNameswill extract just the object names of alloutputObjectsacross modules - New function
restartSpadesand its associatedoptions(spades.recoveryMode = 1), the new default, which is still experimental. Its purpose is to be able to restart a simulation in the case of an error or interruption. - Now gives better errors if modules are missing main .R file or if they are missing entirely
- More silent tests
modis now an active binding tosim[[currentModule(sim)]]$.objects(move fromsim[[currentModule(sim)]]) and its parent environment isemptyenv(). This should cause no changes to users who usemod$..., but it will cause a change if user was calling objects directly viasim[[currentModule(sim)]]$.... This change is to separate the function enclosing environments and object enclosing environments, which should be different.sim@completedis now an environment instead of a list. Of the three event queues, this one can become the largest. Thelistwould get increasingly slow as the number of completed events increased. There should be no user visible changes when usingcompleted(sim)
spades.debug is now set to 1
spades.recoveryMode is new and set to 1 (i.e., the current event will be kept at its initial state)
- Internal bugs during
simInitespecially in some weird cases ofchildModules. - packages listed in
reqdPkgsnot being loaded when only listed in child modules. Fixed in5cd79ac95bc8d190e954313f125928458b0108d2. - fixed issue with saving simulation outputs at simulation end time.
- improved messaging and fixed test failures when GLPK installed but not used by
igraph - compatibility with
RandomFields>= 3.3.4
archivistanddevtoolsadded to Suggests because they are used in vignettes- minimum
reproducible
-
new vignette on caching
SpaDESsimulations moved fromSpaDESpackage. -
simListenvironment now hasemptyenv()as itsparent.env. The biggest user-facing changes are:- functions placed in the
envir(sim)(unusual, but may occur) won't find objects in the.GlobalEnv; - lighter memory footprint, as functions take RAM due to the objects in the
parent.envin which they are defined (little know fact identified here: http://adv-r.had.co.nz/memory.html#gc identified as a possible source of memory leaks).
- functions placed in the
-
module's function environment in the
simListnow has its parentasNamespace("SpaDES.core")instead of theenvir(sim)(as mentioned above), i.e,.parent.env(sim[[currentModule(sim)]])isasNamespace("SpaDES.core"). The main user-noticeable changes of this are that module functions will not accidentally find objects in thesimListunless they are actually passed in explicitly as arguments. -
New active binding,
modthat works as a module-specific variable, similar to a private object, i.e.,mod$ais a local object inside the module that persists across events. It is a pointer tosim[[currentModule(sim)]]$a -
New function
scheduleConditionalEvent, which allows an event to be scheduled based on a condition. Still experimental. -
An experimental new function and feature,
objectSynonyms, which will create active bindings of two names to a single object -
User can now specify
modulePathas a character vector, e.g.,simInit(..., paths = list(modulePath = c(".", "test"))). This means that a user can organize the modules in different locations. -
modulePathnow has a new argument,module, where user can specify (a) specific module(s)'s path. Modifications were implemented todataPathto utilize this new feature -
simInitandspadesnow callsetPaths(paths)orsetPaths(sim$paths), unsetting themon.exitinternally to make the paths used for functions e.g.,reproducible::Cacheto use the correct path -
under-the-hood speed improvements for the DES (about 20% faster) -- 38 microseconds per event under ideal conditions
-
improved default path settings in
.inputObjects(#83) -
following
reproduciblepackage updates, now usesdata.table::setattrinternally to avoid copying of objects (this may have very little/no effect onsimListobjects) -
suppliedElsewherehas a new argument,returnWhere, a logical which will cause a logical of length 3 to be returned, indicating in which of the 3 other places the object may have been supplied, instead of length 1, still the default.
- fix to work with latest
data.tablev1.12.0 (#85, @mattdowle) - several minor, including to
Copy(error existed because function inheritance persisted even though the location of the function was moved)
- add
RandomFieldsto Suggests, as it is in the Suggests ofSpaDES.toolsand used in examples/tests.
- new option and default setting:
options("spades.saveSimOnExit" = TRUE). This will save the state of thesimListto an object asSpaDES.core:::.pkgEnv$.sim, with a message, if there is a hard exist. There is virtually no computational cost to this, as the object is already in RAM. simListinternals changed. It now inherits fromenvironment. Amongst other things, this means that tab autocomplete in RStudio now works for objects in thesimList. Also, we removed several associated methods,$,[[,ls,ls.str,objects, as the defaults for environments work correctly with thesimListnowdebugarg inspadescall can now take numeric, currently 1 or 2, giving a few pre-packaged informative messaging each event- new function
elapsedTimewhich gives a summary of the clock time used by each module or event - most metadata entries now have accessor of same name, e.g.,
inputObjects(sim)returns theinputObjectsdata.frame. - new function
citationreplacesutils::citationwith an S4 generic. Ifpackagearg is acharacter, it dispatchesutils::citation; if asimList, it gives the citation for the module(s) - improved messaging when GLPK not installed (e.g., on macOS)
downloadModule()now prints the module # SpaDES.core downloaded (#77)
- resolved
.inputObjects()name conflict (internal.inputObjectsrenamed to._inputObjectsDF;.outputObjectsrenamed to._outputObjectsDF) - module
.inputObjectsevaluated based on module load order (#72) .robustDigestfix forsimListobjects -- needed to omit._startClockTimeand.timestamp
- remove
spfrom imports
- none
- fix issues with failing tests on macOS
- requires new # SpaDES.core of
reproducible(>=0.2.2)
-
new option
spades.useRequire: a logical which causessimInitto load packages withRequireorrequire. Lower case is generally faster, but will not handle the case of uninstalled packages, so should only be used once all packages are installed. -
-
- new option
spades.keepCompleted: a logical which causesspades()to keep (TRUE) or not keep a record of completed events. Keeping track of completed events when they are many (>1e5) gets slow enough that it may be worth turning it off.
- new option
-
-
more robust and faster tests are used now, care of helper functions in
tests -
all.equal.simListnow removes all time dependent attributes, e.g.,._startClockTimeand.timestamp -
speed enhancements for Discrete Event Simulator; now overhead is 1.3 seconds for 5000 events or, per event, 260 microseconds (185 microseconds if
options("spades.keepCompleted" = FALSE)
-
Improvements to caching of functions with
simListobjects:- Cached functions with a
simListin the arguments would erroneously return cached copies of functions. These now are copied through from argumentsimList, rather than cachedsimList. This means that changes to the function definitions in a module will persist (e.g., debugging viabrowser()will work correctly) - functions with
simListin arguments that return asimListwill now do a post digest of the output. This will be compared with the predigest, and only those object which changed in thesimListwill be modified. - caching of
.inputObjectsfunction was incorrect. Fixed.
- Cached functions with a
-
module metadata now in named lists inside
depends(sim) -
new debugging -- if debug is not
FALSE, then any error will trigger abrowser()call inside the event function. User can continue (c) or quit (Q) as per normal.cwill trigger a reparse and events will continue as scheduled. -
introduction of code checking for modules, currently turned on or off by an option
spades.moduleCodeChecks, which isTRUEby default. Code checking includes various types:- use
codetoolsto check for various code problems - detects conflicts with known common functions (
raster::level,raster::scale,quickPlot::Plot) - use
checkCodeEnvon every function inside a module - checking for
sim$xxxoccurrences in modules, comparing tooutputObjectsin metadata if used in assignment (i.e., left hand side of assign operator), or comparing toinputObjectsif used on the right hand side - check that all objects declared in
inputObjectshave default values assigned in the.inputObjectsfunction - messages colour coded, and separated by file with absolute path explicit
- use
-
option
spades.debugset toTRUEby default, instead ofFALSE. This is better for new users. -
moduleMetadataargument order changed, sosimis first, more consistent with all othersimListaccessors. -
downloadDatahas changed dramatically, now it is a wrapper aroundreproducible::prepInputswhich does more checking. -
extractURLwill extract thesourceURLfrom metadata, given an object name. -
makeMemoiseableandunmakeMemoisable, new methods, each the inverse of the other, to deal with imperfect memoised returns under some cases ofsimList. -
new option,
spades.keepCompleted,TRUEby default, which can be useful for dramatically speeding up the DES when there are many (>10,000) events.
- remove
fileExt-- usetools::file_extinstead
- fix tests based on
data.tablechanges (@mattdowle, #64). - re-export
startandend. newModuletemplate modified slightly based on workshop feedback.setPathsnow only sets the directories that are passed into it.all.equal.simListmethod strips a small number of attributes that are used internally that create false failures.- speed enhancements.
- other minor bug fixes.
- add package imports
tools,pryr. - removed package imports
rgeos,RCurlandgoogledrive.
-
uses
reproducible::Requireinstead ofSpaDES.core::loadPackagesto load required packages. Currently, does not use SpaDES.core control for packages, but does use installing (from CRAN or GitHub), and loading (via require). This means a module can indicate a GitHub package, e.g,.achubaty/amc@development -
environments in modules are now as follows:
- Functions defined in a module are sourced into an environment located here:
sim@.envir$<moduleName>, and it is a is a child ofsim@.envir. Functions can be found in this environment, but prefixing functions is not necessary, because modules functions are within this environment already. sim@.enviris a child ofSpaDES.core
- Functions defined in a module are sourced into an environment located here:
-
scoping from within a function that is defined in a module is thus:
sim@.envir$<moduleName>-->sim@.envir-->SpaDES.core--> all imported packages includingbase-->.GlobalEnv-->search()
-
speed improvements:
- the core DES is now built around lists, rather than
data.tableobjects. For small objects (e.g., the event queue) that have fewer than 200 objects, lists are faster. Accessors (e.g.,events(sim),completed(sim)) of the event queues still showdata.tableobjects, but these are made on the fly. .parseModuleand.parseModuePartialnow put their parsed content into a temporary environment (sim@.envir$.parsedFiles$<Full Filename>)during thesimInit, which gets re-used. Previously, files were parsed multiple times in a givensimInitcall. Several functions now haveenvirargument to pass this through (includingmodule# SpaDES.core,packages,checkParams)
- the core DES is now built around lists, rather than
-
parsing of modules is now more intelligent, allowing for modules to contain functions (the current norm) and but they can also create objects at the module level. These can use the
simobject in their definition. These objects can, for example, be used to help define parameters, for example, e.g.,startSimPlus1 <- start(sim) + 1can be defined in the module and used indefineModule -
remove
grDevicesfrom Imports as it was not used (#1) -
remove
chronandCircStatsdependencies -
remove functions
dwrpnorm2and move to packageSpaDES.tools -
remove unused function
F()due to conflicts withF/FALSE. -
improved download of module data: added new
quickCheckargument -
improved download of modules: use fuzzy matching
-
new option:
spades.switchPkgNamespaceswhich allows the user to turn off theSpaDESfeature that loads and unloads libraries specific to each module. While useful, it slows down computations, in some cases, by a lot. -
bug fixes:
- in
zipModulethat omitted the checksum file from being included whendata = FALSE(#3) - caching of
.inputObjectsfunctions was evaluatingoutputObjectsinstead ofinputObjects. Now corrected.
- in
-
If
.inputObjectscontains arguments other than justsim, these will be evaluated as function inputs by the Cache mechanism (via.useCache), therefore correctly assessing when those inputs changed, e.g., if they are files and the arg is wrapped inasPath, then any change to the underlying file will cause a re-cache. e.g.,.inputObjects <- function(sim, importantFile = asPath(file.path(inputPath(sim), "theFile.rdata"))) { ... } -
default
debugoption inspades()now uses the package optionspades.debugand default is set toFALSE(#5) -
various other speed improvements and bug fixes
-
convert
Pto a function, rather than S4 generic and method, for speed. -
@importFromonly used functions fromutilsdue to name conflicts withraster::stackandutils::stack -
new function
remoteFileSizeto check the size of remote files -
new namespaced function
dataPathwill returnfile.path(modulePath(sim), currentModule(sim), "data"), which will return a different path, depending on which module it is placed inside. -
add
crayonto Imports -- now messages are more colour-coded; -
bug fix in 'inputs' for the case of loading objects from the global environment, either from the same object to the same object, or from different global objects overwriting on the same
simListobject;
-
A new package, which takes all core DES functionality out of the
SpaDESpackage:- see
?SpaDES.corefor an overview
- see
-
various speed improvements and bug fixes