Making Code Contributions Seamless

with R Dev Container

18th November 2024 @ LatinR 2024

Little Bit About me

  • šŸ‘‹ Hi Everyone, Iā€™m Atharva Shirdhankar a Backend and DevOps enthusiast, with a passion for seamless systems and tech tinkering with Raspberry Pi!

  • šŸ’» 2x Google Summer of Code Mentee 2023 and 2024 @R project for statistical computing

  • šŸ“ˆ 2x Devto Hackathon Runner-Up (Github Actions 2021, Azure Trail 2022)

  • šŸ”— Lets Connect : Linkedin/@atharvashirdhankar Github/@StarTrooper08

About the R Dev Container Project

  • Tech Stack: R Dev Container is built with Linux, Bash, and Docker, designed for seamless integration with GitHub Codespaces and Gitpod.

linux--v1 bash docker

  • Goal: Enable a quick, seamless setup of the R development environment, allowing contributors to start coding with just a few clicks.

  • Benefit: Lowers the entry barrier for new contributors, reducing setup friction and making it easier to contribute to the R project.

R Dev Container Quick Setup

  • Visit the R Dev Container https://github.com/r-devel/r-dev-env.

  • Click on Code button and change the tab to Codespaces

  • After that Click on ā€œCreate Codespace on mainā€

  • You can also run R program. To do so, you need to click on R: not attached option in status bar(botton right). This will open up a R interactive console.

  • Just create a R file and run it using the run button on the top beside file tabs.

R Contribution Workflow

Find a Bug Report on Bugzilla

  • R Bugzilla - Open bug report list

  • Example Bug - 18810 ā€œImprove error for readRDS by including filenameā€. Potential Solution to this issue is also mentioned by Jeroen Ooms in the discussion.

Building R

Bug Report Statement

  • readRDS errors do not indicate the filename or connection source, leading to generic ā€œerror reading from connectionā€ messages.
install.packages('MASS')
rdsfile <- system.file('Meta/links.rds', package = 'MASS')
unlink(rdsfile)
file.create(rdsfile) #create corrupted file
tools::findHTMLlinks() #errors without clues

Output with Error msg

** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (MASS)

The downloaded source packages are in
        ā€˜/tmp/RtmpMuQ5kv/downloaded_packagesā€™
[1] TRUE
Error in readRDS(f) : error reading from connection

Code Contribution

  • Updating readRDS() function in src/library/base/R/serialize.R file.

    } else if (inherits(file, "connection"))
    con <- if(inherits(file, "url")) gzcon(file) else file
    else stop("bad 'file' argument")
    .Internal(unserializeFromConn(con, refhook))
    
    tryCatch(.Internal(unserializeFromConn(con, refhook)), error = function(err){
        err$message <- paste(err$message, "in", summary(con)$description)
        stop(err)
    })
}

Building R again with new Changes

  • After we have made relevant changes we can just use the following commands to build R again with latest changes.
cd $BUILDDIR
make
make check
  • Error msg after making relevant changes
* DONE (MASS)

The downloaded source packages are in
        ā€˜/tmp/RtmpsOVPcD/downloaded_packagesā€™
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
[1] TRUE
Error in doTryCatch(return(expr), name, parentenv, handler) : 
  error reading from connection in /workspace/r-dev-env/build/r-rdevel/library/MASS/Meta/links.rds

Patch file

  • create a patch file for the code changes made. The following command will save the changes made in source code in $PATCHDIR directory.
cd $TOP_SRCDIR
svn diff > $PATCHDIR/patch.diff

Submit Patch File

Special Mentions

  • R Dev Container project Mentors : Heather Turner, James Tripp, Iain Emsley

  • A Blogpost on Fixing R graphics issues during R Dev Day Austria(July 2024) using R Dev Container - by Di Cook .

  • Some amazing contributors who helped us bring this project all together by contributing to docs, giving feedback and helping out in finding solutions Elio Campitelli, Lorena Abad Crespo, Robert (Bob) Turner and Dan Brady

Resources

R Dev Container Repo : https://github.com/r-devel/r-dev-env

R Dev Container Docs : https://contributor.r-project.org/r-dev-env/

R Slack Channel : https://r-contributors.slack.com/