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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Support
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
๐ Acknowledgments
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdeb5e12d0770a75c39e621b9be92a635977572299b36091681363d2bab722c5
|
|
| MD5 |
bbc087a86315d67aa67253961ab08123
|
|
| BLAKE2b-256 |
438663911e6d62bf85fe5a9a497a6f796d39e6dbaa17b8df2ed823522cda79df
|
File details
Details for the file result_parser_agent-1.0.0-py3-none-any.whl.
File metadata
- Download URL: result_parser_agent-1.0.0-py3-none-any.whl
- Upload date:
- Size: 30.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
864a4ba499ee51905b633b8512224545eaa0d13afa22096a66588117c2e25b23
|
|
| MD5 |
978031da297aac74e413303db13a82fe
|
|
| BLAKE2b-256 |
11f03644730625c3825e38a863e0c56781d4ce451382d1567c72553893ebd72e
|