Skip to content

Commit 059489c

Browse files
committed
Add force=TRUE when installing local repo [skip ci]
1 parent c0dabce commit 059489c

16 files changed

+614
-549
lines changed

.Rhistory

Lines changed: 477 additions & 477 deletions
Large diffs are not rendered by default.

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ Suggests:
5757
jsonlite,
5858
BiocStyle,
5959
BiocPkgTools,
60-
biocViews
60+
biocViews,
61+
reticulate
6162
VignetteBuilder: knitr
6263
License: GPL-3
6364
Config/testthat/edition: 3

NEWS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,21 @@
1212
- `channels`
1313
- New function to construct conda env yaml files:
1414
- `construct_conda_yml`
15+
- New unit tests to test `construct_conda_yml` and building conda envs
16+
from the generated yamls.
1517
* `fill_yaml`
1618
- Add subfunction `is_default`
1719

20+
## Bug fixes
21+
22+
* `no visible global function definition for internal function check_miniconda_args`
23+
- This weird error only came up during Rstudio R CMD checks.
24+
The function `check_miniconda_args` was clearly defined in its own file.
25+
The only way to fix it was copying the function into the same one where it
26+
was called `fill_yaml`.
27+
- Thought it might be a permissions issues with *check_miniconda_args.R* but
28+
the permissions are identical with all the others.
29+
1830
# rworkflows 0.99.13
1931

2032
## New features

R/check_miniconda_args.R

Lines changed: 0 additions & 43 deletions
This file was deleted.

R/conda_installed.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
conda_installed <- function(){
2+
requireNamespace("reticulate")
3+
utils::getFromNamespace("conda_installed","reticulate")()
4+
}

R/condaenv_exists.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
condaenv_exists <- function(...){
2+
requireNamespace("reticulate")
3+
utils::getFromNamespace("condaenv_exists","reticulate")(...)
4+
}

R/construct_conda_yml.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
#' @export
1818
#' @importFrom yaml read_yaml
1919
#' @examples
20-
#' yml <- construct_conda_yml(name="sc_env",
20+
#' yml <- construct_conda_yml(name="myenv",
2121
#' dependencies=c("anndata","scanpy"),
22-
#' return_path = FALSE)
22+
#' return_path = FALSE,
23+
#' ## Writing to temp only for example
24+
#' save_path=tempfile(fileext="myenv_conda.yml"))
2325
construct_conda_yml <- function(name = "test",
2426
channels = list("conda-forge",
2527
"nodefaults"),
@@ -34,13 +36,16 @@ construct_conda_yml <- function(name = "test",
3436
){
3537
# devoptera::args2vars(construct_conda_yml)
3638

39+
if(is.vector(dependencies)) dependencies <- as.list(dependencies)
40+
if(is.vector(pip)) pip <- as.list(pip)
3741
yml <- list(
3842
name=name,
3943
channels=channels,
4044
dependencies=dependencies
4145
)
4246
if(!is.null(pip)){
43-
yml[["pip"]] <- pip
47+
yml[["dependencies"]] <- c(unique(c(yml[["dependencies"]],"pip")),
48+
list(list(pip=pip)))
4449
}
4550
#### Preview ####
4651
if(isTRUE(preview)){
@@ -50,6 +55,7 @@ construct_conda_yml <- function(name = "test",
5055
path_or_yaml <- return_yaml(yml=yml,
5156
path=save_path,
5257
return_path=return_path,
53-
verbose=verbose)
58+
verbose=verbose,
59+
indent.mapping.sequence = TRUE)
5460
return(path_or_yaml)
5561
}

R/fill_yaml.R

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,50 @@ fill_yaml <- function(## function-level args
106106
}
107107
return(yml)
108108
}
109+
110+
111+
#' Check Miniconda arguments
112+
#'
113+
#' Check Miniconda arguments for compatibility with one another.
114+
#' @inheritParams use_workflow
115+
#' @returns Named list of updated args.
116+
#'
117+
#' @keywords internal
118+
check_miniconda_args <- function(runners,
119+
miniforge_variant,
120+
miniforge_version,
121+
activate_environment,
122+
environment_file,
123+
channels,
124+
verbose=TRUE){
125+
126+
for(a in c("miniforge_version",
127+
"environment_file",
128+
"activate_environment")){
129+
if(!is_default(arg=a, val=get(a), func="use_workflow") &&
130+
isFALSE(miniforge_variant)){
131+
messager(a,"supplied. Enabling miniforge.", v=verbose)
132+
miniforge_variant <- TRUE
133+
}
134+
}
135+
#### Check if python-version set ####
136+
if(isTRUE(miniforge_variant)) {
137+
#### Check runners ####
138+
for(r in runners){
139+
if(is.null(r$`python-version`)){
140+
messager("python-version not set for runner",
141+
paste0("os=",shQuote(r$os),"."),
142+
"Using default.",v=verbose)
143+
}
144+
}
145+
}
146+
if(isTRUE(miniforge_variant)) miniforge_variant <- ""
147+
return(list(
148+
miniforge_variant=miniforge_variant,
149+
miniforge_version=miniforge_version,
150+
activate_environment=activate_environment,
151+
environment_file=environment_file,
152+
channels=channels
153+
))
154+
}
155+

R/return_yaml.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
return_yaml <- function(yml,
22
path,
33
return_path,
4-
verbose=TRUE){
4+
handlers=NULL,
5+
verbose=TRUE,
6+
...){
57
if(!is.null(path)){
68
save_yaml(yml=yml,
79
path=path,
8-
verbose=verbose)
10+
handlers=handlers,
11+
verbose=verbose,
12+
...)
913
#### Return ####
1014
if(isTRUE(return_path)){
1115
return(path)

R/save_yaml.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
save_yaml <- function(yml,
22
path,
3-
verbose=TRUE){
3+
handlers=NULL,
4+
verbose=TRUE,
5+
...){
46

57
dir.create(dirname(path),showWarnings = FALSE, recursive = TRUE)
68
messager("Saving yaml ==>",path,v=verbose)
79
#### Write bools as true/false rather than yes/no (default) ####
8-
handlers2 <- list('bool#yes' = function(x){"${{ true }}"},
9-
'bool#no' = function(x){"${{ false }}"})
10-
yml2 <- yaml::yaml.load(yaml::as.yaml(yml),
11-
handlers = handlers2)
12-
yaml::write_yaml(x = yml2,
10+
if(!is.null(handlers)){
11+
yml <- yaml::yaml.load(yaml::as.yaml(yml),
12+
handlers = handlers)
13+
}
14+
yaml::write_yaml(x = yml,
1315
file = path)
1416
}

0 commit comments

Comments
 (0)