Save a context

context_save(
  path,
  packages = NULL,
  sources = NULL,
  package_sources = NULL,
  envir = NULL,
  storage_type = NULL,
  storage_args = NULL,
  name = NULL,
  root_id = NULL
)

Arguments

path

Path to save the context in

packages

Optional character vector of packages to save into the context. Alternatively, can be a list with elements loaded and attached if you want to ensure some packages are loaded but not attached.

sources

Character vector of source files to read in. These should define functions and (perhaps) other "global" objects, but should not do any serious computation.

package_sources

Optional information about where to find non-CRAN packages, created by conan::conan_sources

envir

The current environment. This is used to copy local variables around. For context_load this is the environment into which the global environment is copied. Specify a non-global environment here to avoid clobbering the workspace, but at the risk that some environments may not restore exactly as desired. If this is used, then every new R session, running context_save will create a new context id.

storage_type

Character vector indicating the storage type to use. Options are "rds" (the default) and "environment" (for testing and local use).

storage_args

Arguments passed through to the storage driver

name

An optional name for the context. This will be printed with the context in some situations (such as context_info)

root_id

Force a context root id. This is intended for advanced use only. By setting the root id, two contexts created with storage in different file locations (path) will get the same id. This is required for using a server-hosted database to share a context between different physical machines (or different docker containers). The id, if provided, must be compatible with ids::random_id() - i.e., a 32 character hex string. This option can be left alone in most situations.