Learn R Programming

archivist (version 2.3.8)

loadFromLocalRepo: Load Artifact Given as a md5hash from a Repository

Description

loadFromLocalRepo loads an artifact from a local Repository into the workspace. loadFromRemoteRepo loads an artifact from a github / git / mercurial Repository into the workspace. To learn more about artifacts visit archivistPackage.

Usage

loadFromLocalRepo(md5hash, repoDir = aoptions("repoDir"), value = FALSE)

loadFromRemoteRepo( md5hash, repo = aoptions("repo"), user = aoptions("user"), branch = aoptions("branch"), subdir = aoptions("subdir"), repoType = aoptions("repoType"), value = FALSE )

Arguments

md5hash

A character assigned to the artifact through the use of a cryptographical hash function with MD5 algorithm, or it's abbreviation.

repoDir

A character denoting an existing directory from which an artifact will be loaded.

value

If FALSE (default) then artifacts are loaded into the Global Environment with their original names, if TRUE then artifacts are returned as a list of values (if there is more than one artifact) or as a single value (if there is only one artifact that matches md5hash).

repo

While working with a Remote repository. A character containing a name of a Remote repository on which the Repository is archived. By default set to NULL - see Note.

user

While working with a Remote repository. A character containing a name of a Remote user on whose account the repo is created. By default set to NULL - see Note.

branch

While working with a Remote repository. A character containing a name of Remote Repository's branch on which the Repository is archived. Default branch is master.

subdir

While working with a Remote repository. A character containing a name of a directory on Remote repository on which the Repository is stored. If the Repository is stored in main folder on Remote repository, this should be set to subdir = "/" as default.

repoType

A character containing a type of the remote repository. Currently it can be 'Remote' or 'bitbucket'.

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

Functions loadFromLocalRepo and loadFromRemoteRepo load artifacts from the archivist Repositories stored in a local folder or on git. Both of them take md5hash as a parameter, which is a result of saveToRepo function. For each artifact, md5hash is a unique string of length 32 that is produced by digest function, which uses a cryptographical MD5 hash algorithm. For more information see md5hash.

Important: instead of giving the whole md5hash character, the user can simply give first few characters of the md5hash. For example, a09dd instead of a09ddjdkf9kj33dcjdnfjgos9jd9jkcv. All artifacts with the same md5hash abbreviation will be loaded from Repository.

Note that user and repo should be used only when working with a git repository and should be omitted in the local mode. repoDir should only be used when working on a local Repository and should be omitted in the git mode.

One may notice that loadFromRemoteRepo and loadFromLocalRepo load artifacts to the Global Environment with their original names. Alternatively, a parameter value = TRUE can be specified so that these functions may return artifacts as a value. As a result loaded artifacts can be attributed to new names. Note that, when an abbreviation of md5hash was given then a list of artifacts corresponding to this abbreviation will be loaded.

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

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(), md5hash, removeTagsRepo(), restoreLibs(), rmFromLocalRepo(), saveToLocalRepo(), searchInLocalRepo(), setLocalRepo(), shinySearchInLocalRepo(), showLocalRepo(), splitTagsLocal(), summaryLocalRepo(), zipLocalRepo()

Examples

Run this code

if (FALSE) {
# objects preparation

#' exampleRepoDir <- tempfile()
createLocalRepo(repoDir = exampleRepoDir)
data(iris)
saveToLocalRepo(iris, repoDir=exampleRepoDir, archiveSessionInfo = TRUE)
showLocalRepo(method = "md5hashes", repoDir = exampleRepoDir)
showLocalRepo(method = "tags", repoDir = exampleRepoDir)

loadFromLocalRepo(md5hash = '7f3453331910e3f321ef97d87adb5bad',
  repoDir = system.file("graphGallery", package = "archivist"), value = TRUE) -> pl
deleteLocalRepo(exampleRepoDir, TRUE)
rm(exampleRepoDir)


#
#Remote Version
#

# check the state of the Repository
summaryRemoteRepo( user="pbiecek", repo="archivist" )
showRemoteRepo( user="pbiecek", repo="archivist" )
showRemoteRepo( user="pbiecek", repo="archivist", method = "tags" )

rm( model )
rm( myplot123 )
rm( qda1 )
(VARmd5hash <- searchInRemoteRepo( "varname:Sepal.Width", 
                   user="pbiecek", repo="archivist" ))
(NAMEmd5hash <- searchInRemoteRepo( "name:qda1", 
                   user="pbiecek", repo="archivist", branch="master" ))
(CLASSmd5hash <- searchInRemoteRepo( "class:ggplot", 
                   user="pbiecek", repo="archivist", branch="master" ))


loadFromRemoteRepo( "ff575c261c", user="pbiecek", repo="archivist")
NewObjects <- loadFromRemoteRepo( NAMEmd5hash, user="pbiecek", repo="archivist", value = TRUE )
loadFromRemoteRepo( CLASSmd5hash, user="pbiecek", repo="archivist")


## Loading artifacts from the repository which is built in the archivist package 
## and saving them on the example repository

# Creating an example Repository - on which artifacts loaded from the
# archivist package repository will be saved
exampleRepoDir <- tempfile()
createLocalRepo(repoDir = exampleRepoDir)

# Directory of the archivist package repository
repo_archivist <- system.file("graphGallery", package = "archivist") 

# We are checking what kind of objects
# are stored in the archivist package repository
summaryLocalRepo(repoDir = repo_archivist)

# Let's say that we are interested in 
# an artifact of class ggplot.
GGPLOTmd5hash <- searchInLocalRepo(pattern = "class:ggplot",
                                   repoDir = repo_archivist) 
# There are eight of them.
# We load the first one by its value (parameter value = TRUE)
# and assign it to the p variable.
p <- loadFromLocalRepo(GGPLOTmd5hash[1], repoDir = repo_archivist,
                       value = TRUE)

# Finally, we may save the artifact on the example Repository.
# Note that md5hash is different from the one which is stored in
# the archivist package repository.
saveToRepo(p, repoDir = exampleRepoDir) 

# Making sure that the artifact is stored on the example repository
showLocalRepo(repoDir = exampleRepoDir, method = "tags")

# removing an example Repository

deleteLocalRepo( exampleRepoDir, TRUE)

rm( exampleRepoDir )

# many archivist-like Repositories on one Remote repository

loadFromRemoteRepo( "ff575c261c949d073b2895b05d1097c3", 
user="MarcinKosinski", repo="Museum", branch="master", subdir="ex2")


loadFromRemoteRepo( "ff575c261c949d073b2895b05d1097c3", 
                    user="MarcinKosinski", repo="Museum", branch="master",
                    subdir="ex1")
                    
#github
loadFromRemoteRepo(md5hash = "08dc0b66975cded92b5cd8291ebdc955", 
               repo = "graphGallery", user = "pbiecek", 
               repoType = "github", value = TRUE)
           
#git
loadFromRemoteRepo(md5hash = "08dc0b66975cded92b5cd8291ebdc955", 
               repo = "graphGalleryGit", user = "pbiecek", 
               repoType = "bitbucket", value = TRUE)

# mercurial               
loadFromRemoteRepo(md5hash = "08dc0b66975cded92b5cd8291ebdc955", 
               repo = "graphGalleryM", user = "pbiecek", 
               repoType = "bitbucket", value = TRUE)
}

Run the code above in your browser using DataLab