Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple unit test which queries laminlabs/lamindata #27

Merged
merged 7 commits into from
Oct 10, 2024

Conversation

rcannood
Copy link
Collaborator

@rcannood rcannood commented Oct 10, 2024

Closes #7

Minor changes

Comment on lines 2 to 4
temp_lamin_dir <- tempfile()
temp_lamin_dir2 <- file.path(temp_lamin_dir, ".lamin")
dir.create(temp_lamin_dir2, recursive = TRUE, showWarnings = FALSE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you just use tempdir() here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No -- because tempdir() is a temporary directory that is created once per R session, so calling tempdir() multiple times results in the same result.

Comment on lines 2 to 41
temp_lamin_dir <- tempfile()
temp_lamin_dir2 <- file.path(temp_lamin_dir, ".lamin")
dir.create(temp_lamin_dir2, recursive = TRUE, showWarnings = FALSE)
Sys.setenv(LAMIN_SETTINGS_DIR = temp_lamin_dir)
on.exit({
unlink(temp_lamin_dir, recursive = TRUE)
Sys.unsetenv("LAMIN_SETTINGS_DIR")
})

# 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(temp_lamin_dir2, "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 = "097186c3e91c01ced47aa3e01a3c1515",
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(temp_lamin_dir2, "current_instance.env"))
writeLines(instance_lines, file.path(temp_lamin_dir2, "instance--laminlabs--lamindata.env"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In future it might make sense to make this setup into a fixture so it can be reused but probably not worth the effort now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good idea!

tests/testthat/test-connect_lamindata.R Outdated Show resolved Hide resolved
@rcannood
Copy link
Collaborator Author

Thanks for the great feedback @lazappi !

@rcannood rcannood merged commit 560cc22 into main Oct 10, 2024
7 checks passed
@rcannood rcannood deleted the test-lamindata branch October 10, 2024 18:04
lazappi added a commit that referenced this pull request Oct 14, 2024
* origin/main:
  Add printing to remaining classes (#31)
  Improve error messages (#30)
  Update documentation (#29)
  Return `NULL` when a record's related field is empty (#28)
  minor fix in usage vignette (#32)
  Add usage vignette (#18)
  Add a simple unit test which queries laminlabs/lamindata (#27)
  bump action from v4.5.0 to v4 (#26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add simple unit tests
2 participants