Skip to content

Commit

Permalink
[r/ci] Utilize pin of tiledb-r during install (#2540)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
mojaveazure authored May 9, 2024
1 parent d8cac0b commit 8c7863c
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 2 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/r-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ env:
COVERAGE_TOKEN: ${{ secrets.CODECOV_TOKEN }}
_R_CHECK_TESTS_NLINES_: 0
CATCHSEGV: "TRUE"
R_REMOTES_UPGRADE: "never"

jobs:
ci:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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' }}
Expand Down
2 changes: 1 addition & 1 deletion apis/r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
<https://github.com/single-cell-data>; a formal specification available is at
<https://github.com/single-cell-data/SOMA/blob/main/abstract_specification.md>.
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",
Expand Down
1 change: 1 addition & 0 deletions apis/r/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions apis/r/R/SOMAExperimentAxisQuery.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 45 additions & 0 deletions apis/r/tools/install-tiledb-r.R
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8c7863c

Please sign in to comment.