Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install R packages in topological order in their dependency graph #465

Open
tkilias opened this issue Jan 18, 2022 · 0 comments
Open

Install R packages in topological order in their dependency graph #465

tkilias opened this issue Jan 18, 2022 · 0 comments
Labels
feature Product feature

Comments

@tkilias
Copy link
Collaborator

tkilias commented Jan 18, 2022

Background:

  • We install R packages via install_version, which only can install one package and its dependencies at the time
  • If we install the packages in arbitrary order, we might need to reinstall them later, because the version which was installed isn't the requested and sometimes this upgrade doesn't work
  • So installing them in topological order improve install speed and correctness
  • We have yet to decide, if this will be part of the install script or if we preprocess the package files, because we need at least miniCRAN and igraph for this and both take time to install.

Here is an example, how to reorder a package list:


install.packages("miniCRAN")
install.packages("igraph")

library(miniCRAN)
library(igraph)

input_file <- "/build_info/packages/flavor_base_deps_r/cran_packages"
input <- read.table(file = input_file, sep = "|", comment.char = "#")
packages <- input[,1]
dep_graph <- makeDepGraph(
  packages,
  repos = c(CRAN = getOption("minicran.mran")),
  type = "source",
  suggests = FALSE,
  enhances = FALSE,
  includeBasePkgs = FALSE,
)
sorted_vertices <- topo_sort(dep_graph)
sorted_packages <- as_ids(sorted_vertices)
output <- data.frame(input)
pos <- which(sorted_packages %in% input[,1])
filtered_sorted_packages <- sorted_packages[pos]
reordering = match(filtered_sorted_packages,input[,1])
output <- input[reordering,]
write.table(output, file = "/tmp/toposort", quote = FALSE, sep="|", col.names=FALSE, row.names=FALSE)
@tkilias tkilias added the feature Product feature label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Product feature
Projects
None yet
Development

No branches or pull requests

1 participant