Skip to main content

Time-Travel Debugger for Data Pipelines

Project description

DataGhost ๐Ÿ‘ป

Time-Travel Debugger for Data Pipelines

DataGhost enables precise debugging, inspection, and simulation of historical pipeline runs. Debug your data pipelines like you debug your code.

MIT License Python 3.8+

๐Ÿš€ Quick Start

Installation

pip install dataghost

Basic Usage

from ttd import snapshot

@snapshot(task_id="process_data")
def process_data(data: list, multiplier: int = 2) -> dict:
    processed = [x * multiplier for x in data]
    return {
        "processed_data": processed,
        "count": len(processed)
    }

# Run your function normally
result = process_data([1, 2, 3, 4, 5], multiplier=3)

CLI Commands

# List all snapshots
dataghost snapshot --list

# Replay a specific task
dataghost replay process_data

# Compare two runs
dataghost diff process_data

# List all replayable tasks
dataghost tasks

# Show comprehensive overview
dataghost overview

# Launch interactive web dashboard
dataghost dashboard

โœจ Features

  • ๐ŸŽฏ Zero-config snapshot capture - Just add the @snapshot decorator
  • ๐Ÿ”„ Deterministic replay - Re-execute tasks with historical inputs
  • ๐Ÿ“Š Structured diffing - Compare outputs, inputs, and metadata across runs
  • ๐Ÿ’พ Pluggable storage - DuckDB by default, S3 support planned
  • ๐Ÿ—๏ธ Framework integration - First-class Apache Airflow support
  • ๐ŸŽจ Rich CLI - Beautiful command-line interface with tables and colors
  • ๐Ÿ“ฑ Web Dashboard - Interactive dashboard with real-time monitoring
  • โšก Fast & lightweight - Minimal overhead on your pipelines

๐Ÿ› ๏ธ Core Components

Snapshot Decorator

Capture complete execution context with a simple decorator:

from ttd import snapshot

@snapshot(
    task_id="my_custom_task",     # Optional: defaults to function name
    capture_env=True,             # Capture environment variables
    capture_system=True           # Capture system information
)
def my_data_task(input_data):
    # Your task logic here
    return processed_data

Replay Engine

Replay any historical execution:

from ttd import ReplayEngine

engine = ReplayEngine()

# Replay latest run of a task
result = engine.replay(task_id="process_data")

# Replay specific run
result = engine.replay(task_id="process_data", run_id="20241201_143022_12345")

# Replay with validation
result = engine.replay(task_id="process_data", validate_output=True)

Diff Engine

Compare executions with structured diffing:

from ttd import DiffEngine

diff_engine = DiffEngine()

# Compare latest two runs
diff = diff_engine.diff_task_runs("process_data")

# Compare specific snapshots
diff = diff_engine.diff_snapshots(snapshot_id1, snapshot_id2)

# Generate human-readable report
report = diff_engine.generate_diff_report(diff, format="text")
print(report)

๐ŸŒŠ Airflow Integration

DataGhost provides seamless Apache Airflow integration:

from ttd.integrations.airflow import DataGhostPythonOperator, create_datahost_dag
from datetime import datetime

# Create a DAG with DataGhost enabled
dag = create_datahost_dag(
    dag_id='my_etl_pipeline',
    default_args={'owner': 'data-team'},
    schedule_interval='@daily'
)

# Use DataGhost-enabled operators
extract_task = DataGhostPythonOperator(
    task_id='extract_data',
    python_callable=extract_data_function,
    dag=dag
)

transform_task = DataGhostPythonOperator(
    task_id='transform_data',
    python_callable=transform_data_function,
    dag=dag
)

# Set dependencies
extract_task >> transform_task

๐Ÿ“ฑ Web Dashboard

DataGhost includes a beautiful web dashboard for interactive monitoring and analysis:

# Launch dashboard (auto-opens browser)
dataghost dashboard

# Specify custom port and host
dataghost dashboard --port 3000 --host 0.0.0.0

# Launch without auto-opening browser
dataghost dashboard --no-browser

Dashboard Features:

  • ๐Ÿ“Š Real-time Overview: Live statistics and health metrics
  • ๐ŸŽฏ Task Health Monitoring: Success rates and performance trends
  • โšก Recent Activity: Latest pipeline executions
  • ๐Ÿ“‹ Task Management: Interactive task listing with actions
  • ๐Ÿ”„ One-click Replay: Replay tasks directly from the UI
  • ๐Ÿ“Š Visual Diffs: Compare runs with structured diff visualization
  • ๐Ÿ” Snapshot Explorer: Detailed snapshot inspection
  • ๐Ÿ“ˆ Performance Analytics: Execution time trends and statistics

Installation:

# Install with dashboard dependencies
pip install dataghost[dashboard]

Command-line Overview

For a comprehensive overview in your terminal:

# Show detailed overview with tables
dataghost overview

# Get overview data as JSON
dataghost overview --format json

๐Ÿ“‹ CLI Reference

Snapshot Management

# List all snapshots
dataghost snapshot --list

# List snapshots for specific task
dataghost snapshot --task-id my_task

# Output as JSON
dataghost snapshot --list --format json

Task Replay

# Replay latest run
dataghost replay my_task

# Replay specific run
dataghost replay my_task --run-id 20241201_143022

# Replay with sandbox isolation
dataghost replay my_task --sandbox

# Skip output validation
dataghost replay my_task --no-validate

Diff Analysis

# Compare latest two runs
dataghost diff my_task

# Compare specific runs
dataghost diff my_task --run-id1 run1 --run-id2 run2

# Compare outputs only
dataghost diff my_task --outputs-only

# Get JSON output
dataghost diff my_task --format json

Task Management

# List all replayable tasks
dataghost tasks

# Initialize storage
dataghost init

# Clean up storage
dataghost clean --confirm

๐Ÿ—„๏ธ Storage Backends

DuckDB (Default)

from ttd.storage import DuckDBStorageBackend

# Default local storage
storage = DuckDBStorageBackend()

# Custom database location
storage = DuckDBStorageBackend(
    db_path="custom_path.db",
    data_dir="custom_data"
)

S3 (Coming Soon)

from ttd.storage import S3StorageBackend

storage = S3StorageBackend(
    bucket="my-dataghost-bucket",
    prefix="snapshots/"
)

๐Ÿ”ง Configuration

DataGhost can be configured via:

  1. Environment variables
  2. Configuration files
  3. Direct instantiation

Environment Variables

export DATAGHOST_DB_PATH="./my_snapshots.db"
export DATAGHOST_DATA_DIR="./my_data"
export DATAGHOST_CAPTURE_ENV="true"
export DATAGHOST_CAPTURE_SYSTEM="true"

Global Configuration

from ttd import set_storage_backend
from ttd.storage import DuckDBStorageBackend

# Set global storage backend
set_storage_backend(DuckDBStorageBackend("global.db"))

๐Ÿ“Š Use Cases

๐Ÿ” Debug Data Pipeline Failures

When a pipeline fails, replay the exact conditions:

# Check what happened during the failure
result = engine.replay(task_id="failing_task", run_id="failure_run_id")

if not result['replay_success']:
    print(f"Error: {result['replay_error']}")
    print(f"Original inputs: {result['original_inputs']}")

๐Ÿ“ˆ Compare Pipeline Performance

Track how your pipeline behavior changes over time:

# Compare performance between runs
dataghost diff my_etl_task --run-id1 yesterday --run-id2 today

# See execution time changes, output differences, etc.

๐Ÿงช Test Pipeline Changes

Before deploying changes, compare against historical runs:

# Test new logic against historical data
new_result = new_function(historical_inputs)
diff = diff_engine.compare_outputs(historical_output, new_result)

๐Ÿ“‹ Data Quality Auditing

Track data quality metrics over time:

@snapshot(task_id="data_quality_check")
def check_data_quality(df):
    return {
        "row_count": len(df),
        "null_count": df.isnull().sum().sum(),
        "duplicate_count": df.duplicated().sum(),
        "completeness": 1 - (df.isnull().sum().sum() / df.size)
    }

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

# Clone the repository
git clone https://github.com/dataghost/dataghost.git
cd dataghost

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run linting
black .
isort .
flake8

Running Examples

# Run basic example
python examples/basic_example.py

# Test Airflow DAG locally
python examples/airflow_dag.py

๐Ÿ—บ๏ธ Roadmap

โœ… Milestone 1: Core Engine (Completed)

  • Snapshot decorator with metadata capture
  • DuckDB storage backend
  • CLI with basic commands
  • Replay engine
  • Diff engine

๐Ÿšง Milestone 2: Enhanced Features (In Progress)

  • S3 storage backend
  • Advanced diff algorithms
  • Performance optimizations
  • Extended Airflow integration

๐Ÿ“‹ Milestone 3: Ecosystem Integration

  • Prefect integration
  • Dagster integration
  • Jupyter notebook support
  • VS Code extension

๐ŸŽจ Milestone 4: UI & Visualization

  • Web UI for snapshot browsing
  • Interactive diff visualization
  • Pipeline timeline view
  • Performance dashboards

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built with love by the DataGhost team
  • Inspired by time-travel debugging concepts from software engineering
  • Thanks to the Apache Airflow community for pipeline orchestration patterns

Happy Time-Travel Debugging! ๐Ÿ‘ปโœจ

For more examples and detailed documentation, visit our documentation site.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataghost-0.1.0.tar.gz (210.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dataghost-0.1.0-py3-none-any.whl (203.0 kB view details)

Uploaded Python 3

File details

Details for the file dataghost-0.1.0.tar.gz.

File metadata

  • Download URL: dataghost-0.1.0.tar.gz
  • Upload date:
  • Size: 210.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for dataghost-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9e4b60e5181efcc6f5bb294b57932ce38647d4c84cb31b413a1bd54d7886bccf
MD5 ba98539443400da2c806748d06f3c71c
BLAKE2b-256 dcf19358aa757e5e35f04aa7c61d140b4c2ad2713b93af027736fc254b3309b1

See more details on using hashes here.

File details

Details for the file dataghost-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dataghost-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 203.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for dataghost-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a91e385ec7dcfdc5ccb6723f55a87eb3f798f873cb42ba95310cb65d9a7af7a7
MD5 c8774d82b04db62ef11fe5cbfd64b127
BLAKE2b-256 011f30f65882dfde6fbcb6a379489d1dcec177dc6f40e6a17618162734db2ef9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page