Skip to main content

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

Project description

๐ŸŽฏ Results Parser Agent

A powerful, intelligent agent for extracting metrics from benchmark result files using LangGraph and AI-powered parsing. The agent automatically analyzes unstructured result files and extracts specific metrics into structured JSON output with high accuracy.

๐Ÿš€ Features

  • ๐Ÿค– AI-Powered Parsing: Uses advanced LLMs (OpenAI GPT-4, GROQ, Anthropic, Google Gemini, Ollama) for intelligent 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)
  • โš™๏ธ 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:

# API Keys - Set only the one you need
OPENAI_API_KEY=your_openai_api_key_here
GROQ_API_KEY=your_groq_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
GOOGLE_API_KEY=your_google_api_key_here

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

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

# Optional: Override default LLM settings
LLM_PROVIDER=openai
LLM_MODEL=gpt-4o

๐ŸŽฏ Quick Start

1. Set up your API key

# For OpenAI (default - recommended)
export OPENAI_API_KEY="your-openai-api-key-here"

# For GROQ
export GROQ_API_KEY="your-groq-api-key-here"

# For Anthropic
export ANTHROPIC_API_KEY="your-anthropic-api-key-here"

# For Google Gemini
export GOOGLE_API_KEY="your-google-api-key-here"

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 with specific metrics
result-parser parse ./benchmark_results --workload redis --metrics "SET(requests/sec),GET(requests/sec)"

# Parse a single file
result-parser parse ./results.txt --workload nginx --metrics "Requests/sec,Transfer/sec"

# 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 registry information and script cache status
result-parser 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 ResultsParserAgent, settings
import os

# Set your API key
os.environ["OPENAI_API_KEY"] = "your-api-key-here"

# Get default configuration
config = settings

# Initialize agent
agent = ResultsParserAgent(config)

# Parse results with workload-specific tools
results = await agent.parse_results(
    input_path="./benchmark_results",
    workload="fio",
    metrics=["random_read_iops", "random_write_iops"]
)

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

๐Ÿ”ง 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 agent uses a modular architecture with clear separation of concerns:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   CLI Layer     โ”‚    โ”‚  Parser Agent    โ”‚    โ”‚  Tool Registry  โ”‚
โ”‚  (Typer CLI)    โ”‚โ—„โ”€โ”€โ–บโ”‚  (LangGraph)     โ”‚โ—„โ”€โ”€โ–บโ”‚  (Workloads)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Configuration  โ”‚    โ”‚   LLM Provider   โ”‚    โ”‚ Script Download โ”‚
โ”‚  (Pydantic)     โ”‚    โ”‚  (OpenAI/GROQ)   โ”‚    โ”‚   (Git SSH)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                       โ”‚                       โ”‚
         โ”‚                       โ”‚                       โ”‚
         โ–ผ                       โ–ผ                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ MongoDB Registryโ”‚    โ”‚  Result Output   โ”‚    โ”‚  Script Cache   โ”‚
โ”‚     API         โ”‚    โ”‚   (JSON)         โ”‚    โ”‚   (Local)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ› ๏ธ 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.)
  --metrics TEXT          Comma-separated list of metrics to extract
  --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 metrics [required]
  --script TEXT           Script filename [default: extractor.sh]
  --description TEXT      Workload description
  --status TEXT           Workload status (active/inactive) [default: active]

update-workload - Update Existing Workload

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

Arguments:
  name                    Workload name

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

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/

Pre-commit Hooks

# Install pre-commit hooks
pre-commit install

# Run all hooks
pre-commit run --all-files

๐Ÿค 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

  • Built with LangGraph for agent orchestration
  • Powered by Typer for CLI development
  • Enhanced with Pydantic for data validation
  • Script management powered by Git and SSH

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.0.0.tar.gz (104.4 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.0.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for result_parser_agent-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cdeb5e12d0770a75c39e621b9be92a635977572299b36091681363d2bab722c5
MD5 bbc087a86315d67aa67253961ab08123
BLAKE2b-256 438663911e6d62bf85fe5a9a497a6f796d39e6dbaa17b8df2ed823522cda79df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for result_parser_agent-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 864a4ba499ee51905b633b8512224545eaa0d13afa22096a66588117c2e25b23
MD5 978031da297aac74e413303db13a82fe
BLAKE2b-256 11f03644730625c3825e38a863e0c56781d4ce451382d1567c72553893ebd72e

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