Skip to content

Commit

Permalink
feat(benchmark): Simplify package installs - part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
RasmusSkytte committed Jun 10, 2024
1 parent 1ff215a commit eebcb76
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions data-raw/benchmark.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
withr::local_options("odbc.batch_rows" = 1000)

# Install extra dependencies
lib_paths_default <- .libPaths()
pak::pkg_install("jsonlite")
pak::pkg_install("microbenchmark")

Expand All @@ -21,25 +22,25 @@ for (version in c("CRAN", "main", "branch")) {
version == "branch" ~ glue::glue("ssi-dk/SCDB@{sha}")
)

lib_path <- dplyr::case_when(
lib_dir <- dplyr::case_when(
version == "CRAN" ~ "SCDB",
version == "main" ~ "ssi-dk-SCDB",
version == "branch" ~ glue::glue("ssi-dk-SCDB-{sha}")
)

dir.create(lib_path, recursive = TRUE, showWarnings = FALSE)
lib_path <- here::here("installations", lib_dir)
dir.create(lib_path, showWarnings = FALSE)

# Install the missing packages
.libPaths(lib_path)
.libPaths(c(lib_path, lib_paths_default))
pak::lockfile_create(source, "SCDB.lock")
jsonlite::fromJSON("SCDB.lock")$packages$ref
purrr::discard(rlang::is_installed) |>
pak::pkg_install(lib = lib_path)

missing <- jsonlite::fromJSON("SCDB.lock")$packages$ref |>
purrr::discard(rlang::is_installed)
if (length(missing) > 0) pak::pkg_install(missing, lib = lib_path)
}


# Return early if no backend is defined
# Return early if no back-end is defined
if (identical(Sys.getenv("CI"), "true") && identical(Sys.getenv("BACKEND"), "")) {
message("No backend defined, skipping benchmark!")
} else {
Expand Down

0 comments on commit eebcb76

Please sign in to comment.