Learn R Programming

archivist (version 2.3.8)

saveToLocalRepo: Save an Artifact into a Repository

Description

saveToLocalRepo function saves desired artifacts to the local Repository in a given directory. To learn more about artifacts visit archivistPackage.

Usage

saveToLocalRepo(
  artifact,
  repoDir = aoptions("repoDir"),
  archiveData = TRUE,
  archiveTags = TRUE,
  archiveMiniature = TRUE,
  archiveSessionInfo = TRUE,
  force = TRUE,
  value = FALSE,
  ...,
  userTags = c(),
  use_flocks = aoptions("use_flocks"),
  silent = aoptions("silent"),
  ascii = FALSE,
  artifactName = deparse(substitute(artifact))
)

saveToRepo( artifact, repoDir = aoptions("repoDir"), archiveData = TRUE, archiveTags = TRUE, archiveMiniature = TRUE, archiveSessionInfo = TRUE, force = TRUE, value = FALSE, ..., userTags = c(), use_flocks = aoptions("use_flocks"), silent = aoptions("silent"), ascii = FALSE, artifactName = deparse(substitute(artifact)) )

asave( artifact, repoDir = aoptions("repoDir"), archiveData = TRUE, archiveTags = TRUE, archiveMiniature = TRUE, archiveSessionInfo = TRUE, force = TRUE, value = FALSE, ..., userTags = c(), use_flocks = aoptions("use_flocks"), silent = aoptions("silent"), ascii = FALSE, artifactName = deparse(substitute(artifact)) )

Value

As a result of calling this function a character string is returned, which determines the md5hash of the artifact. If archiveData is TRUE, the result will also have an attribute, named data, which determines md5hash of the data needed to compute the artifact.

Arguments

artifact

An arbitrary R artifact to be saved. For supported artifacts see details.

repoDir

A character denoting an existing directory in which an artifact will be saved.

archiveData

A logical value denoting whether to archive the data from the artifact.

archiveTags

A logical value denoting whether to archive Tags from the artifact.

archiveMiniature

A logical value denoting whether to archive a miniature of the artifact.

archiveSessionInfo

A logical value denoting whether to archive the session info that describes the context in this given artifact was created.

force

A logical value denoting whether to archive artifact if it was already archived in a Repository.

value

A logical value. Should the result be (default value = FALSE) the md5hash of a stored artifact or should the result be an input artifact (value = TRUE), so that valuing code can be used. See examples.

...

Graphical parameters denoting width and height of a miniature. See details. Further arguments passed to head. See Details section about firtsRows parameter

userTags

A character vector with Tags. These Tags will be added to the repository along with the artifact.

use_flocks

A logical value. If TRUE then flock package is used to lock access to a database. By default it's FALSE.

silent

If TRUE produces no warnings.

ascii

A logical value. An ascii argument is passed to save function.

artifactName

The name of the artifact with which it should be archived. If NULL then object's MD5 hash will be used instead.

Contact

Bug reports and feature requests can be sent to https://github.com/pbiecek/archivist/issues

Author

Marcin Kosinski , m.p.kosinski@gmail.com

Details

saveToLocalRepo function saves desired artifacts to the local Repository in a given directory. Artifacts are saved in the local Repository, which is a SQLite database named backpack. After every saveToLocalRepo call the database is refreshed, so the artifact is available immediately in the database for other collaborators. Each artifact is archived in a md5hash.rda file. This file will be saved in a folder (under repoDir directory) named gallery. For each artifact, md5hash is a unique string of length 32 that is produced by digest function, which uses a cryptographical MD5 hash algorithm.

By default, a miniature of an artifact and (if possible) a data set needed to compute this artifact are extracted. They are also going to be saved in a file named by their md5hash in the gallery folder that exists in the directory specified in the repoDir argument. Moreover, a specific Tag-relation is going to be added to the backpack dataset in case there is a need to load the artifact with it's related data set - see loadFromLocalRepo or loadFromRemoteRepo. Default settings may be changed by using the archiveData, archiveTag or archiveMiniature arguments with the FALSE value.

Tags are artifact's attributes, different for various artifact's classes. For more detailed information check Tags

Archived artifact can be searched in the backpack dataset by using the searchInLocalRepo or searchInRemoteRepo functions. Artifacts can be searched by their Tags, names, classes or archiving date.

firstRows parameter.

If the artifact is of class data.frame or user set archiveData = TRUE for artifact that stores data within it, it is possible to specify how many rows of that data (or that data.frame) should be archived in a miniature. This can be done by adding the argument firstRows with the n corresponding to the number of rows (as in head). Note that, the data can be extracted only from the artifacts that are supported by the archivist package; see Tags.

Graphical parameters.

If the artifact is of class lattice, ggplot or recordedplot, and archiveMiniature = TRUE, then it is possible to set the miniature's width and height parameters. By default they are set to width = 800, height = 600.

Supported artifact's classes are listed here Tags.

References

Biecek P and Kosinski M (2017). "archivist: An R Package for Managing, Recording and Restoring Data Analysis Results." _Journal of Statistical Software_, *82*(11), pp. 1-28. doi: 10.18637/jss.v082.i11 (URL: http://doi.org/10.18637/jss.v082.i11). URL https://github.com/pbiecek/archivist

See Also

For more detailed information check the archivist package Use Cases. The list of supported artifacts and their tags is available on wiki on archivist Github Repository.

Other archivist: Repository, Tags, %a%(), addHooksToPrint(), addTagsRepo(), aformat(), ahistory(), alink(), aoptions(), archivistPackage, aread(), areadLocal(), asearch(), asearchLocal(), asession(), atrace(), cache(), copyLocalRepo(), createLocalRepo(), createMDGallery(), deleteLocalRepo(), getRemoteHook(), getTagsLocal(), loadFromLocalRepo(), md5hash, removeTagsRepo(), restoreLibs(), rmFromLocalRepo(), searchInLocalRepo(), setLocalRepo(), shinySearchInLocalRepo(), showLocalRepo(), splitTagsLocal(), summaryLocalRepo(), zipLocalRepo()

Examples

Run this code
if (FALSE) {
exampleRepoDir <- tempfile(tmpdir = ".")
createLocalRepo(repoDir = exampleRepoDir)
data(swiss)
saveToLocalRepo(swiss, repoDir=exampleRepoDir, archiveSessionInfo = TRUE)
showLocalRepo(method = "md5hashes", repoDir = exampleRepoDir)
showLocalRepo(method = "tags", repoDir = exampleRepoDir)

loadFromLocalRepo(md5hash = '2a6e492cb6982f230e48cf46023e2e4f',
  repoDir = system.file("graphGallery", package = "archivist"), value = TRUE) -> model

saveToLocalRepo(model, repoDir=exampleRepoDir,
             userTags = c("do not delete", "my favourite model"))
aoptions('repoDir', system.file("graphGallery", package = "archivist"))
showLocalRepo(method = "tags")
data(iris)
asave(iris, silent = FALSE) # iris was used in pl
aoptions('repoDir', NULL, unset = TRUE)
deleteLocalRepo(exampleRepoDir, TRUE)
rm(exampleRepoDir)
}

Run the code above in your browser using DataLab