Skip to content

Commit

Permalink
use rmarkdown style vignettes. add Sys.getenv(VERBOSE) to messager. u…
Browse files Browse the repository at this point in the history
…pdate rworkflows
  • Loading branch information
bschilder committed Dec 9, 2023
1 parent b89a974 commit e89679c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 45 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/rworkflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,3 @@ jobs:
has_latex: ${{ false }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run_docker: ${{ true }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
runner_os: ${{ runner.os }}
cache_version: cache-v1
docker_registry: ghcr.io
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Suggests:
rmarkdown,
remotes,
knitr,
BiocStyle,
testthat (>= 3.0.0),
utils
RoxygenNote: 7.2.3
Expand Down
4 changes: 3 additions & 1 deletion R/messager.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#'
#' @return Null
#' @keywords internal
messager <- function(..., v = TRUE, parallel = FALSE) {
messager <- function(...,
v = Sys.getenv("VERBOSE")!="FALSE",
parallel = FALSE) {

message_parallel <- function(...) {
system(sprintf('echo "%s"', paste0(..., collapse = "")))
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ output:

```{r, echo=FALSE, include=FALSE}
pkg <- read.dcf("DESCRIPTION", fields = "Package")[1]
title <- read.dcf("DESCRIPTION", fields = "Title")[1]
title <- gsub("\n"," ",read.dcf("DESCRIPTION", fields = "Title")[1])
description <- gsub("\n"," ",read.dcf("DESCRIPTION", fields = "Description")[1])
URL <- read.dcf('DESCRIPTION', fields = 'URL')[1]
owner <- strsplit(URL,"/")[[1]][4]
Expand Down
2 changes: 1 addition & 1 deletion inst/hex/hexSticker.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "hexSticker"
date: "<h4>Updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
output:
BiocStyle::html_document
rmarkdown::html_document
vignette: >
%\VignetteIndexEntry{hexSticker}
%\VignetteEngine{knitr::rmarkdown}
Expand Down
2 changes: 1 addition & 1 deletion man/messager.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 37 additions & 27 deletions vignettes/docker.Rmd
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
---
title: "Docker/Singularity Containers"
author: "<h4>Authors: <i>`r auths <- eval(parse(text = gsub('person','c',read.dcf('../DESCRIPTION', fields = 'Authors@R'))));paste(auths[names(auths)=='given'],auths[names(auths)=='family'], collapse = ', ')`</i></h4>"
date: "<h4>Vignette updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
title: Docker/Singularity Containers
author: '<h4>Authors: <i>`r auths <- eval(parse(text = gsub("person","c",read.dcf("../DESCRIPTION",
fields = "Authors@R"))));paste(auths[names(auths)=="given"],auths[names(auths)=="family"],
collapse = ", ")`</i></h4>'
date: '<h4>Vignette updated: <i>`r format( Sys.Date(), "%b-%d-%Y")`</i></h4>'
output:
BiocStyle::html_document:
md_extensions: [
"-autolink_bare_uris"
]
rmarkdown::html_document:
md_extensions: -autolink_bare_uris
params:
docker_org:
value: "neurogenomicslab"
vignette: >
%\VignetteIndexEntry{docker}
%\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
cont:
value: ghcr.io/neurogenomics/templateR
docker_registry:
value: ghcr.io
docker_org:
value: neurogenomics
vignette: |
%\VignetteIndexEntry{docker}
%\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
---


```{r setup, include=FALSE}
#### Package name ####
pkg <- read.dcf("../DESCRIPTION", fields = "Package")[1]
library(pkg, character.only = TRUE)
PKG <- read.dcf("../DESCRIPTION", fields = "Package")[1]
library(PKG, character.only = TRUE)
## Docker containers must be lowercase
pkg <- tolower(pkg)
pkg <- tolower(PKG)
#### Username of DockerHub account ####
docker_org <- params$docker_org
docker_registry <- params$docker_registry
cont <- params$cont
docker_url <- if(grepl("ghcr.io",docker_registry)){
paste("https://ghcr.io",cont,sep="/")
} else {
paste("https://hub.docker.com/repository/docker",docker_org,pkg,sep="/")
}
```

# DockerHub
# Installation

`r pkg` is now available via
[DockerHub](https://hub.docker.com/repository/docker/`r docker_org`/`r pkg`)
`r PKG` is now available via [`r docker_registry`](`r docker_url`)
as a containerised environment with Rstudio and
all necessary dependencies pre-installed.

## Installation

## Method 1: via Docker

First, [install Docker](https://docs.docker.com/get-docker/)
Expand All @@ -45,7 +54,7 @@ Create an image of the [Docker](https://www.docker.com/) container
in command line:

```
docker pull `r docker_org`/`r pkg`
docker pull `r cont`
```

Once the image has been created, you can launch it with:
Expand All @@ -58,7 +67,7 @@ docker run \
-v ~/Desktop:/Desktop \
-v /Volumes:/Volumes \
-p 8900:8787 \
`r docker_org`/`r pkg`
`r cont`
```

### NOTES
Expand All @@ -68,21 +77,22 @@ docker run \
* The `-d` ensures the container will run in "detached" mode,
which means it will persist even after you've closed your command line session.
* The username will be *"rstudio"* by default.
* Optionally, you can also install the [Docker Desktop](https://www.docker.com/products/docker-desktop)
* Optionally, you can also install the [Docker Desktop](https://www.docker.com/products/docker-desktop/)
to easily manage your containers.

## Method 2: via Singularity

If you are using a system that does not allow Docker
(as is the case for many institutional computing clusters),
you can instead [install Docker images via Singularity](https://sylabs.io/guides/2.6/user-guide/singularity_and_docker.html).
you can instead [install Docker images via Singularity](https://docs.sylabs.io/guides/2.6/user-guide/singularity_and_docker.html).

```
singularity pull docker://`r docker_org`/`r pkg`
singularity pull docker://`r cont`
```

For troubleshooting, see the [Singularity documentation](https://docs.sylabs.io/guides/latest/user-guide/singularity_and_docker.html#github-container-registry).

## Usage
# Usage

Finally, launch the containerised Rstudio by entering the
following URL in any web browser:
Expand Down
19 changes: 10 additions & 9 deletions vignettes/templateR.Rmd
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
---
title: "Getting Started"
author: "<h4>Authors: <i>`r auths <- eval(parse(text = gsub('person','c',read.dcf('../DESCRIPTION', fields = 'Authors@R'))));paste(auths[names(auths)=='given'],auths[names(auths)=='family'], collapse = ', ')`</i></h4>"
date: "<h4>Vignette updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
output:
BiocStyle::html_document
vignette: >
%\VignetteIndexEntry{Getting Started}
%\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
title: Get started
author: '<h4>Authors: <i>`r auths <- eval(parse(text = gsub("person","c",read.dcf("../DESCRIPTION",
fields = "Authors@R"))));paste(auths[names(auths)=="given"],auths[names(auths)=="family"],
collapse = ", ")`</i></h4>'
date: '<h4>Vignette updated: <i>`r format( Sys.Date(), "%b-%d-%Y")`</i></h4>'
output: rmarkdown::html_document
vignette: |
%\VignetteIndexEntry{templateR}
%\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
---


Expand Down

0 comments on commit e89679c

Please sign in to comment.