From 8c7863c364cb7ebbbf25f4ec1e6968a78d90f31b Mon Sep 17 00:00:00 2001 From: Paul Hoffman Date: Thu, 9 May 2024 17:25:11 -0400 Subject: [PATCH] [r/ci] Utilize pin of tiledb-r during install (#2540) * [r/ci] Utilize pin of tiledb-r during install Update `r-ci.yml` to respect the doublepin of tiledb-r in `DESCRIPTION`; this is accomplished by doing the following: - setting environment variable `R_REMOTES_UPGRADE` to `"never"` to prevent upgrading of dependencies in `tools/r-ci.sh install_all` - setting `tiledb-inc.r-universe.dev` as an additional repo for installing dependencies - parsing `apis/r/DESCRIPTION` to find constraints on tiledb-r - searching through all repos to find all accessible versions of tiledb-r - identifying the version of tiledb-r that matches our constraints - installing upstream dependencies of tiledb-r from all accessible repos - installing the correctly-constrained version of tiledb-r * Minor fixes * Minor fixes * [r] Suppress Warnings on SOMA -> `Seurat` Outgestion (#2539) SeuratObject v5.0.2 throws a warning when the layer requested does not exist. During SOMA -> `Seurat` outgestion, this occurs when running `SeuratObject::.CalcN` eg. ```r > obj <- query$to_seurat(X_layers = c('data' = 'data')) Warning: Layer counts isn't present in the assay object; returning NULL ``` Since the results of `.CalcN()` should already exist in the SOMA, we can disable this processing and suppress the warning * Move installation of tiledb-r into standalone R script --- .github/workflows/r-ci.yml | 20 ++++++++++++- apis/r/DESCRIPTION | 2 +- apis/r/NEWS.md | 1 + apis/r/R/SOMAExperimentAxisQuery.R | 2 ++ apis/r/tools/install-tiledb-r.R | 45 ++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 apis/r/tools/install-tiledb-r.R diff --git a/.github/workflows/r-ci.yml b/.github/workflows/r-ci.yml index 024e23921c..c107f05d18 100644 --- a/.github/workflows/r-ci.yml +++ b/.github/workflows/r-ci.yml @@ -16,6 +16,7 @@ env: COVERAGE_TOKEN: ${{ secrets.CODECOV_TOKEN }} _R_CHECK_TESTS_NLINES_: 0 CATCHSEGV: "TRUE" + R_REMOTES_UPGRADE: "never" jobs: ci: @@ -52,6 +53,23 @@ jobs: - name: Bootstrap run: cd apis/r && tools/r-ci.sh bootstrap + - name: Set additional repositories (macOS) + if: ${{ matrix.os != 'ubuntu-latest' }} + run: echo 'options(repos = c("https://tiledb-inc.r-universe.dev", getOption("repos")))' | tee -a ~/.Rprofile + + - name: Set additional repositories (Linux) + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + rversion <- paste(strsplit(as.character(getRversion()), split = '\\.')[[1L]][1:2], collapse = '.') + codename <- system('. /etc/os-release; echo ${VERSION_CODENAME}', intern = TRUE) + repo <- "https://tiledb-inc.r-universe.dev" + (opt <- sprintf('options(repos = c("%s/bin/linux/%s/%s", "%s", getOption("repos")))', repo, codename, rversion, repo)) + cat(opt, "\n", file = "~/.Rprofile", append = TRUE) + shell: Rscript {0} + + - name: Install tiledb-r + run: cd apis/r && Rscript tools/install-tiledb-r.R + - name: Install BioConductor package SingleCellExperiment run: cd apis/r && tools/r-ci.sh install_bioc SingleCellExperiment @@ -82,7 +100,7 @@ jobs: # run: cd apis/r && Rscript -e "options(bspm.version.check=TRUE); install.packages('tiledb', repos = c('https://eddelbuettel.r-universe.dev/bin/linux/jammy/4.3/', 'https://cloud.r-project.org'))" - name: Dependencies - run: cd apis/r && tools/r-ci.sh install_all + run: cd apis/r && Rscript -e "remotes::install_deps(dependencies = TRUE, upgrade = FALSE)" # - name: Install dataset packages from source (macOS) # if: ${{ matrix.os == 'macOS-latest' }} diff --git a/apis/r/DESCRIPTION b/apis/r/DESCRIPTION index f9c773b705..9817e7d70c 100644 --- a/apis/r/DESCRIPTION +++ b/apis/r/DESCRIPTION @@ -6,7 +6,7 @@ Description: Interface for working with 'TileDB'-based Stack of Matrices, like those commonly used for single cell data analysis. It is documented at ; a formal specification available is at . -Version: 1.10.99.5 +Version: 1.10.99.6 Authors@R: c( person(given = "Aaron", family = "Wolen", role = c("cre", "aut"), email = "aaron@tiledb.com", diff --git a/apis/r/NEWS.md b/apis/r/NEWS.md index 39b8891ac6..5d430e9af4 100644 --- a/apis/r/NEWS.md +++ b/apis/r/NEWS.md @@ -11,6 +11,7 @@ * Push default-setting for `TileDBCreateOptions` to `$initialize()` instead of in the accessors * Muffle warnings for missing command logs when outgesting SOMA to `Seurat` * Have `SOMADataFrame$shape()` throw a not-yet-implemented error +* Disable running `SeuratObject::.CalcN()` when outgesting from SOMA to `Seurat` # 1.7.0 diff --git a/apis/r/R/SOMAExperimentAxisQuery.R b/apis/r/R/SOMAExperimentAxisQuery.R index b8d8bebde8..8f820ca831 100644 --- a/apis/r/R/SOMAExperimentAxisQuery.R +++ b/apis/r/R/SOMAExperimentAxisQuery.R @@ -570,6 +570,8 @@ SOMAExperimentAxisQuery <- R6::R6Class( var_index = var_index, var_column_names = var_column_names ) + op <- options(Seurat.object.assay.calcn = FALSE) + on.exit(options(op), add = TRUE, after = FALSE) object <- SeuratObject::CreateSeuratObject( counts = assay, assay = private$.measurement_name diff --git a/apis/r/tools/install-tiledb-r.R b/apis/r/tools/install-tiledb-r.R new file mode 100644 index 0000000000..d7421448ab --- /dev/null +++ b/apis/r/tools/install-tiledb-r.R @@ -0,0 +1,45 @@ +#!/usr/bin/env Rscript + +options(bspm.version.check = TRUE) + +# Find tiledb-r constraints +deps <- read.dcf('DESCRIPTION', fields = 'Imports')[1, ] +deps <- trimws(strsplit(gsub(pattern = ',', replacement = '\n', x = deps), split = '\n')[[1L]]) +deps <- Filter(nzchar, deps) +deps <- Filter(function(x) grepl('^tiledb', x), deps) +deps <- gsub(pattern = '[[:space:]]', replacement = '', x = deps) +deps <- gsub(pattern = '.*\\(|\\)', replacement = '', x = deps) +const <- data.frame(comp = gsub(pattern = '[[:digit:]\\.]*', replacement = '', x = deps)) +const$vers <- gsub(pattern = paste(const$comp, collapse = '|'), replacement = '', x = deps) +(const) + +# Find correct version of tiledb-r +db <- utils::available.packages(filters = c("R_version", "OS_type", "subarch")) +idx <- which(rownames(db) == 'tiledb') +valid <- vapply( + X = idx, + FUN = function(i) { + v <- db[i, 'Version'] + res <- vector(mode = 'logical', length = nrow(const)) + for (i in seq_along(res)) { + res[i] <- do.call(const$comp[i], args = list(v, const$vers[i])) + } + return(all(res)) + }, + FUN.VALUE = logical(1L) +) +if (!any(valid)) { + stop("No valid versions of tiledb-r found") +} +db <- db[-idx[!valid], , drop = FALSE] + +# Install upstream deps +(ups <- tools::package_dependencies("tiledb", db = db, recursive = TRUE)$tiledb) +utils::install.packages(intersect(ups, rownames(db))) + +# Install correct version of tiledb-r +ctb <- contrib.url(getOption("repos")) +names(ctb) <- getOption("repos") +dbr <- db[idx[valid], 'Repository'] +(repos <- names(ctb[ctb %in% dbr])) +utils::install.packages("tiledb", repos = repos)