Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Command Line Interface

A comprehensive command-line interface for running hazard simulations on distribution systems using the ERAD framework.

Installation

Install ERAD with all dependencies:

pip install -e ".[dev]"

The CLI is automatically available as the erad command after installation.

Quick Start

# Show version
erad version

# Show environment info
erad info

# List cached models
erad models list

# List supported hazards
erad hazards list

# Start the API server
erad server start

Commands Overview

CommandDescription
erad versionShow the ERAD version
erad infoShow environment information
erad simulateRun a hazard simulation
erad generateGenerate Monte Carlo scenarios
erad modelsManage distribution system models
erad hazardsHazard-related commands
erad cacheCache management commands
erad serverServer management commands

Simulation Commands

Run Simulation

Run a hazard simulation using cached distribution and hazard system models:

erad simulate <distribution_model> <hazard_model> [OPTIONS]

Arguments:

Options:

Example:

erad simulate my_system earthquake_scenario --output results.sqlite
erad simulate power_grid flood_hazard --curves DEFAULT_CURVES

Generate Scenarios

Generate Monte Carlo scenarios using cached distribution and hazard system models:

erad generate <distribution_model> <hazard_model> [OPTIONS]

Arguments:

Options:

Example:

erad generate my_system flood_scenario --samples 100 --seed 42 --output scenarios.zip
erad generate power_grid earthquake_hazard --samples 50 --output eq_scenarios.zip

Model Management

List Models

List all cached distribution system models:

erad models list [OPTIONS]

Options:

Example:

# List models as table
erad models list

# List with JSON output
erad models list --json

# Refresh and list
erad models list --refresh

Add Model

Add a distribution system model to the cache:

erad models add <file> [OPTIONS]

Options:

Example:

erad models add system.json --name my_system --description "Test distribution system"

Show Model

Show details of a cached model:

erad models show <name> [OPTIONS]

Options:

Example:

erad models show my_system --full

Remove Model

Remove a model from the cache:

erad models remove <name> [OPTIONS]

Options:

Example:

erad models remove my_system

Export Model

Export a cached model to a file:

erad models export <name> <output_path>

Example:

erad models export my_system ./exported_system.json

Hazard Commands

Manage cached hazard system models.

List Hazard Models

List all cached hazard system models:

erad hazards list [OPTIONS]

Options:

Example:

# List hazard models
erad hazards list

# Refresh and list
erad hazards list --refresh

# JSON output
erad hazards list --json

Add Hazard Model

Add a hazard system model to the cache:

erad hazards add <file> [OPTIONS]

Options:

Example:

erad hazards add earthquake.json --name eq_scenario --description "Major earthquake scenario"

Show Hazard Model

Show details of a cached hazard model:

erad hazards show <name> [OPTIONS]

Options:

Example:

erad hazards show eq_scenario --full

Remove Hazard Model

Remove a hazard model from the cache:

erad hazards remove <name> [OPTIONS]

Options:

Example:

erad hazards remove eq_scenario

Export Hazard Model

Export a cached hazard model to a file:

erad hazards export <name> <output_path>

Example:

erad hazards export eq_scenario ./exported_hazard.json

List Hazard Types

List supported hazard types for creating models:

erad hazards types

Output shows available hazard types: earthquake, flood, flood_area, wind, fire, fire_area.

Show Hazard Example

Show an example hazard system configuration:

erad hazards example <hazard_type> [OPTIONS]

Options:

Example:

# Show earthquake example
erad hazards example earthquake

# Save flood example to file
erad hazards example flood --output flood_example.json

Cache Management

Cache Info

Show cache directory information:

erad cache info

Output:

                     Cache Information                      
┌─────────────────┬────────────────────────────────────────┐
│ Cache Directory │ /home/user/.cache/erad/dist_models    │
│ Metadata File   │ /home/user/.cache/.../models_meta.json │
│ Total Models    │ 5                                      │
│ Total Files     │ 5                                      │
│ Total Size      │ 2.50 MB                                │
└─────────────────┴────────────────────────────────────────┘

Refresh Cache

Refresh the model list from the cache directory:

erad cache refresh

Clear Cache

Clear all cached models:

erad cache clear [OPTIONS]

Options:

Example:

# With confirmation
erad cache clear

# Skip confirmation
erad cache clear --force

Server Commands

Start REST API Server

Start the ERAD REST API server:

erad server start [OPTIONS]

Options:

Example:

# Start with defaults
erad server start

# Start on custom port with reload
erad server start --port 8080 --reload

# Production with multiple workers
erad server start --workers 4

Start MCP Server

Start the ERAD MCP server for AI assistant integration:

erad server mcp

Cache Directories

The CLI uses the same cache directories as the REST API and MCP server:

Distribution Models:

Hazard Models:

Shell Completion

Install shell completion for your shell:

# For bash
erad --install-completion bash

# For zsh
erad --install-completion zsh

# For fish
erad --install-completion fish

Examples

Complete Workflow

# 1. Check ERAD info
erad info

# 2. Add a distribution system model
erad models add distribution_system.json --name power_grid --description "City power grid"

# 3. Add a hazard system model
erad hazards add earthquake_scenario.json --name eq_major --description "Major earthquake"

# 4. List available models
erad models list
erad hazards list

# 5. View model details
erad models show power_grid
erad hazards show eq_major

# 6. Run earthquake simulation
erad simulate power_grid eq_major --output eq_results.sqlite

# 7. Add flood hazard model and generate scenarios
erad hazards add flood_scenario.json --name flood_100yr --description "100-year flood"
erad generate power_grid flood_100yr --samples 50 --seed 42 --output flood_scenarios.zip

# 8. Start API server for programmatic access
erad server start --port 8000

Batch Processing Script

#!/bin/bash

# Process multiple hazard scenarios
DIST_MODELS=$(erad models list --json | jq -r 'keys[]')
HAZARD_MODELS=$(erad hazards list --json | jq -r 'keys[]')

for dist_model in $DIST_MODELS; do
    for hazard_model in $HAZARD_MODELS; do
        echo "Processing $dist_model with $hazard_model..."
        
        erad generate "$dist_model" "$hazard_model" \
            --samples 100 \
            --seed 42 \
            --output "results/${dist_model}_${hazard_model}.zip"
    done
done

See Also