diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 4758e2b..55b9634 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -23,6 +23,8 @@ jobs: - { os: ubuntu-latest, r: "devel", http-user-agent: "release", python: "3.x" } - { os: ubuntu-latest, r: "release", python: "3.x" } - { os: ubuntu-latest, r: "oldrel-1", python: "3.9" } + - { os: ubuntu-latest, r: "release", http-user-agent: "release", python: "3.x", lamin: "devel" } + - { os: ubuntu-latest, r: "devel", http-user-agent: "release", python: "3.x", lamin: "devel" } env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -76,6 +78,10 @@ jobs: - name: Setup Python environment run: | laminr::install_lamindb(extra_packages = c("s3fs")) + if ("${{ matrix.config.lamin }}" == "devel") { + reticulate::use_virtualenv("r-lamindb") + reticulate::py_install("git+https://github.com/laminlabs/lamindb.git") + } shell: Rscript {0} - name: Log in to Lamin diff --git a/CHANGELOG.md b/CHANGELOG.md index e80f610..9bcc303 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# laminr devel + +## MAJOR CHANGES + +- Updates for compatibility with the Python `lamindb` v1.0 release + +## MINOR CHANGES + +- `db$track()` can not automatically create a transform UID when not supplied + # laminr v0.3.1 This release improves the UX for setting up the Python environment and adds functions to allow access to CLI functionality from R. @@ -43,7 +53,6 @@ This release contains mostly UX improvements: - Update roadmap (PR #112). - Simplify `README` content (PR #116). - # laminr v0.2.0 This release adds support for creating new artifacts in a LaminDB instance. diff --git a/DESCRIPTION b/DESCRIPTION index 0591c27..d249f5f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: laminr Title: Client for 'LaminDB' -Version: 0.3.1 +Version: 0.3.1.9000 Authors@R: c( person("Robrecht", "Cannoodt", email = "robrecht@data-intuitive.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3641-729X")), diff --git a/R/Artifact.R b/R/Artifact.R index 3df7b0a..33e410d 100644 --- a/R/Artifact.R +++ b/R/Artifact.R @@ -70,8 +70,7 @@ ArtifactRecord <- R6::R6Class( # nolint object_name_linter #' @return A [tiledbsoma::SOMACollection] or [tiledbsoma::SOMAExperiment] #' object open = function() { - is_tiledbsoma <- private$get_value("suffix") == ".tiledbsoma" || - private$get_value("_accessor") == "tiledbsoma" + is_tiledbsoma <- private$get_value("otype") == "tiledbsoma" if (!is_tiledbsoma) { cli::cli_abort( diff --git a/R/Instance.R b/R/Instance.R index 4b46bc2..94be328 100644 --- a/R/Instance.R +++ b/R/Instance.R @@ -74,6 +74,22 @@ create_instance <- function(instance_settings, is_default = FALSE) { } ) + if (!is.null(py_lamin)) { + lamin_version <- reticulate::py_get_attr(py_lamin, "__version__") + lamin_version_clean <- sub("([a-zA-Z].*)", "", lamin_version) # Remove pre-release versions, e.g. 1.0a5 -> 1.0 + if (compareVersion("1.0.2", lamin_version_clean) == 1) { + cli::cli_abort( + c( + paste( + "This version of {.pkg laminr} requires Python {.pkg lamindb} >= 1.0.", + "You have {.pkg lamindb} v{lamin_version}." + ), + "i" = "Run {.run laminr::install_lamindb()} to update." + ) + ) + } + } + # create the instance RichInstance$new( settings = instance_settings, @@ -229,34 +245,7 @@ Instance <- R6::R6Class( # nolint object_name_linter } } - if (is.null(transform)) { - transform <- tryCatch( - py_lamin$track(path = path), - error = function(err) { - py_err <- reticulate::py_last_error() - # please don't change the below without changing it in lamindb - if (py_err$type != "MissingContextUID") { - cli::cli_abort(c( - "Python {py_err$message}", - "i" = "Run {.run reticulate::py_last_error()} for details" - )) - } - - uid <- gsub(".*\\(\"(.*?)\"\\).*", "\\1", py_err$value) - cli::cli_inform(paste( - "To track this notebook, run: db$track(\"{uid}\")" - )) - } - ) - } else { - if (is.character(transform) && nchar(transform) != 16) { - cli::cli_abort( - "The transform UID must be exactly 16 characters, got {nchar(transform)}" - ) - } - - py_lamin$track(transform = transform, path = path) - } + py_lamin$track(transform = transform, path = path) }, #' @description Finish a tracked run finish = function() { diff --git a/R/Registry.R b/R/Registry.R index a4815c0..05e2174 100644 --- a/R/Registry.R +++ b/R/Registry.R @@ -519,7 +519,7 @@ create_record_from_python <- function(py_record, instance) { class_split <- strsplit(py_classes[1], "\\.")[[1]] module_name <- class_split[1] - if (module_name == "lnschema_core") { + if (module_name == "lamindb") { module_name <- "core" } registry_name <- tolower(class_split[3]) @@ -534,7 +534,7 @@ create_record_from_python <- function(py_record, instance) { NULL } ) - if (inherits(value, "lnschema_core.models.Record")) { + if (inherits(value, "lamindb.models.Record")) { value <- create_record_from_python(value, instance) } value diff --git a/R/install.R b/R/install.R index df1f22a..64e24b3 100644 --- a/R/install.R +++ b/R/install.R @@ -35,7 +35,7 @@ install_lamindb <- function(..., envname = "r-lamindb", extra_packages = NULL, reticulate::virtualenv_remove(envname) } - packages <- unique(c("lamindb", "ipython", extra_packages)) + packages <- unique(c("lamindb>=1.0.2", "ipython", extra_packages)) reticulate::py_install(packages = packages, envname = envname, ...) diff --git a/tests/testthat/test-instance_api.R b/tests/testthat/test-instance_api.R index a32303a..785a14e 100644 --- a/tests/testthat/test-instance_api.R +++ b/tests/testthat/test-instance_api.R @@ -52,7 +52,7 @@ test_that("get_record works", { # try to get a record artifact <- api$get_record("core", "artifact", "mePviem4DGM4SFzvLXf3") - expect_true(all(c("uid", "size", "hash", "description", "type") %in% names(artifact))) + expect_true(all(c("uid", "size", "hash", "description") %in% names(artifact))) }) test_that("test get_record fails gracefully with incorrect host", { @@ -78,7 +78,7 @@ test_that("get_record with select works", { # try to get a record artifact <- api$get_record("core", "artifact", "mePviem4DGM4SFzvLXf3", select = "storage") - expect_true(all(c("uid", "size", "hash", "description", "type") %in% names(artifact))) + expect_true(all(c("uid", "size", "hash", "description") %in% names(artifact))) expect_true(all(c("uid", "type", "region", "root") %in% names(artifact$storage))) }) diff --git a/vignettes/laminr.Rmd b/vignettes/laminr.Rmd index f160af2..31d8380 100644 --- a/vignettes/laminr.Rmd +++ b/vignettes/laminr.Rmd @@ -65,15 +65,9 @@ LaminDB tracks which code is used to create data. To track the current source code, run: ```{r track, eval = submit_eval} -db$track("I8BlHXFXqZOG0000") +db$track() ``` - - # Connect to other instances It is possible to connect to any LaminDB instance for reading data.