Skip to content

Commit

Permalink
Remove the 'slendr_' prefix in the default Python environment
Browse files Browse the repository at this point in the history
  • Loading branch information
bodkan committed Apr 12, 2022
1 parent 609cbcb commit eb05180
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
mkdir ~/R_LIBS
echo "R_LIBS_USER=~/R_LIBS" >> ~/.Renviron
R -e 'install.packages("reticulate", repos = "http://cran.rstudio.com")'
R -e 'deps <- c("msprime==1.1.1", "tskit==0.4.1", "pyslim==0.700", "pandas"); PYTHON_ENV <- paste0("slendr_", paste(gsub("==", "-", deps), collapse = "_")); reticulate::conda_create(envname = PYTHON_ENV); reticulate::use_condaenv(PYTHON_ENV, required = TRUE); reticulate::conda_install(envname = PYTHON_ENV, packages = deps, pip = TRUE)'
R -e 'deps <- c("msprime==1.1.1", "tskit==0.4.1", "pyslim==0.700", "pandas"); PYTHON_ENV <- paste(gsub("==", "-", deps), collapse = "_"); reticulate::conda_create(envname = PYTHON_ENV); reticulate::use_condaenv(PYTHON_ENV, required = TRUE); reticulate::conda_install(envname = PYTHON_ENV, packages = deps, pip = TRUE)'
- uses: r-lib/actions/setup-pandoc@v1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
echo "R_LIBS_USER=~/R_LIBS" >> ~/.Renviron
R -e 'install.packages(c("BiocManager", "reticulate"), repos = "http://cran.rstudio.com")'
R -e 'BiocManager::install("ggtree")'
R -e 'deps <- c("msprime==1.1.1", "tskit==0.4.1", "pyslim==0.700", "pandas"); PYTHON_ENV <- paste0("slendr_", paste(gsub("==", "-", deps), collapse = "_")); reticulate::conda_create(envname = PYTHON_ENV); reticulate::use_condaenv(PYTHON_ENV, required = TRUE); reticulate::conda_install(envname = PYTHON_ENV, packages = deps, pip = TRUE)'
R -e 'deps <- c("msprime==1.1.1", "tskit==0.4.1", "pyslim==0.700", "pandas"); PYTHON_ENV <- paste(gsub("==", "-", deps), collapse = "_"); reticulate::conda_create(envname = PYTHON_ENV); reticulate::use_condaenv(PYTHON_ENV, required = TRUE); reticulate::conda_install(envname = PYTHON_ENV, packages = deps, pip = TRUE)'
- uses: r-lib/actions/setup-r@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion R/interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ setup_env <- function(quiet = FALSE, agree = FALSE, pip = TRUE) {
# parse the Python env name back to the list of dependencies
# (the environment is defined in .onAttach(), and this makes sure the
# dependencies are defined all in one place)
deps <- gsub("slendr_", "", PYTHON_ENV) %>% gsub("-", "==", .) %>% strsplit("_") %>% .[[1]]
deps <- PYTHON_ENV %>% gsub("-", "==", .) %>% strsplit("_") %>% .[[1]]
reticulate::conda_install(envname = PYTHON_ENV, packages = deps, pip = pip)

if (!quiet)
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msp <- NULL
# define slendr's required Python dependencies and compose an environment name
# that will be used specifically for them
deps <- c("msprime==1.1.1", "tskit==0.4.1", "pyslim==0.700", "pandas")
PYTHON_ENV <- paste0("slendr_", paste(gsub("==", "-", deps), collapse = "_"))
PYTHON_ENV <- paste(gsub("==", "-", deps), collapse = "_")

.onAttach <- function(libname, pkgname) {
# check for presence of the slim binary in user's PATH and display
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-msprime-geneflow.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skip_if(!slendr:::check_env_present() || Sys.getenv("local_build") != TRUE)
skip_if(!slendr:::check_env_present())
setup_env(quiet = TRUE)

# Let's start by defining a couple of parameters for our simulations
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-msprime.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# generated by two completely different pieces of software after all - SLiM
# and msprime Python library), but they should be *nearly* the same.

skip_if(!slendr:::check_env_present() || Sys.getenv("local_build") != TRUE)
skip_if(!slendr:::check_env_present())
setup_env(quiet = TRUE)

seed <- 42
Expand Down
4 changes: 2 additions & 2 deletions vignettes/vignette-05-tree-sequences.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ tree

This means that we have the whole R phylogenetic ecosystem at our disposal to analyze such trees. For instance we can use the powerful package *ggtree* to plot the tree we have just extracted:

```{r, plot_ggtree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("local_build") == TRUE}
```{r, plot_ggtree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("SLENDR_LOCAL") == TRUE}
library(ggtree)
ggtree(tree) +
Expand All @@ -242,7 +242,7 @@ ggtree(tree) +
```


```{r, plot_apetree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("local_build") != TRUE}
```{r, plot_apetree, eval = Sys.which("slim") != "" && env_present && Sys.getenv("RUNNER_OS") != "macOS" && Sys.getenv("SLENDR_LOCAL") != TRUE}
library(ape)
plot(tree)
nodelabels()
Expand Down
2 changes: 1 addition & 1 deletion vignettes/vignette-08-paper.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ ancestors <- ts_ancestors(ts, "EUR_599")

### Plotting code

```{r, figure_ex4, eval = Sys.getenv("local_build") == TRUE && eval_chunk && file.exists("~/Documents/postdoc/slendr/slendr_models/ex3/output_slim.trees"), fig.height=9, fig.width=7, class.source = "fold-hide"}
```{r, figure_ex4, eval = Sys.getenv("SLENDR_LOCAL") == TRUE && eval_chunk && file.exists("~/Documents/postdoc/slendr/slendr_models/ex3/output_slim.trees"), fig.height=9, fig.width=7, class.source = "fold-hide"}
library(ggtree)
# prepare annotation table for ggtree linking R phylo node ID (not tskit integer
Expand Down

0 comments on commit eb05180

Please sign in to comment.