Skip to main content

A deep agent for extracting metrics from raw result files using LangGraph and intelligent parsing

Project description

๐ŸŽฏ Results Parser

A powerful, efficient parser for extracting metrics from benchmark result files using workload-specific extraction scripts. The parser automatically analyzes result files and extracts metrics into structured JSON output with high accuracy and reliability.

๐Ÿš€ Features

  • ๐ŸŽฏ Script-Based Parsing: Uses workload-specific extraction scripts for reliable, deterministic metric extraction
  • ๐Ÿ“ Flexible Input: Process single files or entire directories of result files
  • ๐Ÿ”ง Workload-Specific Tools: Dedicated extraction scripts for different benchmark types (FIO, Redis, Nginx, MariaDB/MySQL TPC-H & TPC-C) that automatically extract all available metrics
  • โš™๏ธ MongoDB Integration: External API-backed workload registry for scalable management
  • ๐Ÿ“Š Structured Output: Direct output in Pydantic schemas for easy integration
  • ๐Ÿ› ๏ธ Professional CLI: Comprehensive Typer-based command-line interface with subcommands
  • ๐Ÿ”ง Python API: Easy integration into existing Python applications
  • ๐Ÿ”„ Error Recovery: Robust error handling and retry mechanisms
  • ๐Ÿ“ฆ Git-based Scripts: Secure, efficient script distribution and caching system
  • ๐Ÿ”’ Enterprise Security: SSH authentication, environment variables, and secure defaults

๐Ÿ“ฆ Installation

Quick Install (Recommended)

pip install result-parser-agent

Development Install

# Clone the repository
git clone https://github.com/Infobellit-Solutions-Pvt-Ltd/result-parser-agent.git
cd result-parser-agent

# Install with uv (recommended)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
uv pip install -e .

# Or install with pip
pip install -e .

๐Ÿ“‹ Configuration

Environment Variables

Create a .env file in your project directory:

# MongoDB Registry API
REGISTRY_API_BASE_URL=http://your-mongodb-api.com/api/v1

# Script Management
SCRIPTS_BASE_URL=git@github.com:your-org/parser-scripts.git
SCRIPTS_CACHE_DIR=~/.cache/result-parser/scripts
SCRIPTS_CACHE_TTL=3600

๐ŸŽฏ Quick Start

2. Use the CLI

The CLI now supports multiple subcommands for different operations:

Parse Results

# Parse all files in a directory with workload-specific tools
result-parser parse ./benchmark_results --workload fio

# Parse Redis results (scripts automatically extract all available metrics)
result-parser parse ./benchmark_results --workload redis

# Parse a single file
result-parser parse ./results.txt --workload nginx

# Custom output file
result-parser parse ./results/ --workload mariadb_tpch --output my_results.json

# Verbose output
result-parser parse ./results/ --workload mysql_tpcc --verbose

Manage Registry

# Show cached workloads (cache-first, no API calls)
result-parser registry

# Show all workloads including registry (with API calls)
result-parser registry --include-registry

# Add new workload
result-parser add-workload fio --metrics "random_read_iops,random_write_iops" --description "Storage performance benchmark"

# Update existing workload
result-parser update-workload redis --metrics "SET(requests/sec),GET(requests/sec),DEL(requests/sec)"

# Show workload details
result-parser show-workload nginx

Manage Script Cache

# Show cache information
result-parser cache info

# Clear specific workload cache
result-parser cache clear fio

# Clear all caches
result-parser cache clear-all

3. Use the Python API

from result_parser_agent import ResultsParser

# Initialize parser
parser = ResultsParser()

# Parse results with workload-specific tools (scripts automatically extract all available metrics)
results = await parser.parse_results(
    input_path="./benchmark_results",
    workload="fio"
)

# Output structured data
print(results.json(indent=2))

๐Ÿš€ Cache-First Architecture

The CLI tool now uses a cache-first approach for better performance and offline capability:

Local Cache Priority

  • No API calls by default: The CLI first checks local cache for available workload scripts
  • Fast startup: No network delays when using cached workloads
  • Offline capability: Works without internet connection for cached workloads
  • Explicit registry access: Use --include-registry flag to check registry API

Smart Workload Discovery

  • Cache-first validation: When parsing, checks local cache first
  • Auto-download: If workload not in cache, automatically downloads from registry
  • Registry info: Use registry --include-registry to see all available workloads

๐Ÿ“Š How Metrics Extraction Works

The agent now uses a two-phase approach for metrics extraction:

Phase 1: Automatic Extraction

  • Scripts are self-sufficient: Each workload-specific script automatically extracts all available metrics from the data
  • No user input required: You don't need to specify which metrics to extract when parsing
  • Comprehensive coverage: Scripts extract all metrics they can find in the data

Phase 2: Validation & Reporting

  • Expected metrics: Defined in the workload registry for validation purposes
  • Automatic validation: The agent compares extracted metrics against expected metrics
  • Detailed reporting: Shows missing metrics, unexpected metrics, and extraction success

Example Output

๐Ÿ“Š Expected metrics for fio: ['random_read_iops', 'random_write_iops']
๐Ÿ“ˆ Extracted metrics: random_read_iops, random_write_iops, sequential_read_mbps
โ„น๏ธ  Additional metrics found: sequential_read_mbps
โœ… All expected metrics successfully extracted!

This approach ensures maximum flexibility while maintaining quality control through validation.

๐Ÿ”ง Supported Workloads

The agent supports various benchmark workloads with dedicated extraction scripts:

Workload Description Example Metrics
FIO Storage performance benchmark random_read_iops, random_write_iops, sequential_read_mbps
Redis In-memory database benchmark SET(requests/sec), GET(requests/sec)
Nginx Web server performance Requests/sec, Transfer/sec
MariaDB TPC-H Database TPC-H benchmark Power@Size, Throughput@Size, QphH@Size
MySQL TPC-H Database TPC-H benchmark Power@Size, Throughput@Size, QphH@Size
MariaDB TPC-C Database TPC-C benchmark tpmC, tpmTOTAL
MySQL TPC-C Database TPC-C benchmark tpmC, tpmTOTAL

๐Ÿ—๏ธ Architecture

The parser uses a streamlined architecture focused on workload-specific script execution:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   CLI Layer     โ”‚    โ”‚  Results Parser  โ”‚    โ”‚  Tool Registry  โ”‚
โ”‚  (Typer CLI)    โ”‚โ—„โ”€โ”€โ–บโ”‚  (Core Logic)    โ”‚โ—„โ”€โ”€โ–บโ”‚  (Workloads)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Configuration  โ”‚    โ”‚  Script Download โ”‚    โ”‚  Script Cache   โ”‚
โ”‚  (Pydantic)     โ”‚    โ”‚   (Git SSH)      โ”‚    โ”‚   (Local)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ MongoDB Registryโ”‚    โ”‚  Result Output   โ”‚    โ”‚  Extraction     โ”‚
โ”‚     API         โ”‚    โ”‚   (JSON)         โ”‚    โ”‚   Scripts       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Benefits:

  • Simplified: Direct script execution without LLM overhead
  • Faster: No AI processing delays
  • Reliable: Deterministic script-based extraction
  • Maintainable: Clear separation of concerns

๐Ÿ› ๏ธ CLI Commands Reference

parse - Parse Benchmark Results

result-parser parse <input_path> [OPTIONS]

Arguments:
  input_path              Path to results file or directory

Options:
  --workload TEXT         Workload type (fio, redis, nginx, mariadb_tpch, etc.)
  --output TEXT           Output file path [default: results.json]
  --verbose               Enable verbose logging
  --help                  Show this message and exit

registry - Show Registry Information

result-parser registry

Shows:
- Registry source (API + Git Scripts)
- Available workloads
- Script cache status
- Cache directory information

cache - Manage Script Cache

result-parser cache <action> [workload]

Actions:
  info                    Show cache information
  clear [workload]        Clear specific or all caches
  clear-all               Clear all caches

add-workload - Add New Workload

result-parser add-workload <name> [OPTIONS]

Arguments:
  name                    Workload name

Options:
  --metrics TEXT          Comma-separated list of expected metrics [required]
  --script TEXT           Script filename [default: extractor.sh]
  --description TEXT      Workload description
  --status TEXT           Workload status (active/inactive) [default: active]

Note: The --metrics parameter defines the expected metrics for validation purposes. The actual extraction scripts will automatically extract all available metrics from the data.

update-workload - Update Existing Workload

result-parser update-workload <name> [OPTIONS]

Arguments:
  name                    Workload name

Options:
  --metrics TEXT          Comma-separated list of expected metrics
  --script TEXT           Script filename
  --description TEXT      Workload description
  --status TEXT           Workload status (active/inactive)

Note: The --metrics parameter updates the expected metrics for validation purposes. The actual extraction scripts will automatically extract all available metrics from the data.

show-workload - Show Workload Details

result-parser show-workload <name>

Arguments:
  name                    Workload name to display

๐Ÿ”’ Security Features

  • SSH Authentication: Secure access to private Git repositories
  • Environment Variables: No hardcoded secrets or API keys
  • Input Validation: Comprehensive validation of all user inputs
  • Secure Defaults: Principle of least privilege in configuration
  • Script Isolation: Scripts run in controlled environment

๐Ÿš€ Performance Features

  • Script Caching: Local cache with TTL-based invalidation
  • Sparse Git Operations: Efficient individual script retrieval
  • Lazy Loading: Scripts downloaded only when needed
  • Optimized API Calls: Efficient MongoDB API interactions

๐Ÿงช Testing

Run the test suite to ensure everything works correctly:

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=src/result_parser_agent

# Run specific test file
uv run pytest tests/test_cli.py

๐Ÿ“š Development

Code Quality

# Format code
uv run black .

# Sort imports
uv run isort .

# Lint code
uv run ruff check .

# Type checking
uv run mypy src/

๐Ÿค Contributing

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

Development Setup

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Submit a pull request

๐Ÿ“„ License

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

๐Ÿ†˜ Support

๐Ÿ† Acknowledgments

  • Powered by Typer for CLI development
  • Enhanced with Pydantic for data validation
  • Script management powered by Git and SSH
  • Built with Python async/await for efficient processing

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

result_parser_agent-1.2.0.tar.gz (103.9 kB view details)

Uploaded Source

Built Distribution

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

result_parser_agent-1.2.0-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

Details for the file result_parser_agent-1.2.0.tar.gz.

File metadata

  • Download URL: result_parser_agent-1.2.0.tar.gz
  • Upload date:
  • Size: 103.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for result_parser_agent-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e2e02f90ded57ad5498d27c490b4c9bc4ca961c8ed182e6841ef6f532868ede7
MD5 51a7c70ba6253117afbbe46b326fe594
BLAKE2b-256 713a597f692ad558bc8b5eb51e57f3242467483f0d66fc81e003312da939c36a

See more details on using hashes here.

File details

Details for the file result_parser_agent-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for result_parser_agent-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1121cd606d29242f6df0853deafe5c47292343af94381fb88524893bae9c044
MD5 cfdf3d6e78b7acc9a11e322932cd6dc0
BLAKE2b-256 de0ad706da9d4079491d1479651c4a313d8596f0b86e90472618793060fefd4d

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