-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add force=TRUE when installing local repo [skip ci]
- Loading branch information
Showing
16 changed files
with
614 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
conda_installed <- function(){ | ||
requireNamespace("reticulate") | ||
utils::getFromNamespace("conda_installed","reticulate")() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
condaenv_exists <- function(...){ | ||
requireNamespace("reticulate") | ||
utils::getFromNamespace("condaenv_exists","reticulate")(...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
save_yaml <- function(yml, | ||
path, | ||
verbose=TRUE){ | ||
handlers=NULL, | ||
verbose=TRUE, | ||
...){ | ||
|
||
dir.create(dirname(path),showWarnings = FALSE, recursive = TRUE) | ||
messager("Saving yaml ==>",path,v=verbose) | ||
#### Write bools as true/false rather than yes/no (default) #### | ||
handlers2 <- list('bool#yes' = function(x){"${{ true }}"}, | ||
'bool#no' = function(x){"${{ false }}"}) | ||
yml2 <- yaml::yaml.load(yaml::as.yaml(yml), | ||
handlers = handlers2) | ||
yaml::write_yaml(x = yml2, | ||
if(!is.null(handlers)){ | ||
yml <- yaml::yaml.load(yaml::as.yaml(yml), | ||
handlers = handlers) | ||
} | ||
yaml::write_yaml(x = yml, | ||
file = path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,47 @@ | ||
test_that("construct_conda_yml works", { | ||
|
||
path1 <- construct_conda_yml(name="sc_env", | ||
save_path <- tempfile(fileext = "myenv_conda.yml") | ||
path1 <- construct_conda_yml(name="myenv", | ||
dependencies=c("anndata","scanpy"), | ||
return_path = TRUE) | ||
return_path = TRUE, | ||
save_path = save_path) | ||
testthat::expect_true(file.exists(path1)) | ||
|
||
yml1 <- construct_conda_yml(name="sc_env", | ||
yml1 <- construct_conda_yml(name="myenv", | ||
dependencies=c("anndata","scanpy"), | ||
return_path = FALSE) | ||
return_path = FALSE, | ||
save_path = save_path) | ||
testthat::expect_true(all(c("name","channels","dependencies") %in% names(yml1))) | ||
|
||
yml2 <- construct_conda_yml(name="sc_env", | ||
yml2 <- construct_conda_yml(name="myenv", | ||
dependencies=c("anndata>=1.0","scanpy<20.1.1"), | ||
pip = c("pip","mytool1","mtool2"), | ||
return_path = FALSE) | ||
return_path = FALSE, | ||
save_path = save_path) | ||
testthat::expect_true(all(c("name","channels","dependencies","pip") %in% names(yml2))) | ||
|
||
yml3 <- construct_conda_yml(name="sc_env", | ||
yml3 <- construct_conda_yml(name="myenv", | ||
dependencies=c("anndata","scanpy"), | ||
save_path = NULL, | ||
return_path = TRUE) | ||
preview = TRUE, | ||
return_path = TRUE, | ||
save_path = save_path) | ||
testthat::expect_true(all(c("name","channels","dependencies") %in% names(yml3))) | ||
|
||
|
||
#### Construct an actual conda env #### | ||
if(conda_installed() && is_gha()){ | ||
envname <- "testenv" | ||
if(condaenv_exists(envname)){ | ||
reticulate::conda_remove(envname = envname) | ||
} | ||
path2 <- construct_conda_yml(name=envname, | ||
dependencies=list("python"), | ||
pip=list("requests"), | ||
preview = TRUE, | ||
return_path = TRUE, | ||
save_path = save_path) | ||
out <- reticulate::conda_create(environment = path2) | ||
} | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters