Skip to content

Containerized Development Environments for R

Atharva Shirdhankar edited this page Apr 1, 2023 · 5 revisions

Background

​ The standard development process used by members of the R Core Team involves an iterative process of making changes to the source code, re-building R and exploring/testing the changes made. This process presents a big hurdle for new contributors to R, as setting up their system to build R can be non-trivial, requiring a lot of trouble-shooting, especially on Windows and macOS. On Linux and macOS, it is not straight-forward to work with different versions of R side-by-side and care needs to be taken not to corrupt or over-write the user's existing version of R/R packages.

For these reasons, we propose to create containerized development environments for R. Our focus will be on creating a complete environment, including an IDE, that will provide a familiar space for R developers to work on contributions to base R. ​

Related work

​ The Rocker project provides many Docker containers for R, including the r-devel image that is updated daily with the development version of R ("R-devel"). This is useful for testing code in R-devel, for example, to find out if a bug reported in an earlier version of R is still an issue. Since the image also includes Subversion, it should be possible to check out the absolute latest version of R-devel from the repository at https://svn.r-project.org/R/ and re-build R. However, a contributor would need to have Docker installed locally (non-trivial on Windows) and use R through the terminal, which is unfamiliar to people who are used to developing in an IDE such as RStudio or VS Code. Other variations may be helpful for our context, for example we may wish to include git, so that contributors can make a pull request to the git mirror of the R subversion repository, to take advantage of the continuous integration that tests pull requests on several platforms and to make their patch available for peer review. ​

Details of your coding project

​ We have put together a proof-of-concept on GitHub that allows a development environment to be started in GitHub Codespaces. The contributor will refine this proof of concept to create a useful resource for the contributor community. The activities can be tailored to the skills and interest of the contributor, but may involve: ​

  • Improving the speed of starting the container/re-building R within the container. For example, by using a smaller base image, tweaking the build environment or writing bash scripts to manage downloading, building and setting the active R version. ​
  • Working through case studies to help test and refine the workflow, e.g. making a change to documentation, making a change to R code or making a change to compiled code (C/Fortran). ​
  • Creating variants of the container optimized for different use cases. ​
  • Writing documentation on how to use the container(s), perhaps as a section in the R Development Guide or a stand-alone website. ​
  • Creating short video demos working through different case studies. ​

Expected impact

​ The containers created in this project might be used locally, providing a standard environment that does not conflict with the local set-up, with a convenient interface for working on code/documentation. However, we expect the most useful outcome of this project to be a full development environment that can be used online, subject to resource limitations (an individual may use the proof of concept GitHub Codespace for up to 80 hours a month for free).

With no local set up, this will make it quicker and easier for people to get a development environment for R up and running. This will be helpful for people making one-off contributions, who do not want to invest time setting up their system to build R. Even for people interested in contributing longer-term, it will allow them to focus on the interesting work of code/documentation development rather than trouble-shooting build issues. This will be particular helpful for events designed for new R contributors where there is limited time available. ​

Mentors

​ Contributors, please contact mentors below after completing at least one of the tests below. ​

  • EVALUATING MENTOR: Heather Turner [email protected] chairs the R Contribution Working Group and is an author of several CRAN packages, notably the statistical modelling packages gnm, BradleyTerry2 and PlackettLuce. She was a GSoC co-mentor in 2021 and 2022.
  • James Tripp [email protected] is an author of the backfillz, grapho, and le-cat packages.

You can discuss this project with the mentors on the R Contributors Slack, either the on the public #gsoc channel or by direct message. ​

Tests

​ Contributors, please do one or more of the following tests before contacting the mentors above.

  • Easy: Go to the proof-of-concept repository and start the GitHub Codespace by clicking on the "Code" drop-down menu, clicking the "Codespaces"" tab and selecting "Create codespace on main". It will take several minutes to set up the codespace. Open a new file with a .R extension and click "R (not attached)" in the VS Code footer to attach to an active R terminal. Write a simple line of R code in your R script and run it. Take a screenshot of your R session. ​

  • Medium: Start the codespace in the proof-of-concept repository as detailed in the Easy task. Write a script (in R/Python/bash) to download and compile a tarball of the R development source code from CRAN. To build the R source code you can follow the Simple compilation instructions in the R Installation and Administration manual. Take a screenshot of your script and the newly compiled version of R running in a terminal, that shows the version of R. ​

  • Medium: Write a brief description (< 200 words) of how the proof-of-concept works. Describe how you think the proof-of-concept could be improved. ​

  • Hard: Install docker and VSCode on your OS, download the proof-of-concept repository and start the dev container. Build R within the dev container and start R. Take a screenshot.

  • Hard: Once you are able to build R within the codespace or locally on your OS, modify or add a function in one of the base R packages and re-build R. Take a screenshot that shows your new/modified function working in the dev container and provide a brief description (< 100 words) of your modification. ​

  • Hard: Read through the dockerfile in the proof-of-concept repository and the R development image hosted in a different repository. Modify and improve the dockerfile in some way. Provide the modified dockerfile and a short rationale (< 200 words) for the changes you made. ​

Solutions of tests

​ Contributors, please post a link to your test results here. - EXAMPLE CONTRIBUTOR 1 NAME, LINK TO GITHUB PROFILE, LINK TO TEST RESULTS.

Atharva Shirdhankar | Github Profile | Easy Test Result | Medium Test 1 Result | Medium Test 2 Result | Hard Test 1 Result | Hard Test 2 Result | Hard Test 3 Result