Title: | Installing, Managing, and Switching Between Distinct Sets of Installed Packages |
---|---|
Description: | Provides an abstraction for managing, installing, and switching between sets of installed R packages. This allows users to maintain multiple package libraries simultaneously, e.g. to maintain strict, package-version-specific reproducibility of many analyses, or work within a development/production release paradigm. Introduces a generalized package installation process which supports multiple repository and non-repository sources and tracks package provenance. |
Authors: | Gabriel Becker[aut, cre] |
Maintainer: | Gabriel Becker <[email protected]> |
License: | Artistic-2.0 |
Version: | 0.14.5.1 |
Built: | 2024-10-31 16:32:59 UTC |
Source: | https://github.com/gmbecker/switchr |
A version of .libPaths which allows for excluding the site library
.libPaths2(fulllp, exclude.site = TRUE)
.libPaths2(fulllp, exclude.site = TRUE)
fulllp |
The libpath to use, as in .libPaths |
exclude.site |
logical. Should the site library be suppressed. Defaults to TRUE |
Behaves exactly as the .libPaths function does, with the exception of optionally excluding the site library
Add a package to an object associated with a manifest
addPkg( x, ..., rows = makeManifest(...), versions = data.frame(name = manifest_df(rows)$name, version = NA_character_, stringsAsFactors = FALSE), replace = FALSE ) ## S4 method for signature 'PkgManifest' addPkg( x, ..., rows = makeManifest(...), versions = data.frame(name = manifest_df(rows)$name, version = NA_character_, stringsAsFactors = FALSE), replace = FALSE ) ## S4 method for signature 'SessionManifest' addPkg( x, ..., rows = makeManifest(...), versions = data.frame(name = manifest_df(rows)$name, version = NA_character_, stringsAsFactors = FALSE), replace = FALSE )
addPkg( x, ..., rows = makeManifest(...), versions = data.frame(name = manifest_df(rows)$name, version = NA_character_, stringsAsFactors = FALSE), replace = FALSE ) ## S4 method for signature 'PkgManifest' addPkg( x, ..., rows = makeManifest(...), versions = data.frame(name = manifest_df(rows)$name, version = NA_character_, stringsAsFactors = FALSE), replace = FALSE ) ## S4 method for signature 'SessionManifest' addPkg( x, ..., rows = makeManifest(...), versions = data.frame(name = manifest_df(rows)$name, version = NA_character_, stringsAsFactors = FALSE), replace = FALSE )
x |
A manifest or manifest-associate objec tto add the pkg 2 |
... |
The information regarding the package to place in the manifest |
rows |
An already-created data.frame to add to the manifest |
versions |
A data.frame of package names and versions, if adding to a SessionManifest, ignored otherwise |
replace |
logical. If true, the specified package info will replace any already in the manifest in the case of duplicates. Otherwise, an error is thrown. |
Get or set the number of times to retry downloading a file from the CRAN archive
This is intended to stop intermittent install failures due to failing to retrieve files that *are* in the archive but are not downloading properly when a larger number of packages is being retrieved.
archive_retries(x) ## S4 method for signature 'SwitchrParam' archive_retries(x) archive_retries(x) <- value ## S4 replacement method for signature 'SwitchrParam' archive_retries(x) <- value
archive_retries(x) ## S4 method for signature 'SwitchrParam' archive_retries(x) archive_retries(x) <- value ## S4 replacement method for signature 'SwitchrParam' archive_retries(x) <- value
x |
A SwitchrParam object |
value |
The new number of seconds to wait |
When getting, the number of seconds to wait, when setting, a new, updated SwitchrParam object.
Get or set the number of seconds to wait after trying to retrieve a file from the CRAN Archive.
This is intended to stop intermittent install failures due to failing to retrieve files that *are* in the archive but are not downloading properly when a larger number of packages is being retrieved.
archive_timing(x) ## S4 method for signature 'SwitchrParam' archive_timing(x) archive_timing(x) <- value ## S4 replacement method for signature 'SwitchrParam' archive_timing(x) <- value
archive_timing(x) ## S4 method for signature 'SwitchrParam' archive_timing(x) archive_timing(x) <- value ## S4 replacement method for signature 'SwitchrParam' archive_timing(x) <- value
x |
A SwitchrParam object |
value |
The new number of seconds to wait |
When getting, the number of seconds to wait, when setting, a new, updated SwitchrParam object.
An object representing the current Bioc devel version. Can be passed to switchTo.
BiocDevel
BiocDevel
An object of class RepoSubset
of length 1.
An object representing the current Bioc release. Can be passed to switchTo.
BiocRelease
BiocRelease
An object of class RepoSubset
of length 1.
Generate the URLs of the repositories associated with a specific Bioconductor release
biocReposForVers(version)
biocReposForVers(version)
version |
The Bioconductor release to generate URLs for. |
This function will only work if some version of Bioconductor (>2.9) was installed when switchr was installed. It will return NULL otherwise.
DEPCRECATED - Create a manifest of Bioc SVN locations
BiocSVNManifest(bioc_vers = "devel", software_only = TRUE)
BiocSVNManifest(bioc_vers = "devel", software_only = TRUE)
bioc_vers |
A version number for a bioc release, or |
software_only |
logical. Should only software packages be included in the manifest? Defaults to TRUE |
In combination with the lazyRepo
function, this
manifest can be used to work from a local, working checkout of a
set of inter-dependent Bioconductor packages.
A PkgManifest which contains SVN locations for all
packages found in the specified bioc repositories, as well
as those listed in not_in_repo
A constructor for creating a RepoSubset object for a specified release of Bioconductor, which includes only the BiocInstaller package.
BiocVers( version = getBiocReleaseVr(), name = paste("BioC", version, sep = "_"), repos = biocReposForVers(version) )
BiocVers( version = getBiocReleaseVr(), name = paste("BioC", version, sep = "_"), repos = biocReposForVers(version) )
version |
The version of Bioconductor |
name |
The default name for switchr libraries created with this object |
repos |
The urls of the Bioconductor repositories. these will be modified automatically to match the specified version |
Get or set the branch associated with a Package Source
branch(x) ## S4 method for signature 'PkgSource' branch(x) branch(x) <- value ## S4 replacement method for signature 'PkgSource' branch(x) <- value
branch(x) ## S4 method for signature 'PkgSource' branch(x) branch(x) <- value ## S4 replacement method for signature 'PkgSource' branch(x) <- value
x |
A source |
value |
The new branch |
Combine 2 or more manifests of the same type (PkgManifest or SessionManifest)
## S4 method for signature 'SessionManifest' c(x, ..., recursive = FALSE) ## S4 method for signature 'PkgManifest' c(x, ..., recursive = FALSE)
## S4 method for signature 'SessionManifest' c(x, ..., recursive = FALSE) ## S4 method for signature 'PkgManifest' c(x, ..., recursive = FALSE)
x |
An object (indicates the type of all objects to be combined) |
... |
more objects |
recursive |
Unused |
Check if a directory contains package sources
checkIsPkgDir(dir)
checkIsPkgDir(dir)
dir |
The directory |
Create a Pkg manifest which points to tarballs representing a particular version of a CRAN package and versions of its (recursive) dependencies that were contemporary on the first or last day the specified package version resided on CRAN
cranPkgVersManifest( pkg, vers, earliest = TRUE, cur_avail = available.packages(), verbose = FALSE, suggests = c("direct", "none"), delay = 1, erronfail = TRUE )
cranPkgVersManifest( pkg, vers, earliest = TRUE, cur_avail = available.packages(), verbose = FALSE, suggests = c("direct", "none"), delay = 1, erronfail = TRUE )
pkg |
The package on which to base the generated manifest |
vers |
The version of |
earliest |
Should the package dependencies be contemporary with the first (TRUE) or last (FALSE) day the specified package version was (the latest version) on CRAN? |
cur_avail |
The output from available.packages(). Used to identify whether the necessary version is in the CRAN archive or normal repository |
verbose |
Should debugging information about the recursive traversal of package dependencies be printed (defaults to FALSE). |
suggests |
Which Suggests'ed packages should be included. Currently
supported possibilites are direct, indicating Suggestions of |
delay |
Number of seconds to delay between successive REST calls to the crandb database. Defaults to 1 second |
erronfail |
how should connection errors be handled. |
A SessionManifest object
Some packages retain the same version on CRAN for long periods of
time. The cohort in the manifest represents a gross proxy for the cohort
used in conjunction within an analysis which used a the vers
version
of the specified package. In general it will *not* perfectly recreate
the set of package versions originally used.
Gabriel Becker
"Gabor Csardi" (2014). crandb: Query the unofficial CRAN metadata database. R package version 1.0.0. https://github.com/metacran/crandb
Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01
## Not run: man = cranPkgVersManifest("devtools", "1.6") ## End(Not run)
## Not run: man = cranPkgVersManifest("devtools", "1.6") ## End(Not run)
Display the computing environment currently in use. If switchTo has not been called, a new SwitchrCtx object describing the current environment is created.
currentCompEnv()
currentCompEnv()
Get default repositories for use as dependency repos and within install_packages
defaultRepos()
defaultRepos()
A character vector of package repository urls
Get or set repositories to be used to fullfill dependencies beyond packages within the manifest
dep_repos(x) ## S4 method for signature 'PkgManifest' dep_repos(x) ## S4 method for signature 'SessionManifest' dep_repos(x) dep_repos(x) <- value ## S4 replacement method for signature 'PkgManifest' dep_repos(x) <- value ## S4 replacement method for signature 'SessionManifest' dep_repos(x) <- value
dep_repos(x) ## S4 method for signature 'PkgManifest' dep_repos(x) ## S4 method for signature 'SessionManifest' dep_repos(x) dep_repos(x) <- value ## S4 replacement method for signature 'PkgManifest' dep_repos(x) <- value ## S4 replacement method for signature 'SessionManifest' dep_repos(x) <- value
x |
A package or session manifest |
value |
A character vector with the new dependency repos |
Character vector with existing repository urls
Get or set the download method for retreiving files.
dl_method(x) ## S4 method for signature 'SwitchrParam' dl_method(x) dl_method(x) <- value ## S4 replacement method for signature 'SwitchrParam' dl_method(x) <- value
dl_method(x) ## S4 method for signature 'SwitchrParam' dl_method(x) dl_method(x) <- value ## S4 replacement method for signature 'SwitchrParam' dl_method(x) <- value
x |
A SwitchrParam object |
value |
The new number of seconds to wait |
Identify error states from R or external programs
errorOrNonZero(out)
errorOrNonZero(out)
out |
An R object representing output |
TRUE if out is an error object, or has an attribute called "status" which is > 0
Get path from file URL
fileFromFileURL(fileurl)
fileFromFileURL(fileurl)
fileurl |
A file url (beginning in file://) |
The system directory path that fileurl
points to
Find newest packages in a package info data.frame
findNewestPkgInds(df, pkgcol = "package", verscol = "version") findNewestPkgRows( df, pkgcol = "package", verscol = "version", newcol = "new", verbose = FALSE, logfun = message )
findNewestPkgInds(df, pkgcol = "package", verscol = "version") findNewestPkgRows( df, pkgcol = "package", verscol = "version", newcol = "new", verbose = FALSE, logfun = message )
df |
data.frame. Table of package information |
pkgcol |
string. Name of column containing package name |
verscol |
string. Name of column containing package version in version-string form. |
newcol |
character. Experimental. column name for the column indicating that the version is new. |
verbose |
logical. Should debugging information be written using |
logfun |
function. Logging function (closure) which should be called to write verbose logging messages during the process. |
a data.frame with the same columns as df
which contains
only the most recent row for each unique package name, as determined
by the contents of df[[verscol]]
for findNewestPkgInds
, the indices of the rows representing
the newest version of each package within df
. For
findNewestPkgRows
, the rows themselves from df
representing
the newest version of each package.
Find a package directory within an SCM checkout
findPkgDir(rootdir, branch, subdir, param)
findPkgDir(rootdir, branch, subdir, param)
rootdir |
The directory of the checkout |
branch |
The branch to navigate to |
subdir |
The subdirectory to navigate to |
param |
a SwitchrParam object |
A path to the Package sources
findPkgVersionInRepo
findPkgVersionInRepo(repo, name, version, param, dir) ## S4 method for signature 'character' findPkgVersionInRepo(repo, name, version, param, dir) ## S4 method for signature ''NULL'' findPkgVersionInRepo(repo, name, version, param, dir)
findPkgVersionInRepo(repo, name, version, param, dir) ## S4 method for signature 'character' findPkgVersionInRepo(repo, name, version, param, dir) ## S4 method for signature ''NULL'' findPkgVersionInRepo(repo, name, version, param, dir)
repo |
The repository |
name |
The name of the package |
version |
The version of the package to find |
param |
A SwitchrParam object |
dir |
The directory to download the located package tarball into |
A path to the downloaded tarball, or NULL
Unload currently loaded packages from the current R session
flushSession(dontunload = switchrDontUnload())
flushSession(dontunload = switchrDontUnload())
dontunload |
Non-base packages to ignore (not detatch/unload) |
Attached packages are detached (and unloaded) first. After this is done, loaded packages, such as those imported by (previously) attached packages, are unloaded.
Finally, after all packages have been unloaded, native libraries loaded by those packages are unloaded (on systems where this is supported).
NULL, called for its side-effect of unloading packages
Failing to include switchr, any of its dependencies, or any base
packages (available as a vector in the switchDeps
object)
in dontunload
will result in undefined, likely erroneous behavior.
Accessor for the full library path associate with a SwitchrCtx, including the R library and (if not excluded) the site library
full_libpaths(seed) ## S4 method for signature 'SwitchrCtx' full_libpaths(seed)
full_libpaths(seed) ## S4 method for signature 'SwitchrCtx' full_libpaths(seed)
seed |
a SwitchrCtx |
Construct pockage directory path
getPkgDir(basepath, name, subdir, scm_type, branch)
getPkgDir(basepath, name, subdir, scm_type, branch)
basepath |
The parent directory for the package directory |
name |
The name of the package |
subdir |
The subdirectory within a package source that the actual package root directory will reside in. |
scm_type |
Tye type of scm the package sources will be checked out from |
branch |
The branch from which the package will be retrieved. |
A path
Unlike findPkgDir
this does not look for existing
package source directories. It only constructs the path.
Create a package manifest containing only github packages
GithubManifest(..., pkgrepos)
GithubManifest(..., pkgrepos)
... |
Combined to populate |
pkgrepos |
Github repositories in the form "<user>/<reponame>" |
Any names of the pkgrepos vector are assumed to be pkg names for the manifest. For unnamed elements, the pkg name is assumed to be the repository name.
This is a convenience wrapper for makeManifest
.
It uses the username/repo[/subdir][@ref]
shorthand for specifying
package locations in github repositories introduced by Wickham's
devtools. Unlike devtools, username is not optional, and only branch
names are currently supported in the @ref
ghman = GithubManifest("gmbecker/switchr", "hadley/devtools") ghman
ghman = GithubManifest("gmbecker/switchr", "hadley/devtools") ghman
This is a low-level function not intended for direct use by the end user.
gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,SVNSource' gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,CRANSource' gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,BiocSource' gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,GitSource' gotoVersCommit(dir, src, version, param = SwitchrParam())
gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,SVNSource' gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,CRANSource' gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,BiocSource' gotoVersCommit(dir, src, version, param = SwitchrParam()) ## S4 method for signature 'character,GitSource' gotoVersCommit(dir, src, version, param = SwitchrParam())
dir |
Directory |
src |
A PkgSource (or subclass) object |
version |
The exact version to locate |
param |
A SwitchrParam |
This function should never be called by code outside of tests/vignettes in this package or packages that depend on it.
graceful_inet(val, silent) warning2(...)
graceful_inet(val, silent) warning2(...)
val |
logical. NA means no additional handling, TRUE, means careful handling but actually attempt the call, FALSE means force immedate failure without evaling expressions wrapped in inet_handlers() calls |
silent |
logical(1). Should errors and warnings be emitted as messages (FALSE) or be fully suppressed (TRUE). |
... |
passed to message or base::warning |
Head and tail operations on manifests
head(x, ...) ## S4 method for signature 'SessionManifest' head(x, n = 5, ...) ## S4 method for signature 'PkgManifest' head(x, n = 5, ...) tail(x, ...) ## S4 method for signature 'SessionManifest' tail(x, n = 5, ...) ## S4 method for signature 'PkgManifest' tail(x, n = 5, ...)
head(x, ...) ## S4 method for signature 'SessionManifest' head(x, n = 5, ...) ## S4 method for signature 'PkgManifest' head(x, n = 5, ...) tail(x, ...) ## S4 method for signature 'SessionManifest' tail(x, n = 5, ...) ## S4 method for signature 'PkgManifest' tail(x, n = 5, ...)
x |
A manifest object |
... |
unused |
n |
The number of packages to keep |
In the case of a PkgManifest
, the first or last n
packages are retained in the manifest, while all others are removed.
In the case of a SessionManifest
, n
specified versions
are retained, while the underlying PkgManifest
is unchanged.
An object of the same type as x
containing n
packages
Install packages from a set of traditional repositories, or a Just-in-time repository constructed using a PkgManifest or SessionManifest
install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,character' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,missing' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'SessionManifest,ANY' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,SessionManifest' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,PkgManifest' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...)
install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,character' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,missing' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'SessionManifest,ANY' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,SessionManifest' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...) ## S4 method for signature 'character,PkgManifest' install_packages(pkgs, repos, versions = NULL, verbose = FALSE, ...)
pkgs |
The names of the packages to install |
repos |
The (generalized) repositor(ies) to install the packages from. Can be a character vector of traditional package repositories (as with install.packages) or a PkgManifest or SessionManifest (or a url thereof) |
versions |
An optional named character vector or data.frame specifying exact versions of the packages to install |
verbose |
Should extra information be printed during the console during installation |
... |
extra parameters passed directly to install.packages |
In addition to installing the specified packages, this function annotates the installed DESCRIPTION files with provenance information about where the packages were installed from. This retains the information necessary to generate a manifest of installed packages for publication or reinstallation.
When repos
is a vector of traditional repositories, this function -
with the exception of the provenance mentioned above - behaves identically
to install.packages
. Otherwise, a Just-in-Time package
repository is constructed using the information in the manifest(s) passed
to repos
, which is then used in conjuction with
link{install.packages}
to do the actual installation.
Gabriel Becker
Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01
## Not run: ## equivalent to install.packages, except it stores ## package provenance and knows about bioconductor repos install_packages("nlme") ## install from a manifest man = GithubManifest("gmbecker/fastdigest") install_packages("fastdigest", man) ## install a full seeding manifest man2 = makeSeedMan("myotherlib") install_packages(man2) ## End(Not run)
## Not run: ## equivalent to install.packages, except it stores ## package provenance and knows about bioconductor repos install_packages("nlme") ## install from a manifest man = GithubManifest("gmbecker/fastdigest") install_packages("fastdigest", man) ## install a full seeding manifest man2 = makeSeedMan("myotherlib") install_packages(man2) ## End(Not run)
Create a lazy repository for installing directly from a package
manifest. Most users will want to call Install
directly,
which will call this as needed behind the scenes.
lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'SessionManifest,ANY' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'PkgManifest,ANY' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'character,SessionManifest' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'character,PkgManifest' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE )
lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'SessionManifest,ANY' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'PkgManifest,ANY' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'character,SessionManifest' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE ) ## S4 method for signature 'character,PkgManifest' lazyRepo( pkgs, pkg_manifest, versions = rep(NA, times = length(pkgs)), dir = tempdir(), rep_path = file.path(dir, "repo"), get_suggests = FALSE, verbose = FALSE, scm_auths = list(bioconductor = c("readonly", "readonly")), param = SwitchrParam(), force_refresh = FALSE )
pkgs |
The packages to install |
pkg_manifest |
The manifest to use |
versions |
Specific versions of the packages to install. Should be a
vector of the same length as |
dir |
The directory packages should be downloaded/checkedout/built into |
rep_path |
The path of the final repository |
get_suggests |
Whether suggested packages should be included in the lazy repository. Defaults to FALSE |
verbose |
Should extra information be printed to the user during the construction process |
scm_auths |
Named list of username/password credentials for checking
out package sources from one or more sources listed in |
param |
A SwitchrParam object |
force_refresh |
If a package already appears in the lazy repo area, it be updated (e.g. from SCM) and built again? Defaults to FALSE |
When checking building from SVN or git checkouts, this function
will first look for existing checkouts for the relevant packages in
dir
. If found, these will be updated (in the case of conflicts, the
behavior is undefined and will likely fail if they are not resolvable). This
allows the user to have an existing, checkout directory where he or she
works on development versions of multiple, interrelated packages, as local
changes WILL be reflected in the packages built into the lazy repository.
A path to the populated lazy repository, suitable for 'coercing' to a url and installing from.
Gabriel Becker
Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01
Create a Session- or PkgManifest for the contents of a switchr library.
libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... ) ## S4 method for signature 'missing' libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... ) ## S4 method for signature 'character' libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... ) ## S4 method for signature 'SwitchrCtx' libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... )
libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... ) ## S4 method for signature 'missing' libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... ) ## S4 method for signature 'character' libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... ) ## S4 method for signature 'SwitchrCtx' libManifest( lib = currentCompEnv(), record_versions = TRUE, known_manifest = makeManifest(dep_repos = repos), repos = defaultRepos(), ... )
lib |
A SwitchrCtx object, or the name of a switchr library. Defaults to the currently active switchr library. |
record_versions |
Should the exact versions of installed packages be recorded in the manifest (TRUE) |
known_manifest |
An existing manifest, used when imputing
location information for packages not
installed via |
repos |
A vector of traditional package repositories. Used when imputing
location information for packages not installed via
|
... |
currently unused |
The manifest generated by this function will not include base packages, as they are part of R and not installable in the traditional sense.
man = libManifest() man ## Not run: man2 = libManifest("myotherlib") man2 ## End(Not run)
man = libManifest() man ## Not run: man2 = libManifest("myotherlib") man2 ## End(Not run)
Accessor for which directories an SwitchrCtx is associated with.
library_paths(seed) ## S4 method for signature 'SwitchrCtx' library_paths(seed)
library_paths(seed) ## S4 method for signature 'SwitchrCtx' library_paths(seed)
seed |
An SwitchrCtx |
Currently unused/under heavy development.
An object
Load a GRAN repo package
loadGRAN(nm = "current")
loadGRAN(nm = "current")
nm |
The name of the repository for which to load the package. Defaults
|
This function is a convenience to load the package GRAN<nm>, which will provide the contained GRAN repository as default repository within the switchr framework.
NULL. Called for the side-effect of loading the specified package
Load a package or session manifest from a file (local or URL)
loadManifest(fil)
loadManifest(fil)
fil |
The path or URL to the file or a gist containing it |
A PkgManifest or SessionManifest object
Locate and download/build the exact version of a single package.
locatePkgVersion( name, version, pkg_manifest, param = SwitchrParam(), dir = notrack(repo), repo = NULL )
locatePkgVersion( name, version, pkg_manifest, param = SwitchrParam(), dir = notrack(repo), repo = NULL )
name |
package name |
version |
package version string |
pkg_manifest |
A manifest containing locations to search for the package |
param |
A SwitchrParam object |
dir |
directory to download package into |
repo |
(optional) GRANRepository object to search |
The full path to the downloaded file , or NULL if unable to locate the package
Locating and attempting to install a non-current version of a single
will not work in general, due to dependency issues. In most cases a
Just-in-Time repository should be created and used instead, e.g. via
install_packages
This function is called internally during the construction of Just-in-Time repositories and during the installation of specific package versions.
Gabriel Becker
Retreive the directory associated with an object
location(repo) ## S4 method for signature 'PkgSource' location(repo)
location(repo) ## S4 method for signature 'PkgSource' location(repo)
repo |
An object associated with a path |
a character containing the associated path
Gabriel Becker
Get or set the logging function in an object associated with a SwitchrParam
logfun(x) ## S4 method for signature 'SwitchrParam' logfun(x) logfun(x) <- value ## S4 replacement method for signature 'SwitchrParam' logfun(x) <- value
logfun(x) ## S4 method for signature 'SwitchrParam' logfun(x) logfun(x) <- value ## S4 replacement method for signature 'SwitchrParam' logfun(x) <- value
x |
An object with a SwitchrParam |
value |
The new logging function |
Make SVN url for a Bioconductor package given the name, bioc version, and type of package.
makeBiocSVNURL(name, biocVers = getBiocvrFromRvr(), pkgtype = "software")
makeBiocSVNURL(name, biocVers = getBiocvrFromRvr(), pkgtype = "software")
name |
A vector of bioconductor package names The name of the package |
biocVers |
The version (release) of bioconductor, or |
pkgtype |
character. Which type of packages to retrieve the SVN root url for. Should be
|
A vector of urls for the specified packages within the Bioconductor SVN repository
make file url
makeFileURL(path)
makeFileURL(path)
path |
The path to wrap in a file:// URL |
A valid file URL
Locate or create a specified switchr library
makeLibraryCtx( name, seed = NULL, pkgs = NULL, exclude.site = TRUE, contains, rvers = NULL, verbose = FALSE )
makeLibraryCtx( name, seed = NULL, pkgs = NULL, exclude.site = TRUE, contains, rvers = NULL, verbose = FALSE )
name |
The name for the library |
seed |
The object to seed the library from |
pkgs |
Pkgs to install upon creation. Deprecated, use a seeding object instead. |
exclude.site |
Whether the site library should be excluded when switching to this library |
contains |
Currently unused. |
rvers |
Optional R version. If specified, existing libraries much be associated with the same R version to be considered a match. |
verbose |
Should informative messages be emitted to the console |
This function is not intended to be called directly in most cases; switchTo calls it automatically.
Create a package manifest
makeManifest(..., dep_repos = defaultRepos())
makeManifest(..., dep_repos = defaultRepos())
... |
Vectors containing package information. Passed to |
dep_repos |
The dependency repos for the package. |
Create a checkout of a package and all it's dependencies from a manifest
makePkgCheckout( pkgs, pkg_manifest, dir, get_suggests = c("none", "first", "all"), param = SwitchrParam(), scm_auths = list(bioconductor = c("readonly", "readonly")), repos = defaultRepos() )
makePkgCheckout( pkgs, pkg_manifest, dir, get_suggests = c("none", "first", "all"), param = SwitchrParam(), scm_auths = list(bioconductor = c("readonly", "readonly")), repos = defaultRepos() )
pkgs |
character - The packages you will be working on |
pkg_manifest |
Pkgmanifest|SessionManifest - The manifest containing the pkgs and dependencies to checkout |
dir |
character - The directory in which to place the checkouts of packages |
get_suggests |
character - Should 'Suggests' dependencies be retrieved? Options are "none" (never), "first" (for packages in |
param |
SwitchrParam - The SwitchrParam to use during the checkout process, |
scm_auths |
list - A named list of user-password pairs to use during the checkout process |
repos |
character - The package repositories to retrieve dependnecy information from for pkgs/dependnecies which do not appear in |
a character vector of all packages (incl. recursive dependnecies) checked out into dir
This is an internal function not intended to be called directly by end users
makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,SVNSource' makePkgDir( name, source, path, latest_only = FALSE, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,GithubSource' makePkgDir( name, source, path, latest_only = FALSE, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,GitSource' makePkgDir( name, source, path, latest_only = FALSE, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,ANY' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,CRANSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,BiocSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,TarballSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,LocalSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE )
makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,SVNSource' makePkgDir( name, source, path, latest_only = FALSE, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,GithubSource' makePkgDir( name, source, path, latest_only = FALSE, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,GitSource' makePkgDir( name, source, path, latest_only = FALSE, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,ANY' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,CRANSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,BiocSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,TarballSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE ) ## S4 method for signature 'ANY,LocalSource' makePkgDir( name, source, path, latest_only, param = SwitchrParam(), forceRefresh = FALSE )
name |
The package |
source |
A PkgSource |
path |
The path to place the directory |
latest_only |
Should a fastpath for downloading the latest commit in a SCM package without a formal checkout be used? |
param |
A SwitchrParam |
forceRefresh |
Should an existing instance of the package source be deleted/refreshed |
Create a directory and populate it with package source code from the specified source
makeSeedMan
makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'missing' makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'sessionInfo' makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'parsedSessionInfo' makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'data.frame' makeSeedMan(x, known_manifest = PkgManifest(), ...)
makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'missing' makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'sessionInfo' makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'parsedSessionInfo' makeSeedMan(x, known_manifest = PkgManifest(), ...) ## S4 method for signature 'data.frame' makeSeedMan(x, known_manifest = PkgManifest(), ...)
x |
The object to generate a seeding manifest from, if missing, the output from sessionInfo() is used. |
known_manifest |
A manifest containing known locations of package sources. makeSeedMan will attempt to determine locations of packages listed in x using both known_manifest and official repositories. |
... |
Currently unused. |
man = makeSeedMan()
man = makeSeedMan()
Create a PkgSource object for a package
makeSource( url, type, user, password, scm_auth = list(), prefer_svn = FALSE, ... )
makeSource( url, type, user, password, scm_auth = list(), prefer_svn = FALSE, ... )
url |
The url of the package sources |
type |
The source type. |
user |
A function which, when called, returns the username to use when when checking the soources out |
password |
A function which returns the password to use when checking out the sources |
scm_auth |
A list of username-password pairs, named with regular
expressions to match against url when constructing the
defaults for |
prefer_svn |
Currently unused. |
... |
Passed directly to constructors for PkgSource superclasses |
Get or set manifest associated with an object
manifest(x) manifest(x) <- value ## S4 method for signature 'SessionManifest' manifest(x) ## S4 replacement method for signature 'SessionManifest' manifest(x) <- value
manifest(x) manifest(x) <- value ## S4 method for signature 'SessionManifest' manifest(x) ## S4 replacement method for signature 'SessionManifest' manifest(x) <- value
x |
An object which contains a manifest |
value |
A PkgManifest |
A PkgManifest or SessionManifest object
Get or set the package location manifest (data.frame) associated with an object
manifest_df(x, ...) ## S4 method for signature 'SessionManifest' manifest_df(x, session_only = TRUE, ...) ## S4 method for signature 'PkgManifest' manifest_df(x) manifest_df(x) <- value ## S4 replacement method for signature 'SessionManifest' manifest_df(x) <- value ## S4 replacement method for signature 'PkgManifest' manifest_df(x) <- value
manifest_df(x, ...) ## S4 method for signature 'SessionManifest' manifest_df(x, session_only = TRUE, ...) ## S4 method for signature 'PkgManifest' manifest_df(x) manifest_df(x) <- value ## S4 replacement method for signature 'SessionManifest' manifest_df(x) <- value ## S4 replacement method for signature 'PkgManifest' manifest_df(x) <- value
x |
The object |
... |
unused. |
session_only |
Only return manifest rows associated with |
value |
A data.frame of package manifest information.
See |
This function is useful when a developer has a 'checkout' directory where the sources for multiple packages live. Particularly, it allows one to work on multiple interlocking packages at the same time and have a manifest which will install them all together automatically when time for testing.
manifestFromCheckoutDir(pdir, recursive = FALSE, excl_pat = NULL)
manifestFromCheckoutDir(pdir, recursive = FALSE, excl_pat = NULL)
pdir |
character(1). Parent directory which contains package source directories. |
recursive |
logical(1). Should directories within |
excl_pat |
character(1) or NULL. A regular expression for directories/packages to exclude from the manifest. |
A Package manifest with 'local' type entries for each package found within pdir
.
## Not run: manifestFromCheckoutDir(".") ## End(Not run)
## Not run: manifestFromCheckoutDir(".") ## End(Not run)
Create one or more rows of a manifest data.frame
ManifestRow( name, url = NA_character_, type = NA_character_, branch = NA_character_, subdir = ".", extra = NA_character_ )
ManifestRow( name, url = NA_character_, type = NA_character_, branch = NA_character_, subdir = ".", extra = NA_character_ )
name |
name of the package. |
url |
location of the package sources |
type |
type of location (svn, git, local, etc) |
branch |
name of the branch to use to build the package |
subdir |
subdirectory to use to build the package |
extra |
currently ignored. extra commands for building or installing the package |
If name is missing, an empty (0 row) manifest data.frame
is returned. All other fields default to values indicating no information-
NA_character
in most cases, and "."
for subdir
A valid Package manifest data.frame
Attempt to normalize a relative path to an absolute one. Optionally without resolving symlinks on non-Windows systems
normalizePath2(path, follow.symlinks = FALSE, winslash = "\\", mustWork = NA)
normalizePath2(path, follow.symlinks = FALSE, winslash = "\\", mustWork = NA)
path |
The path to normalize |
follow.symlinks |
Should symlinks (other than . and ..) be resolved to their physical locations? (FALSE) |
winslash |
The value of winslash to be passed down to normalizePath on windows systems |
mustWork |
logical. Passed to normalizePath on windows. Ignored otherwise. |
The normalized path.
This function is not intended to be called directly by the user.
notrack(repo) ## S4 method for signature ''NULL'' notrack(repo)
notrack(repo) ## S4 method for signature ''NULL'' notrack(repo)
repo |
The object. |
the path where retrieved package versions should be. If repo
is NULL, a notrack directory is constructed within a temp directory.
Number of rows
nrow(x) ## S4 method for signature 'PkgManifest' nrow(x) ## S4 method for signature 'SessionManifest' nrow(x)
nrow(x) ## S4 method for signature 'PkgManifest' nrow(x) ## S4 method for signature 'SessionManifest' nrow(x)
x |
A tabular data structure. |
The number of rows in the structure
List the packages installed in a switchr context (library)
packages(seed) ## S4 method for signature 'SwitchrCtx' packages(seed)
packages(seed) ## S4 method for signature 'SwitchrCtx' packages(seed)
seed |
A switchr context |
An object representing the information in printed sessionInfo() output
Parse text output from printing SessionInfo objects
parseSessionInfoString(string)
parseSessionInfoString(string)
string |
The text output from sessionInfo() |
Construct a PkgManifest, which can be installed from using install_packages
PkgManifest( manifest = ManifestRow(...), dep_repos = defaultRepos(), ..., dl_method )
PkgManifest( manifest = ManifestRow(...), dep_repos = defaultRepos(), ..., dl_method )
manifest |
The manifest (data.frame) of packages and their locations |
dep_repos |
A list of traditional pkg repositories which can contain dependencies
for the packages listed in |
... |
Arguments passed to |
dl_method |
Download method. Ignored unless |
If a package is found in both the manifest dataf.frame and the dependency repositories, the version in the manifest will always take precidence within the switchr framework.
Get or set the package name associated with a Package Source
pkgname(x) ## S4 method for signature 'PkgSource' pkgname(x) pkgname(x) <- value ## S4 replacement method for signature 'PkgSource' pkgname(x) <- value
pkgname(x) ## S4 method for signature 'PkgSource' pkgname(x) pkgname(x) <- value ## S4 replacement method for signature 'PkgSource' pkgname(x) <- value
x |
A source |
value |
The new pkgname |
An object representing the source location of a package. This is a virtual used exlusively through its subclasses, which are used to differentiate the different types of package source locations.
Publish a package or session manifest to file.
publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'PkgManifest,character' publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'SessionManifest,character' publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'missing,ANY' publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'SwitchrCtx,ANY' publishManifest(manifest, dest = "./pkg_manifest.rman", ...)
publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'PkgManifest,character' publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'SessionManifest,character' publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'missing,ANY' publishManifest(manifest, dest = "./pkg_manifest.rman", ...) ## S4 method for signature 'SwitchrCtx,ANY' publishManifest(manifest, dest = "./pkg_manifest.rman", ...)
manifest |
The object to save as a serialized package or session manifest. Defaulst to the currently in use switchr library. A session manifest will be generated by libManifest as necessary. |
dest |
The destination |
... |
Unused |
The name of the file written
Remove a switchr library and update the manifest of existing libraries
removeLib(name = NULL, repos = NULL, compEnv = NULL, fromStack = FALSE)
removeLib(name = NULL, repos = NULL, compEnv = NULL, fromStack = FALSE)
name |
The name of the switchr library to remove |
repos |
the url used to seed the library |
compEnv |
a SwitchrCtx representing the library to remove |
fromStack |
Whether the library should be removed if it currently appears in the Context stack Defaults to false. |
NULL, called for its side-effect of removing/destroying a switchr library
Only one of name
, repos
and compEnv
should be
specified. An error will be thrown otherwise.
## Not run: removeLib("mylibrary") ## End(Not run)
## Not run: removeLib("mylibrary") ## End(Not run)
An object that represents a subset of packages available in a repo. When switched to, switchr will default to only installing the specified packages, rather than all packages in the repository.
RepoSubset(repos, pkgs, default_name)
RepoSubset(repos, pkgs, default_name)
repos |
The traditional repositories to select the packages from |
pkgs |
The packages included in the subset |
default_name |
The default name to use when the RepoSubset is used to seed a switchr context |
Create a Pkg manifest which points to tarballs representing the cohort of packages associated with a particular release of R
rVersionManifest(vers, curr_avail = available.packages())
rVersionManifest(vers, curr_avail = available.packages())
vers |
The version of R to create a manifest for |
curr_avail |
The output from available.packages(). Used to identify whether the necessary version is in the CRAN archive or normal repository |
A SessionManifest object
Gabriel Becker
"Gabor Csardi" (2014). crandb: Query the unofficial CRAN metadata database. R package version 1.0.0. https://github.com/metacran/crandb
Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01
## Not run: man = rVersionManifest("3.1.1") man ## End(Not run)
## Not run: man = rVersionManifest("3.1.1") man ## End(Not run)
A manifest which includes both a PkgManifest containing package source information, and a data.frame defining a filter with exact versions of some or all packages
SessionManifest(manifest, versions = character())
SessionManifest(manifest, versions = character())
manifest |
A PkgManifest |
versions |
A data.frame with 2 columns: name and version, or a named character vector. In the case of a character vector, the names are taken to be package names |
A SessionManifest object
Set or Retrieve the shell initialization script for an object
sh_init_script(x) ## S4 method for signature 'SwitchrParam' sh_init_script(x) sh_init_script(x) <- value ## S4 replacement method for signature 'SwitchrParam' sh_init_script(x) <- value
sh_init_script(x) ## S4 method for signature 'SwitchrParam' sh_init_script(x) sh_init_script(x) <- value ## S4 replacement method for signature 'SwitchrParam' sh_init_script(x) <- value
x |
An object associated with a SwitchrParam object |
value |
The new value. |
This is intended to stop intermittent install failures due to network drive latency interacting with git commands
shell_timing(x) ## S4 method for signature 'SwitchrParam' shell_timing(x) shell_timing(x) <- value ## S4 replacement method for signature 'SwitchrParam' shell_timing(x) <- value
shell_timing(x) ## S4 method for signature 'SwitchrParam' shell_timing(x) shell_timing(x) <- value ## S4 replacement method for signature 'SwitchrParam' shell_timing(x) <- value
x |
A SwitchrParam object |
value |
The new number of seconds to wait |
When getting, the number of seconds to wait, when setting, a new, updated SwitchrParam object.
accessor for subdirectory.
subdir(x) ## S4 method for signature 'PkgSource' subdir(x) subdir(x) <- value ## S4 replacement method for signature 'PkgSource' subdir(x) <- value
subdir(x) ## S4 method for signature 'PkgSource' subdir(x) subdir(x) <- value ## S4 replacement method for signature 'PkgSource' subdir(x) <- value
x |
An object associated with a subdirectory, typically a PkgSource |
value |
The new subdirectory to associate with the object |
A convenience function to switch back to the previously used computing environment.
switchBack()
switchBack()
The base packages, as well as switchr and its dependencies.
switchDeps
switchDeps
An object of class character
of length 20.
Get or set the base directory for switchr libraries
switchrBaseDir(value)
switchrBaseDir(value)
value |
A new value for the base directory |
If value
is missing, the current base directory
is returned. Otherwise the value
is set as the default directory
and returned.
A constructor for class SwitchrCtx, represenging a switchr installed-package library.
SwitchrCtx(name, libpaths, exclude.site = TRUE, seed = NULL)
SwitchrCtx(name, libpaths, exclude.site = TRUE, seed = NULL)
name |
The name to associate with the context |
libpaths |
The directories where the installed packages are located |
exclude.site |
Should the current site library be included in the context when it is switched to (TRUE) ' |
seed |
An object representing the list of packages the switchr context was seeded with. |
Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01
Get or set packages which should NOT be unloaded when flushing the system, e.g., when switching between libraries.
switchrDontUnload(value, add = TRUE)
switchrDontUnload(value, add = TRUE)
value |
The packages to not unload when switching libraries. |
add |
Should |
By default switchr will not attempt to unload any base packages,
itself, or any of its dependencies. Attempting to unload any of these
packages (e.g. add=FALSE
) will result in undefined behavior and
is not recommended.
Generate a manifest of all currently available (existing) swtichr libraries.
switchrManifest()
switchrManifest()
A data.frame with information about the located switchr libraries
This function reads cached metadata from the current switchr base
directory (~/.switchr by default). This cache is updated whenever
the switchr framework is used to create or destroy a switchr library,
but will not be updated if one is added or removed manually. In
such cases updateManifest
must be called first
Set whether or not ANY packages are unloaded when switching libraries.
switchrNoUnload(value)
switchrNoUnload(value)
value |
A logical value, or missing to return the current option |
This should be set to TRUE when using switchr in the context of dynamic documents such as .Rnw and .Rmd files.
A logical indicating whether or not calling flushSession
will skipped during the library switching process.
A contstructor for a SwitchrParam object representing a number of common parameters understood by the switchr framework
SwitchrParam( logfun = function(...) NULL, shell_init = character(), archive_timing = 2, archive_retries = 2, dl_method, shell_timing = 1 )
SwitchrParam( logfun = function(...) NULL, shell_init = character(), archive_timing = 2, archive_retries = 2, dl_method, shell_timing = 1 )
logfun |
The function to be called to write to logs |
shell_init |
A character containing the location of a shell script to be sourced before any system commands. |
archive_timing |
The timeout after downloading a package from the CRAN Archive. |
archive_retries |
Number of times to retry retrieving a package from the CRAN Archive. |
dl_method |
The download method to use when retrieve package
source files. See |
shell_timing |
numeric. The numer of seconds to wait between certain shell commands. Defaults to 1, this should only need to be changed in the case of, e.g., networked drive latency issues. |
A SwitchrParam object.
Gabriel Becker
Switch to a different computing environment (set of installed R packages and library location paths for new pkg installs)
switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,character' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,SwitchrCtx' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,missing' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'SwitchrCtx,ANY' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,RepoSubset' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,PkgManifest' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,SessionManifest' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... )
switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,character' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,SwitchrCtx' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,missing' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'SwitchrCtx,ANY' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,RepoSubset' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,PkgManifest' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... ) ## S4 method for signature 'character,SessionManifest' switchTo( name, seed = NULL, reverting = FALSE, ignoreRVersion = FALSE, exclude.site = TRUE, ... )
name |
The name associated (or to associate) with the computing environment. |
seed |
The seed, indicating packages to install into a newly created package library No effect if the library already exists |
reverting |
Indicates whether we are reverting to the environment in use before the current one. Typically not set directly by the user. |
ignoreRVersion |
Should the R version in use be ignored when checking for existing computing environmeSnts. This is experimental. |
exclude.site |
Should the Site library be excluded when creating
and switching to the specified library. Defaults to |
... |
Passed directly to |
If switchr does not now about the specified computing environment, a new one
will be created via installCompEnv. This includes
creating a directory under the switchr base directory and installing
packages into it. See installCompEnv
for more details.
This function has the side effect of unloading all loaded
packages (other than base packages, GRAN or GRANBAse, switchr itself, and
switchr's dependencies) and the associated DLLs. It also changes the library
location R will use to search for packages, e.g. when you call
library
.
This means you will have to reinstall packages after switching, which is important and intended (e.g. when switching to using Bioc devel from Bioc release).
Invisibly returns the SwitchrCtx object representing the new computing environment
By default, this process involves a call to flushSession
which will
attempt to unload all loaded packages. While some support of configuring
what is unloaded is provided via switchrDontUnload
, it is recommended
that you turn this feature entirely off via switchrNoUnload(TRUE)
when
using switchr within dyanmic documents (.Rnw/.Rmd files, etc), particularly
when using the knitr package.
Becker G, Barr C, Gentleman R, Lawrence M; Enhancing Reproducibility and Collaboration via Management of R Package Cohorts. Journal of Statistical Software, 81(1). 2017. doi: 10.18637/jss.v082.i01
## Not run: switchTo("mynewlibrary") switchBack() fdman = GithubManifest("gmbecker/fastdigest") switchTo("fastdigestlib", seed = fdman) ## End(Not run)
## Not run: switchTo("mynewlibrary") switchBack() fdman = GithubManifest("gmbecker/fastdigest") switchTo("fastdigestlib", seed = fdman) ## End(Not run)
Run a system command with an optional intialization script (e.g. a .bashrc sourced first).
system_w_init( cmd, dir, init = character(), args = NULL, env = NULL, ..., param = SwitchrParam() )
system_w_init( cmd, dir, init = character(), args = NULL, env = NULL, ..., param = SwitchrParam() )
cmd |
The text of the command. Must be length 1. |
dir |
The directory that the command should be executed in. The working directory will be temporarily changed to this dir, but will be changed back upon exit of system_w_init. |
init |
(optional) a character value indicating the location of an initialization shell script. |
args |
character. Arguments to be passed to the command |
env |
character. Environmental variables to be set when running the command |
... |
additional parameters passed directly to |
param |
A SwitchrParam object. The shell initialization
script associated with this object is used when |
Depends, see system
for details.
Update an existing repository by reading the PACKAGES file and only processing built package tarballs which do not match existing entries.
update_PACKAGES
can be much faster than
write_PACKAGES
for small-moderate changes to large
repository indexes.
update_PACKAGES( dir = ".", fields = NULL, type = c("source", "mac.binary", "win.binary"), verbose = dryrun, unpacked = FALSE, subdirs = FALSE, latestOnly = TRUE, addFiles = FALSE, strict = TRUE, dryrun = FALSE, logfun = message, ... )
update_PACKAGES( dir = ".", fields = NULL, type = c("source", "mac.binary", "win.binary"), verbose = dryrun, unpacked = FALSE, subdirs = FALSE, latestOnly = TRUE, addFiles = FALSE, strict = TRUE, dryrun = FALSE, logfun = message, ... )
dir |
See |
fields |
See |
type |
See |
verbose |
Should informative messages be displayed throughout
the proccess. Defaults to the value of |
unpacked |
See |
subdirs |
See |
latestOnly |
See |
addFiles |
See |
strict |
logical. Should 'strict mode' be used when checking
existing PACKAGES entries. See details. Defaults to
|
dryrun |
logical. Should should the necessary updates be
calculated but NOT applied. (default |
logfun |
function. If |
... |
Additional arguments to |
Throughout this section, package tarball is taken to mean a tarball
file in dir
whose name can be interpreted as
<package>_<version>.<ext>
(or that is pointed to by the File
field of an existing PACKAGES entry). Novel package tarballs are
those which do not match an existing PACKAGES
file entry.
update_PACKAGES
avoids (re)processing package tarballs in cases where
a PACKAGES
file entry already exists and appears to remain valid. The
logic for detecting still-valid entries is as follows:
Currently update_PACKAGES
calls directly down to
write_PACKAGES
(and thus no speedup should be expected)
if any of the following conditions hold:
No PACKAGES
file exists under dir
unpacked
is TRUE
subdirs
is anything other than FALSE
fields
is not NULL
and one or more specified fields
are not present in the existing PACKAGES
file
All package tarballs whose last modify times are later than that
of the existing PACKAGES file are considered novel and no attempt
is made to identify or retain any corresponding PACKAGES
entries. Similarly, all PACKAGES
entries which have no
corresponding package tarball are definitionally invalid.
When strict = TRUE
, PACKAGES
entries which appear to
match a package tarball are confirmed via MD5 checksum; those that
pass are retained as valid. All novel package tarballs are fully
proccessed by the standard write_PACKAGES
machinery, and
the resulting entries are added. Finally, if latestOnly =
TRUE
, package-version pruning is performed across the entries.
When strict = FALSE
, package tarballs are assumed to encode
correct metadata in their filenames. PACKAGES
entries which
appear to match a package tarball are retained as valid (No MD5sum
checking occurs). If latestOnly = TRUE
, package-version
pruning across the full set of retained entries and novel package
tarballs before the processing of the novel tarballs, at
significant computational and time savings in some
situations. After the optional pruning, any relevant novel package
tarballs are processed via write_PACKAGES
and added to the
set of retained entries.
After the above process concludes, the final database of
PACKAGES
entries is written to all three PACKAGES files,
overwriting the existing files.
While both strict and nonstrict modes offer speedups when updating small percentages of large repositories, non-strict mode is much faster and is recommended in situations where the assumptions it makes are safe.
Gabriel Becker
Update the cached information regarding available switchr libraries.
updateManifest()
updateManifest()
NULL, used for it's side-effect of updating the switchr library metadata cache.
Get or set the the versions information in a SessionManifest
versions_df(x) ## S4 method for signature 'SessionManifest' versions_df(x) versions_df(x) <- value ## S4 replacement method for signature 'SessionManifest' versions_df(x) <- value
versions_df(x) ## S4 method for signature 'SessionManifest' versions_df(x) versions_df(x) <- value ## S4 replacement method for signature 'SessionManifest' versions_df(x) <- value
x |
An object containing package version information |
value |
A data.frame of package version information. |