Skip to main content

Rair - Research Archival & Integrity Recorder

Rair is a CLI-tool for simple data versioning.

When running experiments, model parameters and model details needs to be tweaked frequently. Committing minimal changes clutters the git history and makes it hard to track actual program modifications. Rair allows to link computation results to exact code versions without the need to commit all changes to git. Therefore it stores code diffs alongside the git commit reference. It tracks input and intermediate data as well to guarantee full reproducibility for every run.

Using heuristics, Rair can be used in many scenarios without any manual configuration.

Usage example

Suppose you have a simple script mymodel.py committed to git, looking like this:

import time

print('Test text output to stdio')
p1 = 5.9
p2 = 9.5

with open("test_result.txt", "w") as f:
    current_time = time.strftime("%Y-%m-%d %H:%M:%S")
    f.write(f"Current time: {current_time}\n")
    f.write(f"result = {p1 + p2}\n")

You tune some parameters (here p1 and p2) without committing the changes to git.

Now you run your script like this:

rair mymodel.py

Rair runs the script and creates an archive with the following structure:

rairarchive/
├── data/
│   └── 9157ce88256e95668977_test_result.txt  # deduplicated data file
└── runs/
    └── 20260603-001-023aa51f/
        ├── info.md          # human-readable run overview
        ├── run.json         # machine-readable run metadata
        ├── out.txt          # captured stdout/stderr
        ├── git_diff.patch   # uncommitted changes (patch format)
        └── test_result.txt  # output file (hardlink)

The file info.md gives an overview of the run:

# Run Information

- Start time: 2026-06-03 11:53:09
- Execution time: 0.185 s
- Command: `python mymodel.py`
- Run hash: `023aa51fa4981ebe097f2045947d2108cff014c42332d5f6ef5a9d71cbf5273b`

## Git Information

- Commit: `95aa8c491f8a3e5c44890ea3c6616e123692c4cd`
- Short git hash: `95aa8c4`
- Branch: `main`
- Tracking URL: `no-upstream`

## Uncommitted Changes

```
in mymodel.py:
p1 = 7.1
p2 = 3.3
```

## Restore Code

To restore the code state for this run, run:

```bash
git checkout 95aa8c491f8a3e5c44890ea3c6616e123692c4cd
git apply "rairarchive/runs/20260603-001-023aa51f/git_diff.patch"
```

## Output Files

- `test_result.txt` -> `rairarchive/data/9157ce88256e95668977_test_result.txt` (hash: `9157ce88`)

The "Run hash" captures the git hash, code diff, command line and input file content.

Install

Rair can be installed with pip. It is tested on Windows and Unix:

pip install rair

Features

  • Git diff tracking: Track uncommitted changes alongside git commits
  • Output capture: Captures stdout/stderr to a file
  • Metadata format: Human-readable markdown and machine-readable JSON
  • Auto-discovery: Automatically discover input/output files using hash-based change detection for outputs
  • Deduplication: Avoids storing duplicate data files by using file hashes
  • Flexible configuration: Configure via CLI, or config file .rair.toml, or pyproject.toml

Running Rair

# Run a Python script with automatic tracking of all data files
# in the project directory
rair myscript.py

# Run a Python script with script arguments
rair myscript.py arg1 arg2

# Run other scripts, the interpreter is chosen by the shebang line
# or the file extension
rair analysis.R
rair ./run_model

# Run with explicit command
rair python3 mymodel.py arg1 arg2

# The first argument can be a script or any arbitrary command
rair make --all

# Options for Rair must be given before the script or command.
# Everything after it is passed on unchanged, here the comment is used
# by Rair and --input is passed to the script
rair --comment "experiment 1" myscript.py --input file.txt

# Manually specify which files to track
rair --input "data/*.csv" --output "results/*.json" myscript.py

# If only input files are specified, outputs are auto-discovered
rair --input "data/*.csv" --input parameters.txt myscript.py

# Auto-discovery of files can be disabled
rair --no-auto-discover --output "results/*.json" myscript.py

# Run the default command specified in the config file and add
# a comment that is stored with the results
rair --comment "experiment 1"

Automatic data file tracking

By default Rair will track all files in the project directory (the top-level directory of the git repository) that are not tracked by git as input data files. Hidden files and directories (names starting with a dot) and the archive directory are ignored. Output files are discovered by comparing file hashes before and after the run: new and changed files are outputs. This allows to track all relevant files without the need to specify them manually. The directory that is searched can be restricted with --autodata. File hashes are cached in .rair_cache/ and are recalculated for files with a changed modification time.

Note that files ignored by git (like __pycache__ or a non-hidden virtual environment) are not tracked by git and are therefore picked up as data files, too. Use --exclude or --autodata to leave them out.

All CLI flags

--config FILE              Path to config file (used instead of .rair.toml/pyproject.toml)
--input TEXT               Glob pattern for input files to track (can be repeated)
--output TEXT              Glob pattern for output files to track (can be repeated)
--exclude TEXT             Glob pattern to exclude from tracking (can be repeated)
--archive-dir DIRECTORY    Directory for archive data (default: rairarchive)
--autodata DIRECTORY       Directory for auto-discovering input/output files
--no-capture-output        Do not write console output to out.txt
--no-auto-discover         Disable auto-discovery when --input/--output not specified
--no-output-files-in-run   Do not create hardlinks to output files in the run folder
--comment TEXT             Add a comment to info.md and run.json
--setup                    Run interactive setup dialog
--help                     List all CLI flags

The three --no-... flags have a positive counterpart (--capture-output, --auto-discover, --output-files-in-run) to override a value from the config file.

Configuration

As alternative to CLI parameters, configuration can be provided via a .rair.toml file under [rair] or in pyproject.toml under [tool.rair]. CLI parameters override the values from the config file. Here example configurations:

.rair.toml:

[rair]
archive_dir = "rairarchive"
input_glob = ["data/*.csv", "cache/*.pkl"]
output_glob = ["results/*.json", "logs/*.txt"]
capture_output = false
output_files_in_run = false
default_command = "make"

pyproject.toml:

[tool.rair]
archive_dir = "rairarchive"
input_glob = ["data/*.csv", "cache/*.pkl"]
output_glob = ["results/*.json", "logs/*.txt"]
capture_output = false
output_files_in_run = false
default_command = "make"

All Config Values

Config Value Type Default Description
archive_dir Path rairarchive Directory where archive data is stored
input_glob list[str] [] Glob patterns for input files to track
output_glob list[str] [] Glob patterns for output files to track
exclude_glob list[str] [] Glob patterns for files to exclude from tracking
autodata_dir Path Project dir Directory for auto-discovering input/output files
capture_output bool true Whether to capture stdout/stderr to out.txt
auto_discover bool true Enable auto-discovery of input/output files when not explicitly specified
output_files_in_run bool true Create hardlinks to output files in the run folder
default_command str None Command (optionally with arguments) to run when invoking rair without a command

Relative paths and glob patterns are resolved from the project directory.

Hierarchical Configuration

You can have different configurations for different directories:

  • The config files (.rair.toml, or a pyproject.toml with a [tool.rair] section) of all directories from the project directory down to the current directory are merged
  • A setting in a subdirectory overrides the same setting of its parent directories, settings that are not given are inherited
  • List values (glob patterns) are replaced, not concatenated
  • Use rair --setup in subdirectories to create local configs
  • Run rair --setup and choose "(c)urrent directory" or "(p)roject"

Example directory structure:

project/
├── .rair.toml          # Project config
└── experiments/
    ├── .rair.toml      # Overrides single settings of the project config
    └── train.py

With archive_dir = "rairarchive" and capture_output = false in the project config and only default_command = "python train.py" in experiments/.rair.toml, running rair in experiments/ uses all three settings.

Developer Guide

Feedback and contributions are welcome - please open an issue or submit a pull request on GitHub.

To get started with development, first clone the repository:

git clone https://github.com/DLR-Institute-of-Future-Fuels/rair.git
cd rair

You may set up a virtual environment:

python -m venv .venv
source .venv/bin/activate  # On Windows: `.venv\Scripts\activate`

Build and install the package and dev dependencies:

pip install -e .[dev]

Run the tests:

pytest

License

This project is licensed under the MIT license - see the LICENSE file for details.

Metadata

Release files for rair 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rair 0.1.3
File Size Uploaded Provenance Actions
rair-0.1.3.tar.gz 52.0 kB With provenance Details for rair-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rair 0.1.3
File Interpreter ABI Platform Actions
rair-0.1.3-py3-none-any.whl Python 3 none any Details for rair-0.1.3-py3-none-any.whl

Total release size: 80.5 kB

Release files / rair-0.1.3.tar.gz

Download URL rair-0.1.3.tar.gz
Size 52.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dc5e7815ce1c275783f583ba819c366e2c10a9a5919e46c990527a9d2a43eb16
BLAKE2b-256 checksum
How to use checksums
205cc496cb938a0b3507612e228848e749195cb447fa3e43add5af94e88b60e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / rair-0.1.3-py3-none-any.whl

Download URL rair-0.1.3-py3-none-any.whl
Size 28.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
348cd64b91bdf859eb7805b6faa03fb3374b52669c698a6f84fe90cb032982d9
BLAKE2b-256 checksum
How to use checksums
561fd1f1d0ae491e4edd1b58d747c7acb6121a98abc1a108f8fccc7f3d165957
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Security for rair 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rair-0.1.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page