r2x
A plugin manager and pipeline runner for the r2x power systems modeling ecosystem. Install plugins, compose pipelines, run translations.
Table of Contents
- Install
- Quickstart
- Plugin Management
- Running Pipelines
- Running Plugins Directly
- Interactive System Shell
- Configuration
- Pipeline File Format
- Verbosity
- Architecture
- Building from Source
- License
Install
Download the latest binary for your platform from the releases page.
Installers are available for macOS, Linux (glibc 2.28+), and Windows:
# macOS / Linux
|
# Windows
powershell -ExecutionPolicy Bypass -c "irm https://github.com/NatLabRockies/r2x-cli/releases/latest/download/r2x-installer.ps1 | iex"
[!NOTE] Pre-built binaries require Python shared libraries at runtime. If
r2x --versionfails with a missinglibpythonerror, runuv python install 3.12to make the shared library available.
Verify it works:
Quickstart
# 1. Initialize a pipeline config
# 2. Install a plugin from PyPI
# 3. Run a pipeline
r2x init creates a pipeline.yaml with example variables, pipeline
definitions, and plugin configuration. Edit it to match your data and
you're running translations in under a minute.
Plugin Management
| Command | What it does |
|---|---|
r2x install <package> |
Install from PyPI |
r2x install NatLabRockies/r2x-reeds |
Install from a GitHub repo |
r2x install --branch dev NatLabRockies/r2x-reeds |
Install a specific branch (also --tag, --commit) |
r2x install -e /path/to/plugin |
Install in editable mode for local development |
r2x remove <package> |
Uninstall a plugin |
r2x list |
List all installed plugins |
r2x list r2x-reeds |
Filter by package name |
r2x list r2x-reeds break-gens |
Filter by package and module |
r2x sync |
Re-run plugin discovery |
r2x clean -y |
Wipe the plugin manifest |
Running Pipelines
Pipelines chain plugins together in a named sequence defined in a YAML file. See Pipeline File Format for the full spec.
# List available pipelines
# Dry run (preview without executing)
# Execute
# Execute and save output
Running Plugins Directly
Skip the pipeline and run a single plugin with inline arguments:
# Show a plugin's help
# List all runnable plugins
Interactive System Shell
Load a system JSON and drop into an IPython session for exploration:
# From stdin
|
# Run a script against the system
# Run a script then stay interactive
The session exposes sys (the loaded system), plugins (installed
plugins), and lazy-loaded pd, np, plt for pandas, numpy, and
matplotlib. Type %r2x_help for the full list of magic commands.
Configuration
# Show current config
# Set values
# Reset everything
# Install a Python version
# Get the Python executable path
# Create or recreate the managed venv
# Install packages into the managed venv
Pipeline File Format
Pipeline configs are YAML files with three sections: variables for
substitution values, pipelines for named plugin sequences, and
config for per-plugin settings.
variables:
output_dir: "output"
reeds_run: /path/to/reeds/run
solve_year: 2032
pipelines:
reeds-test:
- r2x-reeds.parser
- r2x-reeds.break-gens
reeds-to-plexos:
- r2x-reeds.upgrader
- r2x-reeds.parser
- r2x-reeds-to-plexos.translation
- r2x-plexos.exporter
config:
r2x-reeds.parser:
weather_year: 2012
solve_year: ${solve_year}
path: ${reeds_run}
r2x-reeds.break-gens:
drop_capacity_threshold: 5
r2x-plexos.exporter:
output: ${output_dir}
output_folder: ${output_dir}
Variables use ${var} syntax and are substituted at runtime across
all config values and output_folder.
Verbosity
| Flag | Effect |
|---|---|
-q |
Suppress informational logs |
-qq |
Suppress logs and plugin stdout |
-v |
Debug logging |
-vv |
Trace logging |
--log-python |
Show Python logs on console |
Architecture
flowchart LR
CLI[r2x CLI] --> Config[r2x-config]
CLI --> Manifest[r2x-manifest]
CLI --> AST[r2x-ast]
CLI --> Python[r2x-python]
CLI --> Logger[r2x-logger]
AST -->|ast-grep| Discovery[Plugin Discovery]
Python -->|PyO3| Runtime[Python Runtime]
Manifest --> Plugins[(Plugin Registry)]
The workspace is split into six crates:
| Crate | Role |
|---|---|
r2x-cli |
CLI entry point, command routing, pipeline execution |
r2x-config |
Configuration management, paths, Python/venv settings |
r2x-manifest |
Plugin manifest read/write, package metadata |
r2x-ast |
AST-based plugin discovery via ast-grep (no Python startup needed) |
r2x-python |
PyO3 bridge for running Python plugins |
r2x-logger |
Structured logging with tracing |
[!TIP] Plugin discovery uses static analysis (ast-grep) instead of importing Python modules. This makes
r2x syncandr2x installfast and safe, with no side effects from plugin code.
Building from Source
Prerequisites
# Install prerequisites
|
|
[!IMPORTANT] Restart your shell after installing rustup and uv so both are available in your PATH.
Build and install
&&
PYO3_PYTHON=
This places the r2x binary in ~/.cargo/bin/.
PYO3_PYTHON=
The binary lands at target/release/r2x. Copy it wherever you like.
- If the build fails with a Python error, verify
uv python find 3.12returns a valid path. You may needuv python install 3.12first. - If
r2xis not found after install, check that~/.cargo/binis in your$PATH. - On HPC systems with older glibc, building from source is usually required since pre-built binaries target glibc 2.28+.
License
BSD-3-Clause. See LICENSE.txt for the full text.
Copyright (c) 2025, Alliance for Sustainable Energy LLC.