pracpac

Practical R Packaging with Docker

https://github.com/signaturescience/pracpac

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.4%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Practical R Packaging with Docker

Basic Info
Statistics
  • Stars: 34
  • Watchers: 6
  • Forks: 0
  • Open Issues: 3
  • Releases: 2
Created over 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License Citation

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# pracpac 


[![R-CMD-check](https://github.com/signaturescience/pracpac/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/signaturescience/pracpac/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/pracpac)](https://CRAN.R-project.org/package=pracpac)
[![arXiv](https://img.shields.io/badge/arXiv-2303.07876-b31b1b.svg)](https://arxiv.org/abs/2303.07876)


**pracpac**: Practical R Packaging with Docker

The goal of pracpac is to provide a usethis-like interface to create Docker images from R packages under development. The pracpac package uses renv by default, ensuring reproducibility by building dependency packages inside the container image mirroring those installed on the developer's system. The pracpac package can be used to containerize any R package and deploy with other domain-specific non-R tools, Shiny applications, or entire data analysis pipelines.

## Installation

Install pracpac from CRAN with:

```r
install.packages("pracpac")
```

Install the development version of pracpac from [GitHub](https://github.com/signaturescience/pracpac) with:

```r
# install.packages("devtools")
devtools::install_github("signaturescience/pracpac", build_vignettes = TRUE)
```

## Example

Detailed documentation is available in the [basic usage](https://signaturescience.github.io/pracpac/articles/basic-usage.html) and [use cases](https://signaturescience.github.io/pracpac/articles/use-cases.html) vignettes:

```{r, eval=FALSE}
vignette("basic-usage", package="pracpac")
vignette("use-cases", package="pracpac")
```

In the most simple example, running `use_docker()` inside of a package directory will (1) capture all the package dependencies installed on the developers system using [renv](https://rstudio.github.io), (2) build the package source tar.gz, (3) create a Dockerfile which builds an image with the package and its entire dependency chain, and (4) optionally builds a Docker image with tags set using the version in the package `DESCRIPTION`. The Dockerfile, `renv.lock` file, and the package source tar.gz file will all be placed into a `docker/` subdirectory of the package, which is added to the package's `.Rbuildignore`. The workflow is shown in the figure below.

![Pracpac workflow](man/figures/pracpac-workflow.png)

For example, running `use_docker()` in the example package included in pracpac at [inst/hellow](https://github.com/signaturescience/pracpac/tree/main/inst/hellow) will produce a Dockerfile with the following contents:

```Dockerfile
FROM rocker/r-ver:latest

## copy the renv.lock into the image
COPY renv.lock /renv.lock

## install renv and biocmanager
RUN Rscript -e 'install.packages(c("renv","BiocManager"), repos="https://cloud.r-project.org")'

## set the renv path var to the renv lib
ENV RENV_PATHS_LIBRARY renv/library

## restore packages from renv.lock
RUN Rscript -e 'renv::restore(lockfile = "/renv.lock", repos = NULL)'

## copy in built R package
COPY hellow_0.1.0.tar.gz /hellow_0.1.0.tar.gz

## run script to install built R package from source
RUN Rscript -e "install.packages('/hellow_0.1.0.tar.gz', type='source', repos=NULL)"
```

And an `renv.lock` with the dependencies of `hellow` (in this case just the `praise` package):

```json
{
  "R": {
    "Version": "4.0.2",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://cran.rstudio.com"
      }
    ]
  },
  "Packages": {
    "praise": {
      "Package": "praise",
      "Version": "1.0.0",
      "Source": "Repository",
      "Repository": "CRAN",
      "Hash": "a555924add98c99d2f411e37e7d25e9f",
      "Requirements": []
    }
  }
}
```

By default, `use_docker()` does not actually build the image. You can build the image with `build_image()` after running `use_docker()`, or in one step using `use_docker(build=TRUE)`. This two-step procedure is useful because other use cases may require edits to the Dockerfile to install system libraries, or copy in Shiny app or pipeline-specific code. See the [help page for `?use_docker`](https://signaturescience.github.io/pracpac/reference/use_docker.html) and the [use cases vignette](https://signaturescience.github.io/pracpac/articles/use-cases.html) (`vignette("use-cases", package="pracpac")`) for details.

Owner

  • Name: Signature Science
  • Login: signaturescience
  • Kind: organization
  • Location: Austin, TX

Citation (CITATION.cff)

# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.4.1
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------
 
cff-version: 1.2.0
message: 'To cite package "pracpac" in publications use:'
type: software
license: MIT
title: 'pracpac: Practical R Packaging in Docker'
version: 0.1.0
abstract: Streamline the creation of Docker images with R packages and dependencies
  embedded. The pracpac package provides a usethis-like interface to creating Dockerfiles
  with dependencies managed by renv.
authors:
- family-names: Turner
  given-names: Stephen
  orcid: https://orcid.org/0000-0001-9140-9028
- family-names: Nagraj
  given-names: VP
  email: nagraj@nagraj.net
  orcid: https://orcid.org/0000-0003-0060-566X
url: https://signaturescience.github.io/pracpac/
contact:
- family-names: Nagraj
  given-names: VP
  email: nagraj@nagraj.net
  orcid: https://orcid.org/0000-0003-0060-566X
references:
- type: software
  title: magrittr
  abstract: 'magrittr: A Forward-Pipe Operator for R'
  notes: Imports
  url: https://magrittr.tidyverse.org
  repository: https://CRAN.R-project.org/package=magrittr
  authors:
  - family-names: Bache
    given-names: Stefan Milton
    email: stefan@stefanbache.dk
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  year: '2023'
- type: software
  title: glue
  abstract: 'glue: Interpreted String Literals'
  notes: Imports
  url: https://glue.tidyverse.org/
  repository: https://CRAN.R-project.org/package=glue
  authors:
  - family-names: Hester
    given-names: Jim
    orcid: https://orcid.org/0000-0002-2739-7082
  - family-names: Bryan
    given-names: Jennifer
    email: jenny@rstudio.com
    orcid: https://orcid.org/0000-0002-6983-2759
  year: '2023'
- type: software
  title: fs
  abstract: 'fs: Cross-Platform File System Operations Based on ''libuv'''
  notes: Imports
  url: https://fs.r-lib.org
  repository: https://CRAN.R-project.org/package=fs
  authors:
  - family-names: Hester
    given-names: Jim
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  - family-names: Csárdi
    given-names: Gábor
    email: csardi.gabor@gmail.com
  year: '2023'
- type: software
  title: rprojroot
  abstract: 'rprojroot: Finding Files in Project Subdirectories'
  notes: Imports
  url: https://rprojroot.r-lib.org/
  repository: https://CRAN.R-project.org/package=rprojroot
  authors:
  - family-names: Müller
    given-names: Kirill
    email: krlmlr+r@mailbox.org
    orcid: https://orcid.org/0000-0002-1416-3412
  year: '2023'
- type: software
  title: renv
  abstract: 'renv: Project Environments'
  notes: Imports
  url: https://rstudio.github.io/renv/
  repository: https://CRAN.R-project.org/package=renv
  authors:
  - family-names: Ushey
    given-names: Kevin
    email: kevin@rstudio.com
  year: '2023'
- type: software
  title: pkgbuild
  abstract: 'pkgbuild: Find Tools Needed to Build R Packages'
  notes: Imports
  url: https://github.com/r-lib/pkgbuild
  repository: https://CRAN.R-project.org/package=pkgbuild
  authors:
  - family-names: Wickham
    given-names: Hadley
  - family-names: Hester
    given-names: Jim
  - family-names: Csárdi
    given-names: Gábor
    email: csardi.gabor@gmail.com
  year: '2023'
- type: software
  title: 'R: A Language and Environment for Statistical Computing'
  notes: Depends
  url: https://www.R-project.org/
  authors:
  - name: R Core Team
  location:
    name: Vienna, Austria
  year: '2023'
  institution:
    name: R Foundation for Statistical Computing
  version: '>= 2.10'
- type: software
  title: rmarkdown
  abstract: 'rmarkdown: Dynamic Documents for R'
  notes: Suggests
  url: https://pkgs.rstudio.com/rmarkdown/
  repository: https://CRAN.R-project.org/package=rmarkdown
  authors:
  - family-names: Allaire
    given-names: JJ
    email: jj@rstudio.com
  - family-names: Xie
    given-names: Yihui
    email: xie@yihui.name
    orcid: https://orcid.org/0000-0003-0645-5666
  - family-names: McPherson
    given-names: Jonathan
    email: jonathan@rstudio.com
  - family-names: Luraschi
    given-names: Javier
    email: javier@rstudio.com
  - family-names: Ushey
    given-names: Kevin
    email: kevin@rstudio.com
  - family-names: Atkins
    given-names: Aron
    email: aron@rstudio.com
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  - family-names: Cheng
    given-names: Joe
    email: joe@rstudio.com
  - family-names: Chang
    given-names: Winston
    email: winston@rstudio.com
  - family-names: Iannone
    given-names: Richard
    email: rich@rstudio.com
    orcid: https://orcid.org/0000-0003-3925-190X
  year: '2023'
- type: software
  title: knitr
  abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
  notes: Suggests
  url: https://yihui.org/knitr/
  repository: https://CRAN.R-project.org/package=knitr
  authors:
  - family-names: Xie
    given-names: Yihui
    email: xie@yihui.name
    orcid: https://orcid.org/0000-0003-0645-5666
  year: '2023'
- type: software
  title: testthat
  abstract: 'testthat: Unit Testing for R'
  notes: Suggests
  url: https://testthat.r-lib.org
  repository: https://CRAN.R-project.org/package=testthat
  authors:
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  year: '2023'
  version: '>= 3.0.0'
- type: software
  title: withr
  abstract: 'withr: Run Code ''With'' Temporarily Modified Global State'
  notes: Suggests
  url: https://withr.r-lib.org
  repository: https://CRAN.R-project.org/package=withr
  authors:
  - family-names: Hester
    given-names: Jim
  - family-names: Henry
    given-names: Lionel
    email: lionel@rstudio.com
  - family-names: Müller
    given-names: Kirill
    email: krlmlr+r@mailbox.org
  - family-names: Ushey
    given-names: Kevin
    email: kevinushey@gmail.com
  - family-names: Wickham
    given-names: Hadley
    email: hadley@rstudio.com
  - family-names: Chang
    given-names: Winston
  year: '2023'

GitHub Events

Total
  • Issues event: 3
  • Watch event: 9
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 2
  • Pull request event: 2
  • Create event: 2
Last Year
  • Issues event: 3
  • Watch event: 9
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 2
  • Pull request event: 2
  • Create event: 2

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 54
  • Total pull requests: 51
  • Average time to close issues: 4 days
  • Average time to close pull requests: about 4 hours
  • Total issue authors: 3
  • Total pull request authors: 2
  • Average comments per issue: 2.3
  • Average comments per pull request: 0.33
  • Merged pull requests: 47
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 1
  • Average time to close issues: 28 minutes
  • Average time to close pull requests: less than a minute
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • vpnagraj (32)
  • stephenturner (20)
  • zkamvar (1)
Pull Request Authors
  • vpnagraj (30)
  • stephenturner (22)
Top Labels
Issue Labels
bug (2) enhancement (2)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 715 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: pracpac

Practical 'R' Packaging in 'Docker'

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 715 Last month
Rankings
Forks count: 28.8%
Dependent packages count: 29.8%
Stargazers count: 35.2%
Dependent repos count: 35.5%
Average: 43.8%
Downloads: 89.5%
Maintainers (1)
Last synced: 10 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 2.10 depends
  • fs * imports
  • glue * imports
  • magrittr * imports
  • pkgbuild * imports
  • renv * imports
  • rprojroot * imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat >= 3.0.0 suggests
  • withr * suggests
inst/hellow/DESCRIPTION cran
  • praise * imports
inst/ocf/DESCRIPTION cran
  • wesanderson * imports
inst/example/hellow/Dockerfile docker
  • rocker/r-ver latest build