From 165e88a6602aa572a644e21b484a732f74f9f265 Mon Sep 17 00:00:00 2001 From: pat-s Date: Fri, 26 Jul 2024 11:06:53 +0200 Subject: [PATCH] debug --- .woodpecker/build.yaml | 4 ++-- R/build_binaries.R | 5 +++++ R/packages_index.R | 16 ++++++++++++---- R/upload.R | 4 ++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml index 013a960..051dfd7 100644 --- a/.woodpecker/build.yaml +++ b/.woodpecker/build.yaml @@ -29,12 +29,12 @@ steps: # download latest package version (avoid having to rebuild image every time) # rscript_startup arg: required to pass down global option to future workers https://github.com/HenrikBengtsson/future/issues/134#issuecomment-2245666169 - git clone https://pat-s:$$git_ro_token@git.devxy.io/devxy/arm64-r-binaries.git && cd arm64-r-binaries - - R -q -e 'install.packages(".", repos = NULL, quiet = FALSE); packageVersion("rBinaries")' + - R -q -e 'install.packages(".", repos = NULL, quiet = TRUE); packageVersion("rBinaries")' # manually install some packages into the cache so that some builds don't fail # Hmisc -> ABCanalysis # - R -q -e 'pak::pak("Hmisc")' - mkdir -p /mnt/cache/pkgcache /mnt/cache/R-pkgs - - R -q -e 'options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = "error"); pkgs = tools::CRAN_package_db()[[1]][3:3]; library(rBinaries); future::plan("multisession", workers = 4, rscript_startup = quote(options(crayon.enabled = TRUE))); foo = lapply(pkgs, function(x) build_binary_package(x, build_for_minor=FALSE, debug = FALSE, force = TRUE))' + - R -q -e 'options(crayon.enabled = TRUE, Ncpus = 4, future.globals.onReference = "error"); pkgs = tools::CRAN_package_db()[[1]][3:3]; library(rBinaries); future::plan("multisession", workers = 4, rscript_startup = quote(options(crayon.enabled = TRUE))); foo = lapply(pkgs, function(x) build_binary_package(x, build_for_minor=FALSE, debug = TRUE, force = TRUE))' backend_options: kubernetes: resources: diff --git a/R/build_binaries.R b/R/build_binaries.R index 9eb60dc..460af44 100644 --- a/R/build_binaries.R +++ b/R/build_binaries.R @@ -195,6 +195,11 @@ build_single_tag <- function( # bytes to MB in binary format file_size <- round(as.numeric(fs::file_size(sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag))) / (1024^2), 2) + if (debug) { + cli::cli_alert_warning("DEBUG: total_build_time: {total_build_time}") + cli::cli_alert_warning("DEBUG: file_size: {file_size}") + } + # skip DB connection if package already exists if (file.exists(sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag))) { con <- DBI::dbConnect(RPostgres::Postgres(), diff --git a/R/packages_index.R b/R/packages_index.R index 07c900a..6eee6a2 100644 --- a/R/packages_index.R +++ b/R/packages_index.R @@ -8,8 +8,6 @@ add_to_package_index <- function( bucket = "devxy-arm64-r-binaries", codename = NULL, r_minor_version = NULL, build_for_minor = FALSE) { - cli::cli_h2("Building package index") - codename <- set_codename(codename) if (is.null(r_minor_version)) { r_minor_version <- sub("R version (\\d+\\.\\d+).*", "\\1", R.Version()$version.string) @@ -40,15 +38,25 @@ add_to_package_index <- function( cranlike::add_PACKAGES(file_names, local_bin_dir) cli::cli_alert("{.fun create_package_index}: Uploading PACKAGES* files to S3.") - purrr::walk2( + dummy <- purrr::walk2( sprintf("%s/%s", local_bin_dir, c("PACKAGES.db", "PACKAGES.rds", "PACKAGES.gz")), sprintf("%s/%s", remote_bin_dir, c("PACKAGES.db", "PACKAGES.rds", "PACKAGES.gz")), \(x, y) s3fs::s3_file_upload(x, y, overwrite = TRUE) ) - s3fs::s3_file_upload(sprintf("%s/PACKAGES", local_bin_dir), sprintf("%s/PACKAGES", remote_bin_dir), overwrite = TRUE) + + pkgs_upload_local <- sprintf("%s/PACKAGES", local_bin_dir) + pkgs_upload_remote <- sprintf("%s/PACKAGES", remote_bin_dir) + + if (debug) { + cli::cli_alert_danger("DEBUG: PACKAGES UPLOAD local dir: {pkgs_upload_local}") + cli::cli_alert_danger("DEBUG: PACKAGES UPLOAD remote dir: {pkgs_upload_remote}") + } + + dummy <- s3fs::s3_file_upload(pkgs_upload_local, pkgs_upload_remote, overwrite = TRUE) # s3fs::s3_file_upload( # sprintf("%s/%s", local_bin_dir, c("PACKAGES", "PACKAGES.db", "PACKAGES.rds", "PACKAGES.gz")), # sprintf("%s", remote_bin_dir, c("PACKAGES", "PACKAGES.db", "PACKAGES.rds", "PACKAGES.gz")), # overwrite = TRUE # ) + return(invisible(TRUE)) } diff --git a/R/upload.R b/R/upload.R index 5b3ae7d..0ade4ac 100644 --- a/R/upload.R +++ b/R/upload.R @@ -19,8 +19,8 @@ upload_single_binary_to_s3 <- function( remote_bin_path <- set_bin_path(r_minor_version, build_for_minor, local_build_root = bucket, codename) if (debug) { - cli::cli_alert_danger("DEBUG: dir_out_bin: {dir_out_bin}, codename: {codename}") - cli::cli_alert_danger("DEBUG: Body: {sprintf('%s/%s', dir_out_bin, tarball_name)}") + cli::cli_alert_danger("DEBUG: local_bin_path: {local_bin_path}") + cli::cli_alert_danger("DEBUG: remote_bin_path: {remote_bin_path}") } s3fs::s3_file_system(