r2x-cli
A framework plugin manager for the r2x power systems modeling ecosystem. The r2x-cli simplifies discovery, installation, and management of r2x framework plugins, providing a unified interface for running data processing pipelines.
Installation
Download the latest pre-built binary for your platform from the releases page.
Building from Source
Prerequisites
Building r2x-cli requires the Rust toolchain, the uv package manager, and Python 3.11, 3.12, or 3.13.
Install the Rust toolchain via rustup:
|
Install the uv package manager:
|
Install Python via uv:
Restart your shell after installation to ensure the tools are available in your PATH.
Build and Install
Clone the repository:
&&
Build and install using cargo. The PYO3_PYTHON environment variable tells PyO3 which Python interpreter to use:
PYO3_PYTHON=
This installs the r2x binary to ~/.cargo/bin/, which should already be in your PATH if you installed Rust via rustup.
Verify the installation:
Alternative: Manual Build
For more control over the build process, you can build manually and place the binary in a custom location:
PYO3_PYTHON=
The binary will be at target/release/r2x. Copy it to your preferred location and ensure that location is in your PATH.
Troubleshooting Build Issues
If the build fails with a Python-related error, verify that uv python find 3.12 returns a valid path. You may need to run uv python install 3.12 first.
If the r2x command is not found after installation, verify ~/.cargo/bin is in your PATH with echo $PATH.
On HPC systems or machines with older glibc versions, building from source is often required because pre-built binaries may be incompatible.
Getting Started
Initialize a new pipeline configuration file:
This creates a pipeline.yaml file containing example variables, pipeline definitions, and plugin configuration templates. Specify a custom filename with r2x init my-pipeline.yaml.
Configuration
Display current configuration:
Update configuration values:
Reset configuration to defaults:
Python and Virtual Environment
Install a specific Python version:
Get the Python executable path:
Create or recreate the virtual environment:
Install packages into the managed virtual environment:
Cache
Clean the cache directory:
Plugin Management
List all installed plugins:
Filter by package or module name:
Install a plugin from PyPI:
Install from a git repository:
Install in editable mode for development:
Remove a plugin:
Re-run plugin discovery:
Clean the plugin manifest:
Running Plugins
Run a plugin with arguments:
Show plugin help:
List available plugins:
Pipeline Management
List all pipelines in a configuration file:
Preview pipeline execution without running:
Execute a pipeline:
Execute and save output:
Pipeline Configuration Format
Pipeline configuration files use YAML with three sections: variables for substitution values, pipelines for named plugin sequences, and config for plugin-specific 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.upgrader:
path: ${reeds_run}
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}
Run a pipeline with:
Interactive System Shell
Load a system from JSON and open an interactive IPython session:
Load from stdin:
|
Execute a script against the loaded system:
Execute a script then drop into interactive mode:
The interactive session provides the loaded system as sys, access to plugins via plugins, and lazy-loaded pd, np, and plt for pandas, numpy, and matplotlib. Type %r2x_help in the session to see available commands.
Verbosity Control
Suppress informational logs:
Suppress logs and plugin stdout:
Enable debug logging:
Enable trace logging:
Show Python logs on console:
License
BSD-3-Clause License. See LICENSE.txt for details.