How to Write and Share Replicable Research Code

press S key to access slide notes, F : back to presentation view
log EDUC University of Rennes logo Jaume Primero universitat logo

what is actualy doing Open Science

Open Science is about :

  • sharing things by making them findable and accessible
  • adapting them to existing artifacts (interoperability)
  • preparing and documenting them so they could be reused (reusability)
  • opening them to contribution (specific for source code)

a source code is static…

…but the environment which it’s designed for is moving quickly…

…creating code is like building house of cards grounded on sand

“In modern software there are always dependencies. No one spells out the ones and zeros for the machine by hand, so we write towers of software built on towers of software built on towers of software. And these dependencies change”

📓 Fobbe (2024)

when older versions of dependencies disappear

  • they might disappear from the language repositories (Pypi)
  • they can also disappear from the forges where they were stored
  • and new versions appear to be non compatible with other components (such as in our example)

Guix as a package manager offers solutions to those prooblems

  • Guix provides fully consistent computational environments in only two config files (manifest and channels)
  • these config files track all packages used with their own version and the dependencies to these packages
  • if a dependency cannot be found online anymore, a fall-back system links missing components to their archived counterparts in Software Heritage (1)
  • Guix can be used on Windows through WSL2
  • guix allows to run on a single computer a script with different versions of the same package without any conflict
  • for non-guix users, guix easily packages the software into a Docker container (2)
  1. 📓 Courtès et al. (2024)
  2. 📓 Tournier (2024)

example

Guix users need only two config files to reproduce the environment or a past experience :

  • manifest.scm : enumerate all the dependencies (system and software)
  • channels.scm : defines their exact version
guix time-machine --channels=channels.scm -- shell --manifest=manifest.scm \
-- Rscript myscript.R

Thanks to Guix maintainers, writing code feels a bit less like “writing in the sand”

references

Courtès, L., Sample, T., Tournier, S., & Zacchiroli, S. (2024, June). Source code archiving to the rescue of reproducible deployment. Proceedings of the 2024 ACM Conference on Reproducibility and Replicability, Proceedings of the 2024 ACM Conference on Reproducibility and Replicability. https://doi.org/10.1145/3641525.3663622
Fobbe, S. (2024). The Limits of Reproducibility with Rocker Docker Images for R (posts). https://seanfobbe.com/posts/2024-12-16_reproducibility-limits-rocker-docker-images-r/.
Tournier, S. (2024, December). (Re)déploiement de conteneurs et machines virtuelles avec guix. JRES (Journées Réseaux de l’enseignement Et de La Recherche ) 2024.