copy*Repo copies artifacts from one Repository into another Repository. It adds new files to existing gallery folder in repoTo Repository. copyLocalRepo copies local Repository while copyRemoteRepo copies remote Repository.

copyLocalRepo(repoFrom = NULL, repoTo, md5hashes)

copyRemoteRepo(repoTo, md5hashes, repo = aoptions("repo"),
  user = aoptions("user"), branch = aoptions("branch"),
  subdir = aoptions("subdir"), repoType = aoptions("repoType"))

Arguments

repoFrom

While copying local repository. A character that specifies the directory of the Repository from which artifacts will be copied. If it is set to NULL (by default), it will use the repoDir specified in setLocalRepo.

repoTo

A character that specifies the directory of the Repository into which artifacts will be copied.

md5hashes

A character vector containing md5hashes of artifacts to be copied.

repo

While coping the remote repository. A character containing a name of the remote repository on which the "repoFrom" - Repository is archived. By default set to NULL - see Note.

user

While coping the remote repository. A character containing a name of the remote user on whose account the "repoFrom" - Repository is created. By default set to NULL - see Note.

branch

While coping with the remote repository. A character containing a name of Remote Repository's branch on which the "repoFrom" - Repository is archived. Default branch is master.

subdir

While working with the remote repository. A character containing a name of a directory on the remote repository on which the "repoFrom" - Repository is stored. If the Repository is stored in the main folder on the remote repository, this should be set to FALSE as default.

repoType

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

Details

Functions copyLocalRepo and copyRemoteRepo copy artifacts from the archivist's Repositories stored in a local folder or on the Remote. Both of them use md5hashes of artifacts which are to be copied in md5hashes parameter. For more information about md5hash see md5hash.

Note

If repo and user are set to NULL (as default) in remote mode then global parameters set in setRemoteRepo function are used. If one would like to copy whole Repository we suggest to extract all md5hashes in this way unique(showLocalRepo(repoDir)[,1]).

Contact

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

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

Examples

# NOT RUN {
## Using archivist remote Repository to copy artifacts
# creating example Repository

exampleRepoDir <- tempfile()
createLocalRepo( exampleRepoDir )

# Searching for md5hashes of artifacts (without data related to them)
# in the archivist remote  Repository
hashes <- searchInRemoteRepo( pattern="name", user="pbiecek", repo="archivist", fixed=FALSE )

# Copying selected artifacts from archivist Remote  Repository into exampleRepoDir Repository

copyRemoteRepo( repoTo = exampleRepoDir , md5hashes= hashes, user="pbiecek", repo="archivist" )

# See how the gallery folder in our exampleRepoDir Repository
# with copies of artifacts from archivist Remote  Repository looks like
list.files( path = file.path( exampleRepoDir, "gallery" ) )

# See how the backpack database in our exampleRepoDir Repository looks like
showLocalRepo( repoDir = exampleRepoDir )

# removing an example Repository

deleteLocalRepo( exampleRepoDir, deleteRoot=TRUE )

rm( exampleRepoDir )

# many archivist-like Repositories on one Remote repository

dir <- paste0(getwd(), "/ex1")
createLocalRepo( dir )
copyRemoteRepo( repoTo = dir , md5hashes = "ff575c261c949d073b2895b05d1097c3",
                user="MarcinKosinski", repo="Museum",
                branch="master", subdir="ex2")

# Check if the copied artifact is on our dir Repository

showLocalRepo( repoDir = dir) # It is in backpack database indeed
list.files( path = file.path( dir, "gallery" ) ) # it is also in gallery folder

# removing an example Repository
deleteLocalRepo( dir, TRUE)

rm(dir)

## Using graphGallery Repository attached to the archivist package to copy artifacts

# creating example Repository

exampleRepoDir <- tempfile()
createLocalRepo( exampleRepoDir )

# Searching for md5hashes of artifacts (without data related to them)
# in the graphGallery  Repository
archivistRepo <- system.file( "graphGallery", package = "archivist")
# You may use: 
# hashes <- unique(showLocalRepo(repoDir)[,1]) 
# to extract all artifacts from repository
hashes <- searchInLocalRepo( pattern="name",
                             repoDir =  archivistRepo,
                             fixed=FALSE )

# Copying selected artifacts from archivist Remote  Repository into exampleRepoDir Repository

copyLocalRepo( repoFrom = archivistRepo, repoTo = exampleRepoDir , md5hashes= hashes )

# See how the backpack database in our exampleRepoDir Repository looks like
showLocalRepo( repoDir = exampleRepoDir )

# removing an example Repository

deleteLocalRepo( exampleRepoDir, deleteRoot=TRUE )

rm( exampleRepoDir )
rm( archivistRepo )

# }