diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index e53ab3b..d3f2d29 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -64,15 +64,15 @@ jobs: - name: Install lamindb run: | - pip install lamindb[aws] + pip install lamindb[aws] huggingface_hub - name: Log in to Lamin run: | lamin login - - name: Set cellxgene as default instance + - name: Set lamindata as default instance run: | - lamin connect laminlabs/cellxgene + lamin connect laminlabs/lamindata - uses: r-lib/actions/setup-r-dependencies@v2 with: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 96daebc..3b30825 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -43,15 +43,15 @@ jobs: - name: Install lamindb run: | - pip install lamindb[aws] + pip install lamindb[aws] huggingface_hub - name: Log in to Lamin run: | lamin login - - name: Set cellxgene as default instance + - name: Set lamindata as default instance run: | - lamin connect laminlabs/cellxgene + lamin connect laminlabs/lamindata - name: Build site run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) diff --git a/R/settings_store.R b/R/settings_store.R index 928ce40..5289427 100644 --- a/R/settings_store.R +++ b/R/settings_store.R @@ -90,11 +90,10 @@ } raw_type <- field_types[[name]] - optional <- grepl("Optional\\[.*\\]", raw_type) type <- gsub("Optional\\[(.*)\\]", "\\1", raw_type) value <- - if (optional && raw_value == "null") { + if (raw_value == "null") { NULL } else if (type == "str") { raw_value diff --git a/tests/testthat/helper-setup_lamindata_instance.R b/tests/testthat/helper-setup_lamindata_instance.R deleted file mode 100644 index 830cb46..0000000 --- a/tests/testthat/helper-setup_lamindata_instance.R +++ /dev/null @@ -1,42 +0,0 @@ -local_setup_lamindata_instance <- function(env = parent.frame()) { - root_dir <- withr::local_file(tempfile(), .local_envir = env) - withr::local_envvar(c(LAMIN_SETTINGS_DIR = root_dir), .local_envir = env) - - # create a temporary directory for the settings - lamin_dir <- file.path(root_dir, ".lamin") - dir.create(lamin_dir, recursive = TRUE, showWarnings = FALSE) - - # generate user settings - user_settings <- list( - email = "null", - password = "null", - access_token = "null", - api_key = "null", - uid = "00000000", - uuid = "null", - handle = "anonymous", - name = "null" - ) - user_lines <- paste0("lamin_user_", names(user_settings), "=", unlist(user_settings)) - writeLines(user_lines, file.path(lamin_dir, "current_user.env")) - - # generate instance settings - instance_settings <- list( - owner = "laminlabs", - name = "lamindata", - api_url = "https://us-east-1.api.lamin.ai", - storage_root = "s3://lamindata", - storage_region = "us-east-1", - db = "null", - schema_str = "bionty,wetlab", - schema_id = "ddfac42efaeb0c5d60209e3a281fff0e", - id = "037ba1e08d804f91a90275a47735076a", - git_repo = "null", - keep_artifacts_local = "False" - ) - instance_lines <- paste0("lamindb_instance_", names(instance_settings), "=", unlist(instance_settings)) - writeLines(instance_lines, file.path(lamin_dir, "current_instance.env")) - writeLines(instance_lines, file.path(lamin_dir, "instance--laminlabs--lamindata.env")) - - root_dir -} diff --git a/tests/testthat/helper-skip_if_not_logged_in.R b/tests/testthat/helper-skip_if_not_logged_in.R new file mode 100644 index 0000000..921cd10 --- /dev/null +++ b/tests/testthat/helper-skip_if_not_logged_in.R @@ -0,0 +1,7 @@ +skip_if_not_logged_in <- function() { + user_settings <- .get_user_settings() + testthat::skip_if( + is.null(user_settings$access_token), + "You must be logged in to run this test" + ) +} diff --git a/tests/testthat/test-Artifact.R b/tests/testthat/test-Artifact.R index 0952671..02b6fc5 100644 --- a/tests/testthat/test-Artifact.R +++ b/tests/testthat/test-Artifact.R @@ -4,7 +4,7 @@ test_that("creating an artifact from a data frame works", { skip_if_not_installed("reticulate") skip_if_not(reticulate::py_module_available("lamindb")) - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect() @@ -25,7 +25,7 @@ test_that("creating an artifact from a file works", { skip_if_not_installed("reticulate") skip_if_not(reticulate::py_module_available("lamindb")) - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect() @@ -45,7 +45,7 @@ test_that("creating an artifact from a directory works", { skip_if_not_installed("reticulate") skip_if_not(reticulate::py_module_available("lamindb")) - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect() @@ -68,7 +68,7 @@ test_that("creating an artifact from an AnnData works", { skip_if_not(reticulate::py_module_available("lamindb")) skip_if_not_installed("anndata") - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect() diff --git a/tests/testthat/test-Registry.R b/tests/testthat/test-Registry.R index e86140b..c56b46d 100644 --- a/tests/testthat/test-Registry.R +++ b/tests/testthat/test-Registry.R @@ -1,7 +1,7 @@ skip_if_offline() test_that("df works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect("laminlabs/lamindata") @@ -12,7 +12,7 @@ test_that("df works", { }) test_that("to_string works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect("laminlabs/lamindata") @@ -32,7 +32,7 @@ test_that("to_string works", { }) test_that("print works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect("laminlabs/lamindata") diff --git a/tests/testthat/test-RelatedRecords.R b/tests/testthat/test-RelatedRecords.R index 864ae93..2da3151 100644 --- a/tests/testthat/test-RelatedRecords.R +++ b/tests/testthat/test-RelatedRecords.R @@ -1,7 +1,7 @@ skip_if_offline() test_that("RelatedRecord methods work", { - local_setup_lamindata_instance() + skip_if_not_logged_in() db <- connect("laminlabs/lamindata") artifact <- db$Artifact$get("mePviem4DGM4SFzvLXf3") diff --git a/tests/testthat/test-connect_lamindata.R b/tests/testthat/test-connect_lamindata.R index 0506155..fdc1fb9 100644 --- a/tests/testthat/test-connect_lamindata.R +++ b/tests/testthat/test-connect_lamindata.R @@ -1,7 +1,7 @@ skip_if_offline() test_that("Connecting to lamindata works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() # try to connect to lamindata db <- connect("laminlabs/lamindata") diff --git a/tests/testthat/test-instance_api.R b/tests/testthat/test-instance_api.R index 3aaf847..a32303a 100644 --- a/tests/testthat/test-instance_api.R +++ b/tests/testthat/test-instance_api.R @@ -16,7 +16,7 @@ broken_instance_settings <- function() { } test_that("get_schema works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() instance_file <- .settings_store__instance_settings_file("laminlabs", "lamindata") instance_settings <- .settings_load__load_instance_settings() @@ -42,7 +42,7 @@ test_that("get_schema fails gracefully", { }) test_that("get_record works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() instance_file <- .settings_store__instance_settings_file("laminlabs", "lamindata") instance_settings <- .settings_load__load_instance_settings() @@ -68,7 +68,7 @@ test_that("test get_record fails gracefully with incorrect host", { }) test_that("get_record with select works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() instance_file <- .settings_store__instance_settings_file("laminlabs", "lamindata") instance_settings <- .settings_load__load_instance_settings() @@ -84,7 +84,7 @@ test_that("get_record with select works", { }) test_that("get_record fails gracefully", { - local_setup_lamindata_instance() + skip_if_not_logged_in() instance_file <- .settings_store__instance_settings_file("laminlabs", "lamindata") instance_settings <- .settings_load__load_instance_settings() @@ -106,7 +106,7 @@ test_that("get_record fails gracefully", { }) test_that("get_records works", { - local_setup_lamindata_instance() + skip_if_not_logged_in() instance_file <- .settings_store__instance_settings_file("laminlabs", "lamindata") instance_settings <- .settings_load__load_instance_settings()