From f5bd317ad01850235ea0fc76d0b5f9fb72cfbcdd Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 3 Dec 2024 13:59:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20CI=20setup=20(#125)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix lamindb installation instructions * remove huggingface_hub * simplify installation instructions * manually set python * install python first * fix ga * remove env * no need to install bionty and wetlab during r cmd check * add which * set reticulate_python * check r installation dependencies * update error message * add debug vignette * fix style * do not reinstall tiledbsoma if already installed * add workaround * fix warning message * fix warning * add message * use smaller example dataset * revert debugging code * move lamindb installation to where it was before * align ci yamls * laminr is not installed yet at this stage * fix ci --- .github/workflows/R-CMD-check.yaml | 36 +++++++++++++++++++++--------- .github/workflows/pkgdown.yaml | 28 +++++++++++++++++++---- R/Artifact.R | 1 - R/Instance.R | 19 +++++++--------- man/Instance.Rd | 2 +- vignettes/architecture.qmd | 4 ++-- vignettes/concepts_features.Rmd | 4 ++-- 7 files changed, 63 insertions(+), 31 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index c661f25..bcbb739 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -40,8 +40,6 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-tinytex@v2 - - uses: actions/setup-python@v5 with: python-version: ${{ matrix.config.python }} @@ -62,6 +60,11 @@ jobs: echo "LDFLAGS=-L$OPENBLAS/lib" >> $GITHUB_ENV echo "CPPFLAGS=-I$OPENBLAS/include" >> $GITHUB_ENV + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + - name: Install {tiledbsoma} if: runner.os == 'Linux' run: | @@ -71,7 +74,11 @@ jobs: - name: Install lamindb run: | - pip install 'lamindb[aws]>=0.77.2' huggingface_hub + pip install 'lamindb[aws]>=0.77.2' + + # Make sure IPython is installed -- + # Workaround for laminlabs/laminhub-public#29 + pip install ipython - name: Log in to Lamin run: | @@ -81,12 +88,21 @@ jobs: run: | lamin connect laminlabs/lamindata - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::rcmdcheck - needs: check + - name: Check whether we can import lamindb and connect to the default instance + run: | + reticulate::py_config() + reticulate::import("lamindb") + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") + shell: Rscript {0} - - uses: r-lib/actions/check-r-package@v2 + - name: Upload check results + if: failure() + uses: actions/upload-artifact@main with: - upload-snapshots: true - build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5a9aaca..43393ba 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -31,6 +31,10 @@ jobs: - uses: r-lib/actions/setup-pandoc@v2 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true @@ -41,15 +45,24 @@ jobs: needs: website quarto-version: pre-release - - name: Install {tiledbsoma} + - name: Install {tiledbsoma} if not already installed run: | - options(repos = c("https://chanzuckerberg.r-universe.dev", getOption("repos"))) - install.packages("tiledbsoma") + if (!requireNamespace("tiledbsoma", quietly = TRUE)) { + options(repos = c("https://chanzuckerberg.r-universe.dev", getOption("repos"))) + install.packages("tiledbsoma") + } else { + message("Package 'tiledbsoma' already installed") + } shell: Rscript {0} - name: Install lamindb run: | - pip install 'lamindb[aws]>=0.77.2' huggingface_hub + # install bionty and wetlab to avoid warnings about missing dependencies + pip install 'lamindb[aws,bionty,wetlab]>=0.77.2' + + # Make sure IPython is installed -- + # Workaround for laminlabs/laminhub-public#29 + pip install ipython - name: Log in to Lamin run: | @@ -59,6 +72,13 @@ jobs: run: | lamin connect laminlabs/lamindata + - name: Check whether we can import lamindb and connect to the default instance + run: | + reticulate::py_config() + reticulate::import("lamindb") + laminr::connect() + shell: Rscript {0} + - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} diff --git a/R/Artifact.R b/R/Artifact.R index 396c411..3df7b0a 100644 --- a/R/Artifact.R +++ b/R/Artifact.R @@ -27,7 +27,6 @@ ArtifactRecord <- R6::R6Class( # nolint object_name_linter #' #' @return The path to the cached artifact cache = function() { - py_lamin <- private$.instance$get_py_lamin() if (!is.null(py_lamin)) { if (isTRUE(private$.instance$is_default)) { diff --git a/R/Instance.R b/R/Instance.R index d5f2284..4b46bc2 100644 --- a/R/Instance.R +++ b/R/Instance.R @@ -59,23 +59,20 @@ create_instance <- function(instance_settings, is_default = FALSE) { active = active ) - py_lamin <- NULL check_requires("Connecting to Python", "reticulate", alert = "warning") py_lamin <- tryCatch( reticulate::import("lamindb"), error = function(err) { + cli::cli_warn(c( + paste( + "Failed to connect to the Python {.pkg lamindb} package,", + "some functionality may be limited." + ), + "i" = "Run {.run reticulate::py_config()} and {.run reticulate::py_last_error()} for details" + )) NULL } ) - if (isTRUE(is_default) && is.null(py_lamin)) { - cli::cli_warn(c( - paste( - "Default instance failed to connect to the Python {.pkg lamindb} package,", - "you will not be able to create records" - ), - "i" = "See {.run reticulate::py_config()} for more information" - )) - } # create the instance RichInstance$new( @@ -107,7 +104,7 @@ create_instance <- function(instance_settings, is_default = FALSE) { #' db <- connect("laminlabs/cellxgene") #' #' # fetch an artifact -#' artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") +#' artifact <- db$Artifact$get("MkRm3eUKPwfnAyZMWD9v") #' #' # describe the artifact #' artifact$describe() diff --git a/man/Instance.Rd b/man/Instance.Rd index 9adff42..7df3787 100644 --- a/man/Instance.Rd +++ b/man/Instance.Rd @@ -21,7 +21,7 @@ See the vignette on "Package Architecture" for more information: db <- connect("laminlabs/cellxgene") # fetch an artifact -artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") +artifact <- db$Artifact$get("MkRm3eUKPwfnAyZMWD9v") # describe the artifact artifact$describe() diff --git a/vignettes/architecture.qmd b/vignettes/architecture.qmd index 613deac..db444b1 100644 --- a/vignettes/architecture.qmd +++ b/vignettes/architecture.qmd @@ -230,7 +230,7 @@ For example, to get an artifact with a specific ID using **only** base classes, ```r db <- connect("laminlabs/cellxgene") -artifact <- db$get_module("core")$get_registry("artifact")$get("KBW89Mf7IGcekja2hADu") +artifact <- db$get_module("core")$get_registry("artifact")$get("MkRm3eUKPwfnAyZMWD9v") artifact$get_value("id") ``` @@ -240,7 +240,7 @@ With the sugar syntax classes, you can achieve the same result more concisely: ```r db <- connect("laminlabs/cellxgene") -artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") +artifact <- db$Artifact$get("MkRm3eUKPwfnAyZMWD9v") artifact$id ``` diff --git a/vignettes/concepts_features.Rmd b/vignettes/concepts_features.Rmd index 5cb0047..fb8aaf4 100644 --- a/vignettes/concepts_features.Rmd +++ b/vignettes/concepts_features.Rmd @@ -109,10 +109,10 @@ db$Artifact$df(limit = 5) ## Working with records -You can fetch a specific record from a registry using its ID or UID. For instance, to get the artifact with UID [KBW89Mf7IGcekja2hADu](https://lamin.ai/laminlabs/cellxgene/artifact/KBW89Mf7IGcekja2hADu): +You can fetch a specific record from a registry using its ID or UID. For instance, to get the artifact with UID [MkRm3eUKPwfnAyZMWD9v](https://lamin.ai/laminlabs/cellxgene/artifact/MkRm3eUKPwfnAyZMWD9v): ```{r get_artifact} -artifact <- db$Artifact$get("KBW89Mf7IGcekja2hADu") +artifact <- db$Artifact$get("MkRm3eUKPwfnAyZMWD9v") ``` This artifact contains an `AnnData` object with myeloid cell data. You can view its metadata: