The idea of Dev/Ops

Modern DevOps for Systems Biologists

Author
Affiliations

Jun Allard

Department of Mathematics

Department of Systems Biology

Department of Physics and Astronomy

University of California, Irvine

Why systems biologists need Dev/Ops now

Motivation 1 of 4: The elevation of computational and mathematical biology

A realization that dawned on me in March 2020.

Recent worldwide events have challenged the mathematical biology community.

  • A global pandemic put mathematical biology, and mathematical biologists, on the world stage — predictive epidemiology, in front of policy decision-makers.
  • To keep that impact and respect, our standards of rigor in coding have to be elevated to match our standards of rigor in mathematics.
  • The gap is troubling, because mathematical rigor has been a point of pride in the field. It is also an opportunity.

A tweet from Neil Ferguson, 22 March 2020. He writes that many people would like to see and run the pandemic simulation code being used to model control measures against COVID-19, and explains that he wrote it more than thirteen years earlier to model flu pandemics, as thousands of lines of undocumented C. A reply says Microsoft and GitHub are working with his group to document, refactor and extend the code so that others can use it without the several days of training it currently needs.

Motivation 2 of 4: A case where version control saved me

An early grad student convinced me to use version control: github.com/allardjun/a-typical-paper.

The plot we had

Fraction activated against force in piconewtons. The measured points, with error bars, sit on the solid two-state model curve all the way from 0 to 15 piconewtons, rising from near zero to saturation at one.

One day, while prepping the manuscript…

The same axes and the same model curve, from the data as the repository actually held it. The points follow the curve up to about 8 piconewtons and then peel away from it, flattening into a false plateau near 0.8 instead of continuing to saturation.

A tweet by John M. Mola, 5 May 2019. Finishing a PhD is like finishing a group project where your partner made a ton of mistakes at the beginning of the assignment. Except your partner is just you four years ago.

Motivation 3 of 4: The DevOps approach to science

Software development

Develop, operate, develop, operate, develop, operate.

One long magenta arrow labelled Development phase, ending at a downward arrow marked release, followed by one long purple arrow labelled Operations phase.

Ship something that runs, then make it better.

Six short arrows in a row, alternating magenta and purple, labelled Dev, Ops, Dev, Ops, Dev, Ops.

Building a car

Motor, chassis, wheels, frame, …

Four line drawings in a row: a single wheel, then a wheel and axle, then a bare chassis on wheels, then a finished car. Nothing before the last one can be driven.

Or: first build a bicycle.

Five line drawings in a row: a skateboard, a scooter, a bicycle, a motorbike, a car. Every one of them can be ridden. Credited to Henrik Kniberg.

Graduate school

Bench phase, then coffee-shop phase.

A long magenta arrow labelled benchwork phase, then a purple arrow, then a black arrow ending at the word paper, then a small final arrow labelled maybe release code.

Four short cycles of run, analyze, write up, drawn as alternating magenta and purple arrows. Each cycle drops a downward arrow to something citable: proposal preliminary work, then a poster, then a minimal publishable paper, then a high-impact paper.

A Graduate Journal column from Nature, volume 442, 27 July 2006, headed Lab makeover. A molecular-biology graduate student describes having imagined graduate school as erudite academics in coffee shops, and divides his own into a worker-bee period spent collecting data at the bench and a later coffee-shop phase spent thinking; he proposes combining the two rather than taking them in turn.

The DevOps approach is to make small-batch, continuous, end-to-end improvements.

Pros and cons of working this way

Cons

  • Wasteful. You don’t use a lot of what you do. Think of the industrial revolution and assembly lines.
  • Misses the advantages of scale that come from doing things in parallel.
  • Might invalidate statistical design — consider a randomized control trial.
  • A lot of time spent keeping different versions organized.

Pros

  • For any complex, uncertain project (i.e., science!), all the parts of the project gradually adapt to achieve the goal.
  • Reduces time-to-deadline uncertainty. Too slow or too unambitious? No problem.

A hand-drawn comparison against a deadline marked by a vertical line. One long arrow overshoots it. A second, shorter pair of arrows stops well short of it, beside an unhappy face. A row of many short alternating arrows reaches the line exactly, with faces below it going from unhappy to content as the row proceeds.

  • Empirically shown to reduce worker burnout (Humble & Kim 2018; Forsgren & Humble 2016).

So we are going to need easy, seamless version control.

Motivation 4 of 4: Supervising powerful-but-unreliable team members

  • At early career stages, you write the code.
  • For many career paths — including outside science, and outside coding — you eventually mentor, coach and supervise others.
  • Your job becomes helping them, critically testing their approaches, and catching bugs in their thinking.
  • You need a tool that lets them say what they are thinking, lets you revert if necessary, and gives you an opportunity to look over what they are contributing.

One stick figure standing beside a laptop, a magenta arrow running from the person to the laptop: you write the code yourself.

The same figure now at the left, with green arrows arcing across to four other people, each standing at a laptop of their own with its own magenta arrow: you direct a team, and each of them writes code.

The figure facing a small robot that stands at a laptop, a green double-headed arrow between the person and the robot and a magenta arrow from the robot to the laptop: you and an agentic coder, working back and forth.

In the age of agentic coders, the skill of supervising needs to be learned at earlier career stages.

Working with your past and future self

Version control with git

A hand-drawn horizontal timeline of commits: a line running left to right with a row of filled dots along it, each dot one commit, ending in an arrowhead at the present.

Advantage: bisection search for trouble. When something broke between here and there, git will help you halve the interval until you find it.

Vocabulary

  • repo
  • commit
  • stage / add
  • commit message
  • commit hash
  • HEAD
  • checkout - going to a different commit

Two different things

  • git — an open-source technology
  • GitHub — a company

git is already there

Git is already built in to almost all the software you interact with.

  • VSCode, Jupyter, MATLAB — full support, already installed.
  • Microsoft Office, Mathematica — it works, but misses some features.

Screenshots of three programs side by side, each with its own built-in git panel: Overleaf, MATLAB and Jupyter. Each shows a list of changed files and a place to write a commit message, without leaving the program.

Directory architecture and large data

Three boxes for one project. A folder of large data files, outside git. A git repository holding the code. A second git repository holding the manuscript and its figures. Arrows between them are labelled with commit hashes, so each place records which version of the others it goes with.

How we (the Allard group) organize a project — three places:

  1. Large files, outside of git, backed up (e.g., Google Drive, Dropbox, linux server rack).
  2. Code, in a git repo.
  3. Manuscript and figures, in another git repo (not shared).

The three locations share each other’s commit hashes, so every figure knows which commit it came from.

You can put large files in the git repo and reach for .gitignore instead — but the three-place split is what has held up.

Version control with git can be used smoothly for entire projects — analysis and write-ups, not just code. That is what lets you take a continuous-improvement “DevOps” approach, with the pros and cons above.

How often should you commit?

Ask what the action you just took actually was.

  • Running something to get a result — experiment
  • Adding a feature, mode or setting — feat
  • Fixing a bug or troubleshooting — bugfix
  • Refactoring, cleaning up or improving without adding new capabilities — refactor

A commit should not include more than one of those. “Make your commits more atomic”.

Committing is the one opportunity to slow down and think. Avoid automatic commits – this is not the time.

  • In revisions, one commit per Peer Reviewer comment (e.g., Reviewer1MajorComment3)

Working with a team

git fork, clone, branch, merge, pull request

Four git repositories drawn as hand-sketched circles, each holding its own row of commits. My GitHub account and Your GitHub account sit on the host at the top; my laptop and your laptop below. Magenta arrows mark push and pull between each account and its laptop, and a pull request from mine to yours. Purple arrows mark fork, from my account to yours, and clone, from my account down to my laptop.

In the cloud

GitHub, and other providers: companies, university servers, …

  • push, pull
  • clone
  • fork
  • pull request

The idea of repo ownership: taking is free, giving requires permission.

Advantages and disadvantages over automatic history, like Apple Time Machine or Google Docs.

Much we did not discuss

There is much we did not discuss.

  • Branching
  • Cherry-picking

Working with the world, across teams and time

Reproducibility, dependency, security and isolation

For your code to impact the scientific community, it should work across teams, computers, and dependency upgrades.

Three hand-drawn panels. On the left, one machine as a stack of boxes: Hardware at the bottom, Operating system above it, then Files holding a package called Pack v1.2, and Your code on top, with arrows running up from the package to the code. Red devil faces and arrows are scrawled either side of the stack. In the middle, the same stack headed Friend's computer, but the package is Pack v1.3 and a red cross blocks the arrow reaching Your code. On the right, two projects side by side: Pack v1.2 feeds Project 1, a red cross blocks it from feeding Project 2, and a magenta box reading v1.3 with two question marks points at Project 2 beside a frowning face.

“But it worked on my machine.”

Three levels of isolation

  • Continually assuring that it works on any machine, for any person, without you helping.
  • One project should not screw up another project, even on the same machine.
  • One actor — human? agent? — should not screw up another actor, even on the same machine.

The same stack of boxes, wrapped in three nested outlines. A magenta outline around Your code and Pack v1.2 is labelled virtual environment; a green outline that also takes in Files is labelled container; an orange outline that also takes in the operating system is labelled virtual machine. Hardware sits outside all three, and a second project sits alongside them.

Environments in Python, Conda, Julia, R and Matlab

Same idea everywhere: make a local copy of your dependencies, activate it, and record it so someone else can rebuild it.

Python

  • Older way: a venv, memorialized in requirements.txt; someone else recreates it with pip install -r requirements.txt.
  • Newer way: uv.lock; someone else recreates it with uv run.

Conda

  • Make one and switch to it: conda create -n myproject, then conda activate myproject.
  • Memorialized in environment.yml, written by conda env export; someone else recreates it with conda env create.

Julia

  • All dependencies needed by any project on this machine live in $JULIA_DEPOT.
  • Each project records what it needs in Project.toml and Manifest.toml.
  • Someone else recreates your environment from those.

Containerization: Docker and dev-containers

Some different things

  • containers — an open-source technology
  • Docker — a company
  • dev-container — the VSCode/GitHub/Microsoft specification for containers

The definition of the machine lives in a Dockerfile or in .devcontainer/devcontainer.json.

They are shorter than you might guess, because they layer on top of other people’s definitions:

"image": "mcr.microsoft.com/devcontainers/python:1-3.13-bookworm",

Both the Our Story activity and Activity 2 take place in containers. You can read their .devcontainer/devcontainer.json to see exactly how little is in there.

The four kinds of documentation, and the primacy of QUICKSTART.md

The standard classification of the kinds of documentation that good coders use:

  • references
  • tutorials
  • how-tos
  • explanations

One kind of how-to is QUICKSTART.md: instructions for someone else, starting from recreating the environment and ending at a generated output, e.g. a plot.

# QUICKSTART

Install [uv](https://docs.astral.sh/uv/) and then run:

```bash
uv sync
uv run python generate_kinetics_versus_length.py
```

This will generate `fig_kinetics.png`.

Keep QUICKSTART.md continuously up to date - know that someone else could run it without you — and you will find yourself at peace. It eliminates the “heroics” and “heist mode” at the end of a project.

Much we did not discuss

There is much we did not discuss.

  • Attribution, licensing (“Creative Commons”, “MIT”, “GPL”), confidentiality and harvesting and Open Science.
  • What makes a good commit message?
  • What makes a good end-to-end test? How do you come up with good end-to-end tests?