Skip to content

Commit

Permalink
Add new conda yml
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed May 24, 2024
1 parent c0dafb5 commit 2d5e13e
Show file tree
Hide file tree
Showing 32 changed files with 299 additions and 105 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
^auto$
.*\.Rproj$
^\.Rproj\.user$
^README.Rmd
Expand Down
30 changes: 20 additions & 10 deletions .github/workflows/rworkflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ name: rworkflows
branches:
- master
- main
- devel
- RELEASE_**
pull_request:
branches:
- master
- main
- devel
- RELEASE_**
jobs:
rworkflows:
permissions:
contents: write
packages: write
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
container: ${{ matrix.config.cont }}
Expand All @@ -20,16 +25,22 @@ jobs:
matrix:
config:
- os: ubuntu-latest
r: devel
bioc: devel
cont: bioconductor/bioconductor_docker:devel
rspm: https://packagemanager.rstudio.com/cran/__linux__/focal/release
r: auto
cont: ghcr.io/bioconductor/bioconductor_docker:devel
python: 3.11
- os: macOS-latest
r: latest
bioc: release
r: auto
cont: ~
rspm: ~
python: 3.11
- os: windows-latest
r: latest
bioc: release
r: auto
cont: ~
rspm: ~
python: 3.11
steps:
- uses: neurogenomics/rworkflows@master
with:
Expand All @@ -41,10 +52,9 @@ jobs:
run_covr: ${{ true }}
run_pkgdown: ${{ true }}
has_runit: ${{ false }}
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }}
run_docker: ${{ true }}
docker_user: bschilder
docker_org: neurogenomicslab
has_latex: ${{ false }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run_docker: ${{ false }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
runner_os: ${{ runner.os }}
cache_version: cache-master
cache_version: cache-v1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
auto/
basilisk/
# R project files
*.Rproj
Expand Down Expand Up @@ -40,4 +41,4 @@ vignettes/*.R
*.utf8.md
*.knit.md
# R Environment Variables
.Renviron
.Renviron
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: echoconda
Type: Package
Title: echoverse module: conda environment management
Version: 0.99.9
Version: 0.99.10
Authors@R:
c(person(given = "Brian",
family = "Schilder",
Expand Down Expand Up @@ -59,7 +59,7 @@ Suggests:
Remotes:
github::MRCIEU/genetics.binaRies,
github::RajLabMSSM/echodata
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
StagedInstall: no
VignetteBuilder: knitr
License: GPL (>= 3)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# echoconda 0.99.10

## New features

* Updated `rworkflows`.

# echoconda 0.99.9

## New features
Expand Down
14 changes: 10 additions & 4 deletions R/basilisk.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ create_env_basilisk <- function(yaml_path,
pkgs,
sep="=",
use_subversion=FALSE,
use_nodefaults=TRUE,
start = TRUE){
package <- NULL;
# yaml_path <- tail(ymls$yaml_path,1)
yaml_txt <- yaml::read_yaml(file = yaml_path)
deps <- unlist(yaml_txt$dependencies)
#### Omit python ####
deps <- deps[!startsWith(deps,"python")]
#### Check for pip deps ####
has_pip <- if(!is.null(names(deps))){
startsWith(names(deps),"pip")
Expand All @@ -41,7 +44,7 @@ create_env_basilisk <- function(yaml_path,
}
#### Subset to only core packages ####
#### Make sure package aren't listed twice ####
pkgs <- pkgs[!duplicated(pkgs$package),]
pkgs <- pkgs[!duplicated(pkgs$package),]
#### Omit subversions for increased flexibility ####
if(isFALSE(use_subversion)){
pkgs$version <- stringr::str_split(pkgs$version,"[.]",
Expand All @@ -50,15 +53,18 @@ create_env_basilisk <- function(yaml_path,
## Split by pip / non-pip
pip_pkgs <- pkgs[package %in% unname(deps[has_pip]),]
nonpip_pkgs <- pkgs[package %in% unname(deps[!has_pip]),]
channels <- unique(c(pkgs$channel,
if(use_nodefaults) "nodefaults" else NULL))
use_nodefaults
#### Create basilisk env object ####
envObj <- basilisk::BasiliskEnvironment(
envname = yaml_txt$name,
pkgname = "echoconda",
## Use >= rather than = or == for increased flexibility,
## but reduced reproducibility.
packages = paste(nonpip_pkgs$package,nonpip_pkgs$version,sep=sep),
pip = paste(pip_pkgs$package,pip_pkgs$version,sep=sep),
channels = unique(c(pkgs$channel,"nodefaults"))
packages = paste(nonpip_pkgs$package, nonpip_pkgs$version, sep=sep),
pip = paste(pip_pkgs$package, pip_pkgs$version, sep=sep),
channels = channels
)
if(isTRUE(start)){
proc <- basilisk::basiliskStart(env = envObj)
Expand Down
18 changes: 14 additions & 4 deletions R/create_env.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#' Create conda env
#'
#' Create conda env using one of several methods.
#' @param ... Additional arguments passed to method-specific
#' conda env build functions:
#' \itemize{
#' \item \code{basilisk}: \link[echoconda]{create_env_basilisk}
#' \item \code{reticulate}: \link[reticulate]{conda_create}
#' \item \code{cli}: \link[echoconda]{create_env_cli}
#' }
#' @keywords internal
#' @inheritParams yaml_to_env
#' @inheritParams reticulate::conda_create
Expand All @@ -9,7 +16,8 @@ create_env <- function(conda_env,
method=c("basilisk","reticulate","cli"),
conda="auto",
force_new=FALSE,
verbose=TRUE){
verbose=TRUE,
...){
messager("echoconda:: Creating conda environment:", conda_env,
v = verbose
)
Expand All @@ -26,7 +34,8 @@ create_env <- function(conda_env,
if(method=="reticulate"){
reticulate::conda_create(envname = conda_env,
environment = yaml_path,
conda = conda)
conda = conda,
...)
#### basilisk ####
} else if(method=="basilisk"){
pkgs <- data.table::fread(
Expand All @@ -35,15 +44,16 @@ create_env <- function(conda_env,
)
envObj <- create_env_basilisk(yaml_path = yaml_path,
pkgs = pkgs,
start = TRUE)
...)
conda_env <- envObj@envname

#### cli ####
} else if(method=="cli"){
conda_env <- create_env_cli(yaml_path = yaml_path,
conda = conda,
force_new = force_new,
verbose = verbose)
verbose = verbose,
...)
} else {
stp <- paste("method must be one of:",
paste("\n -",eval(formals(create_env)$method)))
Expand Down
4 changes: 2 additions & 2 deletions R/env_to_yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#' @export
#' @importFrom reticulate conda_export
#' @examples
#' path <- echoconda::env_to_yaml(conda_env="base")
#' path <- env_to_yaml(conda_env="base")
env_to_yaml <- function(conda_env,
yaml_path = file.path(tempdir(),"conda.yml"),
conda = "auto",
method = c("basilisk","reticulate"),
method = c("reticulate","basilisk"),
verbose = TRUE,
...){

Expand Down
6 changes: 4 additions & 2 deletions R/find_env_rlib.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#'
#' @family conda
#' @export
find_env_rlib <- function(conda_env = "echoR",
find_env_rlib <- function(conda_env = "echoR_mini",
suffix = "lib/R/library/") {
conda_env <- check_env(conda_env = conda_env)
conda_path <- dirname(dirname(find_python_path(conda_env = conda_env)))
list.files(conda_env)
python <- find_python_path(conda_env = conda_env)
conda_path <- dirname(dirname(python))
if (conda_path == ".") {
env_Rlib <- .libPaths()
message("No conda_env='", conda_env, "' not found.")
Expand Down
4 changes: 2 additions & 2 deletions R/install_conda_basilisk.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#' @keywords internal
#' @importFrom basilisk.utils installConda
install_conda_basilisk <- function(verbose=TRUE){

new_install <- basilisk.utils::installConda()
# Sys.setenv("BASILISK_USE_SYSTEM_DIR"=1)
new_install <- basilisk.utils::installConda(installed = FALSE)
if(isTRUE(new_install)){
messager("echoconda:: Installing conda via basilisk.",v=verbose)
} else {
Expand Down
17 changes: 10 additions & 7 deletions R/yaml_to_env.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@
#' overwrite it with a new one (\emph{DEFAULT}: \code{FALSE}).
#' @param show_contents Show the contents of the yaml file (if used).
#' @param verbose Print messages.
#' @inheritParams create_env
#' @inheritParams reticulate::conda_create
#'
#' @source \href{https://github.com/rstudio/reticulate/issues/779}{GitHub Issue}
#' @source \href{https://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t}{
#' StackOverflow suggestions for cross-platform troubleshooting}
#' @family conda
#'
#' @export
#' @importFrom reticulate conda_binary
#' @importFrom echodata is_local is_url
#' @examples
#' conda_env <- echoconda::yaml_to_env()
#' conda_env <- yaml_to_env()
yaml_to_env <- function(yaml_path = system.file(
package = "echoconda",
"conda","echoR_mini.yml"
Expand All @@ -33,13 +35,13 @@ yaml_to_env <- function(yaml_path = system.file(
conda = "auto",
force_new = FALSE,
show_contents = FALSE,
verbose = TRUE) {
# echoverseTemplate:::source_all()
# echoverseTemplate:::args2vars(echoconda::yaml_to_env)
verbose = TRUE,
...) {
# devoptera::args2vars(yaml_to_env)

method <- tolower(method)[1]
install_conda(method = method,
verbose = verbose)
# install_conda(method = method,
# verbose = verbose)
start <- Sys.time()
#### Check whether env exists ####
conda_env <- name_from_yaml(yaml_path = yaml_path,
Expand Down Expand Up @@ -87,7 +89,8 @@ yaml_to_env <- function(yaml_path = system.file(
method = method,
conda = conda,
force_new = force_new,
verbose = verbose)
verbose = verbose,
...)
}
}
conda_env <- check_env(conda_env = conda_env)
Expand Down
14 changes: 5 additions & 9 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
---
title: ""
author: "<img src='https://github.com/RajLabMSSM/`r read.dcf('DESCRIPTION', fields = 'Package')[1]`/raw/`r gsub('[*] ','',system('git branch', intern = TRUE)[1])`/inst/hex/hex.png' height='300'><br><br>
`r badger::badge_github_version(color = 'black')`
`r badger::badge_github_actions(action = 'rworkflows')`
`r badger::badge_last_commit()`
`r badger::badge_codecov()`
`r badger::badge_license()`
<h5>Author: <i>Brian M. Schilder</i></h5>"
author: "`r rworkflows::use_badges(branch='main')`"
date: "<h5>README updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h5>"
output:
github_document
---

```{r, echo=FALSE, include=FALSE}
pkg <- read.dcf("DESCRIPTION", fields = "Package")[1]
description <- read.dcf("DESCRIPTION", fields = "Description")[1]
description <- read.dcf("DESCRIPTION", fields = "Description")[1] |>
gsub(pattern="\n",replacement=" ")
```

## ``r pkg``: `r gsub("echoverse module: ","", description)`

This R package is part of the *echoverse* suite that supports [`echolocatoR`](https://github.com/RajLabMSSM/echolocatoR):
This R package is part of the *echoverse* suite that supports
[`echolocatoR`](https://github.com/RajLabMSSM/echolocatoR):
an automated genomic fine-mapping pipeline.

If you use ``r pkg``, please cite:
Expand Down
29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
<img src='https://github.com/RajLabMSSM/echoconda/raw/main/inst/hex/hex.png' height='300'><br><br>
[![](https://img.shields.io/badge/devel%20version-0.99.9-black.svg)](https://github.com/RajLabMSSM/echoconda)
[![R build
status](https://github.com/RajLabMSSM/echoconda/workflows/rworkflows/badge.svg)](https://github.com/RajLabMSSM/echoconda/actions)
[![](https://img.shields.io/github/last-commit/RajLabMSSM/echoconda.svg)](https://github.com/RajLabMSSM/echoconda/commits/main)
[![](https://app.codecov.io/gh/RajLabMSSM/echoconda/branch/main/graph/badge.svg)](https://app.codecov.io/gh/RajLabMSSM/echoconda)
<img src='https://github.com/RajLabMSSM/echoconda/raw/main/inst/hex/hex.png' title='Hex sticker for echoconda' height='300'><br>
[![License: GPL (\>=
3)](https://img.shields.io/badge/license-GPL%20(%3E=%203)-blue.svg)](https://cran.r-project.org/web/licenses/GPL%20(%3E=%203))
¶ <h5> ¶ Author: <i>Brian M. Schilder</i> ¶ </h5>
<h5> ¶ README updated: <i>Dec-22-2022</i> ¶ </h5>

## `echoconda`: Various utility functions to find, build,

and use conda environments from within R.
[![](https://img.shields.io/badge/devel%20version-0.99.10-black.svg)](https://github.com/RajLabMSSM/echoconda)
[![](https://img.shields.io/github/languages/code-size/RajLabMSSM/echoconda.svg)](https://github.com/RajLabMSSM/echoconda)
[![](https://img.shields.io/github/last-commit/RajLabMSSM/echoconda.svg)](https://github.com/RajLabMSSM/echoconda/commits/main)
<br> [![R build
status](https://github.com/RajLabMSSM/echoconda/workflows/rworkflows/badge.svg)](https://github.com/RajLabMSSM/echoconda/actions)
[![](https://codecov.io/gh/RajLabMSSM/echoconda/branch/main/graph/badge.svg)](https://app.codecov.io/gh/RajLabMSSM/echoconda)
<br>
<a href='https://app.codecov.io/gh/RajLabMSSM/echoconda/tree/main' target='_blank'><img src='https://codecov.io/gh/RajLabMSSM/echoconda/branch/main/graphs/icicle.svg' title='Codecov icicle graph' width='200' height='50' style='vertical-align: top;'></a>
<h4>
Authors: <i>Brian Schilder, Jack Humphrey, Towfique Raj</i>
</h4>
<h5>
README updated: <i>Feb-11-2024</i>
</h5>

## `echoconda`: Various utility functions to find, build, and use conda environments from within R.

This R package is part of the *echoverse* suite that supports
[`echolocatoR`](https://github.com/RajLabMSSM/echolocatoR): an automated
Expand Down
10 changes: 10 additions & 0 deletions inst/conda/ontogpt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: ontogpt
channels:
- conda-forge
- bioconda
- nodefaults
dependencies:
- python>=3.9
- poetry
- pip:
- ontogpt
13 changes: 13 additions & 0 deletions inst/conda/plotly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: plotly
channels:
- conda-forge
- bioconda
- plotly
- nodefaults
dependencies:
- python>=3.7
- plotly
- plotly-orca
- python-kaleido
- r-plotly
- pip
Loading

0 comments on commit 2d5e13e

Please sign in to comment.