Title: | Install R packages from Particular Git Branches |
---|---|
Description: | When developing multiple dependent packages, it is often useful to introduce development stages (devel, pre-release, release) that synchronize these packages. This package provides an implementation of development stages via branch naming rules. It defines RStudio addins that allow to install the matching upstream and downstream dependencies. |
Authors: | Adrian Waddell [aut, cre], Maximilian Mordig [aut], Nikolas Burkoff [aut] |
Maintainer: | Adrian Waddell <[email protected]> |
License: | file LICENSE |
Version: | 0.3.1.9001 |
Built: | 2024-12-06 03:11:07 UTC |
Source: | https://github.com/openpharma/staged.dependencies |
Build, check and install internal dependencies
build_check_install( dep_structure, install_direction = "all", steps = c("build", "check", "install"), rcmd_args = list(check = c("--no-multiarch", "--with-keep.source", "--install-tests")), artifact_dir = tempfile(), install_external_deps = TRUE, upgrade = "never", package_list = NULL, dry = FALSE, verbose = 1, ... )
build_check_install( dep_structure, install_direction = "all", steps = c("build", "check", "install"), rcmd_args = list(check = c("--no-multiarch", "--with-keep.source", "--install-tests")), artifact_dir = tempfile(), install_external_deps = TRUE, upgrade = "never", package_list = NULL, dry = FALSE, verbose = 1, ... )
dep_structure |
( |
install_direction |
"upstream", "downstream" or "all"; which packages to install (according to dependency structure). By default this is only "upstream" |
steps |
( |
rcmd_args |
( |
artifact_dir |
( |
install_external_deps |
logical to describe whether to install
external dependencies of package using |
upgrade |
argument passed to |
package_list |
( |
dry |
( |
verbose |
( |
... |
Arguments passed on to
|
list with entries
artifact_dir: artifact_dir
directory with log files
pkg_actions: data.frame
of performed actions
## Not run: x <- dependency_table(project = ".", verbose = 1) build_check_install(x, steps = c("build", "check"), verbose = 1) build_check_install(x, artifact_dir = "../output") ## End(Not run)
## Not run: x <- dependency_table(project = ".", verbose = 1) build_check_install(x, steps = c("build", "check"), verbose = 1) build_check_install(x, artifact_dir = "../output") ## End(Not run)
Installs downstream R packages as specified in a
dependency_structure
object and then runs
rcmdcheck
(R CMD check
) on the downstream dependencies.
check_downstream( dep_structure, distance = NULL, check_args = c("--no-multiarch", "--with-keep.source", "--install-tests"), only_tests = FALSE, install_external_deps = TRUE, upgrade = "never", package_list = NULL, dry = FALSE, verbose = 1, ... )
check_downstream( dep_structure, distance = NULL, check_args = c("--no-multiarch", "--with-keep.source", "--install-tests"), only_tests = FALSE, install_external_deps = TRUE, upgrade = "never", package_list = NULL, dry = FALSE, verbose = 1, ... )
dep_structure |
( |
distance |
( |
check_args |
( |
only_tests |
( |
install_external_deps |
logical to describe whether to install
external dependencies of package using |
upgrade |
argument passed to |
package_list |
( |
dry |
( |
verbose |
( |
... |
Arguments passed on to
|
data.frame
of performed actions
## Not run: x <- dependency_table(project = ".", verbose = 1) check_downstream(x, verbose = 1) check_downstream(x, verbose = 1, only_test = TRUE, check_args = c("--no-manual")) ## End(Not run)
## Not run: x <- dependency_table(project = ".", verbose = 1) check_downstream(x, verbose = 1) check_downstream(x, verbose = 1, only_test = TRUE, check_args = c("--no-manual")) ## End(Not run)
Check & install downstream job
check_downstream_job( project = ".", verbose = 1, create_args = list(renv_profile = Sys.getenv("RENV_PROFILE")), ... )
check_downstream_job( project = ".", verbose = 1, create_args = list(renv_profile = Sys.getenv("RENV_PROFILE")), ... )
project |
( |
verbose |
( |
create_args |
|
... |
Arguments passed on to
|
check_downstream
## Not run: check_downstream_job(check_args = Sys.getenv("RCMDCHECK_ARGS")) check_downstream_job( check_args = Sys.getenv("RCMDCHECK_ARGS"), list(create_arg = list(ref = "6_makegraph@main")) ) check_downstream_job(only_tests = TRUE) ## End(Not run)
## Not run: check_downstream_job(check_args = Sys.getenv("RCMDCHECK_ARGS")) check_downstream_job( check_args = Sys.getenv("RCMDCHECK_ARGS"), list(create_arg = list(ref = "6_makegraph@main")) ) check_downstream_job(only_tests = TRUE) ## End(Not run)
Checks that the staged dependency yamls are consistent with the dependencies listed in the DESCRIPTION files
check_yamls_consistent(dep_structure, skip_if_missing_yaml = FALSE)
check_yamls_consistent(dep_structure, skip_if_missing_yaml = FALSE)
dep_structure |
|
skip_if_missing_yaml |
|
This function explicitly checks that for all packages in the
dependency_structure
object: all upstream and downstream packages specified
in each yaml file are found in the appropriate package DESCRIPTION file
NULL if successful. An error is thrown if inconsistencies found
## Not run: x <- dependency_table(project = ".") check_yamls_consistent(x) ## End(Not run)
## Not run: x <- dependency_table(project = ".") check_yamls_consistent(x) ## End(Not run)
Use this function to clear the package cache of some
or all repositories (depending on pattern
) if
the git
operations fail.
clear_cache(pattern = "*")
clear_cache(pattern = "*")
pattern |
files to remove, see |
## Not run: clear_cache() clear_cache("*elecinfra*") ## End(Not run)
## Not run: clear_cache() clear_cache("*elecinfra*") ## End(Not run)
Create dependency structure of your package collection
dependency_table( project = ".", project_type = c("local", "repo@host")[1], ref = NULL, local_repos = if ((project_type) == "local") get_local_pkgs_from_config() else NULL, direction = "all", fallback_branch = "main", renv_profile = NULL, verbose = 1 )
dependency_table( project = ".", project_type = c("local", "repo@host")[1], ref = NULL, local_repos = if ((project_type) == "local") get_local_pkgs_from_config() else NULL, direction = "all", fallback_branch = "main", renv_profile = NULL, verbose = 1 )
project |
( |
project_type |
( |
ref |
( |
local_repos |
( |
direction |
( |
fallback_branch |
( |
renv_profile |
( |
verbose |
( |
dependency_structure
An S3 object with the following items:
project
argument used to create
the object (absolute path if project_type
is local
project_type
used to create object
The R package name of code in the project
directory
data.frame
contain one row per r package discovered, with the
following rows package_name
, type
(current
, upstream
, downstream
or other
),
distance
(minimum number of steps from current_pkg
), ref
, repo
, host
, sha
cache_dir
, accessible
, installable
and install_index
(the order to install the packages).
Note some items are are suppressed when printing the object
list
with three elements, upstream_deps
is the graph where edges point from a package
to its upstream dependencies. They are ordered in installation order. The
downstream_deps
list is the graph with the edge direction flipped,
and is ordered in reverse installation order. external
contains the external
R packages found in the description files of the internal packages. It is a dataframe
of the form returned by desc::desc_get_deps
direction
argument used to create object
named list
containing the json of the renv.lock files for the chosen profile for
each repo. An entry to the list is NULL
if a repos does not have the required lock file
## Not run: dependency_table(verbose = 1) dependency_table( project = "openpharma/stageddeps.food@https://github.com", project_type = "repo@host", ref = "main" ) x <- dependency_table( project = "path/to/project", direction = c("upstream") ) print(x) plot(x) ## End(Not run)
## Not run: dependency_table(verbose = 1) dependency_table( project = "openpharma/stageddeps.food@https://github.com", project_type = "repo@host", ref = "main" ) x <- dependency_table( project = "path/to/project", direction = c("upstream") ) print(x) plot(x) ## End(Not run)
Return the git ref (tag or branch) of the repo to install given the available branches and tags.
determine_ref(ref, available_refs, fallback_branch = "main", branch_sep = "@")
determine_ref(ref, available_refs, fallback_branch = "main", branch_sep = "@")
ref |
ref we want to build |
available_refs |
data.frame with columns |
fallback_branch |
the default branch to try to use if no other matches found |
branch_sep |
separator between branches in |
A ref is either a tag or branches separated by slashes of the form name1@name2@...@nameN
.
Where separator is specified by branch_sep
argument
This function checks for an exact match for the tag if this is not found then
among the available branches, it searches in the order
name1@name2@...@nameN
, name2@name3@...@nameN
, name3@name4@...@nameN
, ..., nameN
branch/tag to choose to match feature, error if no suitable branch was provided with the type attribute "tag" or "branch"
determine_ref( "feature1", data.frame(ref = c("main", "feature1"), type = "branch") ) == structure("feature1", type = "branch") determine_ref( "feature1@devel", data.frame(ref = c("main", "devel", "feature1"), type = "branch") ) == structure("devel", type = "branch") determine_ref( ref = "fix1@feature1@devel", available_refs = data.frame( ref = c( "main", "devel", "feature1", "feature1@devel", "fix1@feature1@devel", "fix1" ), type = "branch" ) ) == structure("fix1@feature1@devel", type = "branch") determine_ref( "fix1@feature1@devel", data.frame( ref = c("main", "devel", "feature1", "feature1@devel", "fix1"), type = "branch" ) ) == structure("feature1@devel", type = "branch") determine_ref( "fix1@feature1@devel", data.frame(ref = c("main", "devel", "feature1", "fix1"), type = "branch") ) == structure("devel", type = "branch") determine_ref("feature1@release", data.frame(ref = c("main", "devel"), type = "branch")) # error because neither `feature1@release` nor `release` branch exists # determine_ref("feature1@release", data.frame(ref = c("master", "devel"), type = "branch")) # tag examples determine_ref( "v0.1", data.frame(ref = c("main", "devel", "feature1", "v0.1"), type = c(rep("branch", 3), "tag")) ) == structure("v0.1", type = "tag") determine_ref( "v0.2", data.frame(ref = c("main", "devel", "feature1", "v0.1"), type = c(rep("branch", 3), "tag")) ) == structure("main", type = "branch")
determine_ref( "feature1", data.frame(ref = c("main", "feature1"), type = "branch") ) == structure("feature1", type = "branch") determine_ref( "feature1@devel", data.frame(ref = c("main", "devel", "feature1"), type = "branch") ) == structure("devel", type = "branch") determine_ref( ref = "fix1@feature1@devel", available_refs = data.frame( ref = c( "main", "devel", "feature1", "feature1@devel", "fix1@feature1@devel", "fix1" ), type = "branch" ) ) == structure("fix1@feature1@devel", type = "branch") determine_ref( "fix1@feature1@devel", data.frame( ref = c("main", "devel", "feature1", "feature1@devel", "fix1"), type = "branch" ) ) == structure("feature1@devel", type = "branch") determine_ref( "fix1@feature1@devel", data.frame(ref = c("main", "devel", "feature1", "fix1"), type = "branch") ) == structure("devel", type = "branch") determine_ref("feature1@release", data.frame(ref = c("main", "devel"), type = "branch")) # error because neither `feature1@release` nor `release` branch exists # determine_ref("feature1@release", data.frame(ref = c("master", "devel"), type = "branch")) # tag examples determine_ref( "v0.1", data.frame(ref = c("main", "devel", "feature1", "v0.1"), type = c(rep("branch", 3), "tag")) ) == structure("v0.1", type = "tag") determine_ref( "v0.2", data.frame(ref = c("main", "devel", "feature1", "v0.1"), type = c(rep("branch", 3), "tag")) ) == structure("main", type = "branch")
List the external R packages required to be installed
get_all_external_dependencies( dep_structure, available_packages = as.data.frame(utils::available.packages()), install_direction = "upstream", package_list = NULL, from_internal_dependencies = c("Depends", "Imports", "LinkingTo", "Suggests"), from_external_dependencies = c("Depends", "Imports", "LinkingTo") )
get_all_external_dependencies( dep_structure, available_packages = as.data.frame(utils::available.packages()), install_direction = "upstream", package_list = NULL, from_internal_dependencies = c("Depends", "Imports", "LinkingTo", "Suggests"), from_external_dependencies = c("Depends", "Imports", "LinkingTo") )
dep_structure |
( |
available_packages |
( |
install_direction |
"upstream", "downstream" or "all"; which packages to install (according to dependency structure). By default this is only "upstream" |
package_list |
( |
from_internal_dependencies |
Vector chosen from |
from_external_dependencies |
Vector chosen from |
A vector of 'external' R packages required to install
the selected 'internal' packages, ordered by install order (unless from_external_dependencies
does not include "Depends"
, "Imports"
and "LinkingTo"
). The core R packages
(e.g. methods
, utils
) are not included. The output can be used with remotes::system_requirements
to extract the system requirements needed for your packages, see example below.
## Not run: x <- dependency_table("openpharma/stageddeps.electricity", project_type = "repo@host", feature = "main" ) # get external package dependencies ex_deps <- get_all_external_dependencies(x) print(ex_deps) # get system dependencies (in this case there are none) unique(unlist(lapply(ex_deps, function(pkg, ...) { remotes::system_requirements(package = pkg, ...) }, os = "ubuntu", os_release = "20.04" ))) ## End(Not run)
## Not run: x <- dependency_table("openpharma/stageddeps.electricity", project_type = "repo@host", feature = "main" ) # get external package dependencies ex_deps <- get_all_external_dependencies(x) print(ex_deps) # get system dependencies (in this case there are none) unique(unlist(lapply(ex_deps, function(pkg, ...) { remotes::system_requirements(package = pkg, ...) }, os = "ubuntu", os_release = "20.04" ))) ## End(Not run)
local_packages
Checks that all directories exist and are absolute paths.
get_local_pkgs_from_config()
get_local_pkgs_from_config()
local_packages
get_local_pkgs_from_config()
get_local_pkgs_from_config()
Given a dependency_structure
object, install the R packages
install_deps( dep_structure, install_project = TRUE, install_direction = "upstream", install_external_deps = TRUE, upgrade = "never", package_list = NULL, dry = FALSE, verbose = 1, ... )
install_deps( dep_structure, install_project = TRUE, install_direction = "upstream", install_external_deps = TRUE, upgrade = "never", package_list = NULL, dry = FALSE, verbose = 1, ... )
dep_structure |
( |
install_project |
( |
install_direction |
"upstream", "downstream" or "all"; which packages to install (according to dependency structure). By default this is only "upstream" |
install_external_deps |
logical to describe whether to install
external dependencies of package using |
upgrade |
argument passed to |
package_list |
( |
dry |
( |
verbose |
( |
... |
Additional args passed to |
data.frame
of performed actions
determine_branch
## Not run: x <- dependency_table(project = "./path/to/project") install_deps(x) # install all dependencies install_deps(x, install_direction = "all") ## End(Not run)
## Not run: x <- dependency_table(project = "./path/to/project") install_deps(x) # install all dependencies install_deps(x, install_direction = "all") ## End(Not run)
The dependencies are obtained by traversing the upstream and downstream repositories
in the package's staged dependencies yaml files starting from project
.
install_deps_app( default_repo = NULL, default_host = "https://github.com", default_ref = "main", fallback_branch = "main", run_gadget = TRUE, run_as_job = TRUE, verbose = 1, install_external_deps = TRUE, renv_profile = NULL, upgrade = "never", ... )
install_deps_app( default_repo = NULL, default_host = "https://github.com", default_ref = "main", fallback_branch = "main", run_gadget = TRUE, run_as_job = TRUE, verbose = 1, install_external_deps = TRUE, renv_profile = NULL, upgrade = "never", ... )
default_repo |
( |
default_host |
( |
default_ref |
( |
fallback_branch |
( |
run_gadget |
( |
run_as_job |
( |
verbose |
( |
install_external_deps |
logical to describe whether to install
external dependencies of package using |
renv_profile |
( |
upgrade |
argument passed to |
... |
Additional args passed to |
shiny.app
or value returned by app (executed as a gadget)
## Not run: install_deps_app("openpharma/stageddeps.food") ## End(Not run)
## Not run: install_deps_app("openpharma/stageddeps.food") ## End(Not run)
Install dependencies job
install_deps_job( project = ".", project_type = "local", verbose = 1, create_args = list(renv_profile = Sys.getenv("RENV_PROFILE")), ... )
install_deps_job( project = ".", project_type = "local", verbose = 1, create_args = list(renv_profile = Sys.getenv("RENV_PROFILE")), ... )
project |
( |
project_type |
( |
verbose |
( |
create_args |
|
... |
Arguments passed on to
|
install_deps
## Not run: install_deps_job() install_deps_job(create_args = list(ref = "6_makegraph@main")) # install all dependencies install_deps_job(create_args = list(direction = "all")) install_deps_job(dry_install = TRUE) ## End(Not run)
## Not run: install_deps_job() install_deps_job(create_args = list(ref = "6_makegraph@main")) # install all dependencies install_deps_job(create_args = list(direction = "all")) install_deps_job(dry_install = TRUE) ## End(Not run)
It adds the git SHA to the DESCRIPTION file, so that the package does not need to be installed again when the same commit is already installed.
install_repo_add_sha(repo_dir, ...)
install_repo_add_sha(repo_dir, ...)
repo_dir |
directory of repo |
... |
Additional args passed to |
Graph is a list which for each node contains a vector of child nodes in the returned list, parents appear before their children.
topological_sort(graph)
topological_sort(graph)
graph |
(named |
Implementation of Kahn algorithm with a modification to maintain the order of input elements.
vector listing parents before children
staged.dependencies:::topological_sort(list(A = c(), B = c("A"), C = c("B"), D = c("A"))) staged.dependencies:::topological_sort(list(D = c("A"), A = c(), B = c("A"), C = c("B"))) staged.dependencies:::topological_sort(list(D = c("A"), B = c("A"), C = c("B"), A = c())) ## Not run: # cycle topological_sort(list(A = c("B"), B = c("C", "A"), C = c())) ## End(Not run)
staged.dependencies:::topological_sort(list(A = c(), B = c("A"), C = c("B"), D = c("A"))) staged.dependencies:::topological_sort(list(D = c("A"), A = c(), B = c("A"), C = c("B"))) staged.dependencies:::topological_sort(list(D = c("A"), B = c("A"), C = c("B"), A = c())) ## Not run: # cycle topological_sort(list(A = c("B"), B = c("C", "A"), C = c())) ## End(Not run)
Using the existing stage_dependencies yaml file 'graph' to define internal dependencies, update the project yaml file to include to include all direct (i.e. distance 1) upstream and downstream repos
update_with_direct_deps(dep_structure)
update_with_direct_deps(dep_structure)
dep_structure |
|
Functions to set and remove the option parameter verbose_level_staged.deps
.
It can assume integer values between c(0, 1, 2)
. This will set this variable
as an option with options()
and getOption()
.
verbose_sd_set(verbose = 1) verbose_sd_get() verbose_sd_rm()
verbose_sd_set(verbose = 1) verbose_sd_get() verbose_sd_rm()
verbose |
( |
verbose_sd_set(2) verbose_sd_get() # 2, the inserted value verbose_sd_rm() verbose_sd_get() # 1, the default
verbose_sd_set(2) verbose_sd_get() # 2, the inserted value verbose_sd_rm() verbose_sd_get() # 1, the default