forked from neurogenomics/rworkflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
720 additions
and
189 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 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
check_bioc_version <- function(bioc){ | ||
|
||
opts <- bioc_r_versions(return_opts = TRUE) | ||
bioc <- tolower(as.character(bioc)) | ||
if(bioc %in% c("release_*", | ||
"release*", | ||
"release")){ | ||
bioc <- "release" | ||
} else { | ||
bioc <- gsub("_",".",gsub("RELEASE_","",bioc, ignore.case = TRUE)) | ||
} | ||
if(!bioc %in% opts){ | ||
stopper(paste0("bioc=",shQuote(bioc)), | ||
"bioc version must be one of:", | ||
paste("\n -",shQuote(opts),collapse = "")) | ||
} else { | ||
return(bioc) | ||
} | ||
} |
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,44 @@ | ||
#' Check containers exist | ||
#' | ||
#' Check that a list of containers are valid. | ||
#' @inheritParams construct_runners | ||
#' @param domain Container repository API domain. | ||
#' @returns NUll | ||
#' | ||
#' @keywords internal | ||
check_cont <- function(cont, | ||
domain = "https://hub.docker.com/v2/repositories/", | ||
verbose = TRUE){ | ||
|
||
requireNamespace("jsonlite") | ||
for(co in cont){ | ||
if(is.null(co)) next() | ||
if(isFALSE(grepl("/",co))){ | ||
stopper("Container must be specificied in the following format:", | ||
"'owner/repo:tag'") | ||
} | ||
splt <- strsplit(co,":")[[1]] | ||
URL <- paste(domain, splt[1], | ||
"tags?page_size=1000",sep="/" | ||
) | ||
#### Check repo exists #### | ||
messager("Checking public container repository exists:",shQuote(splt[1]), | ||
v=verbose) | ||
js <- tryCatch({ | ||
jsonlite::read_json(URL) | ||
}, error=function(e){ | ||
stopper("Unable to find public container:",co) | ||
} | ||
) | ||
#### Check tag exists #### | ||
if(length(splt)==2){ | ||
messager("Checking tag exists:",shQuote(splt[2]), | ||
v=verbose) | ||
tags <- sapply(js$results ,function(x){x$name}) | ||
if(!splt[2] %in% tags){ | ||
stopper("The tag", shQuote(splt[2]), | ||
"does not exist in the repo",shQuote(splt[1])) | ||
} | ||
} | ||
} | ||
} |
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,67 @@ | ||
#' Construct containers list | ||
#' | ||
#' @param run_check_cont Check whether the requested container repo | ||
#' (and the tag, if specified) exist using \link[rworkflows]{check_cont}. | ||
#' @param default_cont The DockerHub container to default to. | ||
#' Used when it's detected that only the tag has been given in one or more | ||
#' \code{cont} entry. | ||
#' @param default_tag The DockerHub container tag to default to. | ||
#' @inheritParams construct_runners | ||
#' @returns Named list of containers | ||
#' | ||
#' @export | ||
#' @importFrom stats setNames | ||
#' @examples | ||
#' cont <- construct_cont() | ||
construct_cont <- function(default_cont = "bioconductor/bioconductor_docker", | ||
default_tag = "devel", | ||
cont = list( | ||
paste(default_cont,default_tag,sep=":"), | ||
NULL, | ||
NULL), | ||
versions_explicit = FALSE, | ||
run_check_cont = FALSE, | ||
verbose = TRUE){ | ||
# devoptera::args2vars(construct_cont) | ||
|
||
#### Remove any trailing : (e.g. when default_tag=NULL) #### | ||
cont <- lapply(cont, function(x){ | ||
if(is.null(x)) NULL else trimws(x,whitespace = ":") | ||
}) | ||
#### Run QC #### | ||
cont2 <- lapply(cont,function(co){ | ||
if(is.null(co)){ | ||
return(NULL) | ||
} else if(!grepl("/",co) && | ||
!is.null(default_cont)){ | ||
messager("Only tag name supplied to 'cont'.", | ||
"Assuming default=",shQuote(default_cont),v=verbose) | ||
co <- paste(default_cont,co,sep=":") | ||
} else if(!grepl(":",co) | | ||
!grepl(default_cont,co)) { | ||
return(co) | ||
} | ||
splt <- strsplit(co,":")[[1]] | ||
bioc_version <- rev(splt)[1] | ||
if(isTRUE(versions_explicit)){ | ||
if(grepl(":",co)){ | ||
info <- bioc_r_versions(bioc_version = bioc_version) | ||
return( | ||
paste0(splt[[1]],":RELEASE_",gsub("[.]","_",info$bioc)) | ||
) | ||
} else { | ||
return(co) | ||
} | ||
} else if(tolower(bioc_version)=="release"){ | ||
co <- gsub(":release",":latest",co, ignore.case = TRUE) | ||
} | ||
return(co) | ||
}) | ||
#### Check that the Dockerhub repo exists #### | ||
if(isTRUE(run_check_cont)){ | ||
check_cont(cont = cont, | ||
verbose = verbose) | ||
} | ||
#### Return #### | ||
return(cont2) | ||
} |
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
Oops, something went wrong.