Stash and unstash all modules and internal state. List and remove stashes.

stash(comment = NA_character_)

unstash(id = length(.modulr_env$injector$stash))

list_stashes()

remove_stash(id, all)

Arguments

comment

A string (character vector of length one).

id

A scalar (integer vector of length one).

all

A flag. Should all stashes be removed?

Value

A scalar (integer vector of length one) containing the stash ID.

Details

stash allows to stash all modules and the internal state of modulr. Each stash is pushed on a stack and can be commented for later reference. unstash pops a stash from the stack and restores the state accordingly. list_stashes lists the stack, showing ids, timestamps and comments for each stash. remove_stash removes one or all stashes from the stack.

Warning

It is considered a very bad practice to define, touch, undefine, load, make, reset, or perform any other operation from within a module definition that may alterate the internal state of modulr.

See also

define, list_modules, and reset.

Examples

reset() remove_stash(all = TRUE)
#> [2017-06-21T21:58:31 UTC] Removing all stashes ... OK
define("foo", NULL, function() NULL)
#> [2017-06-21T21:58:31 UTC] Defining 'foo' ... OK
stash("'foo' only")
#> [2017-06-21T21:58:31 UTC] Stashing modulr state, stash #1 ... OK
list_stashes()
#> id timestamp comment #> 1 1 2017-06-21T21:58:31 UTC 'foo' only
define("bar", NULL, function() NULL)
#> [2017-06-21T21:58:31 UTC] Defining 'bar' ... OK
stash("'foo' and 'bar'")
#> [2017-06-21T21:58:31 UTC] Stashing modulr state, stash #2 ... OK
list_stashes()
#> id timestamp comment #> 1 1 2017-06-21T21:58:31 UTC 'foo' only #> 2 2 2017-06-21T21:58:31 UTC 'foo' and 'bar'
#> name version storage along type weight calls dependencies uses size #> 1 bar <NA> in-memory <NA> <NA> <NA> 0 0 0 888 bytes #> 2 foo <NA> in-memory <NA> <NA> <NA> 0 0 0 888 bytes #> lines modified #> 1 2 2017-06-21T21:58:31 UTC #> 2 2 2017-06-21T21:58:31 UTC
unstash(1L)
#> [2017-06-21T21:58:31 UTC] Unstashing modulr state, stash #1 ... OK
#> name version storage along type weight calls dependencies uses size #> 1 foo <NA> in-memory <NA> <NA> <NA> 0 0 0 888 bytes #> lines modified #> 1 2 2017-06-21T21:58:31 UTC