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-registryflag 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-registryto 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
- 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.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2e02f90ded57ad5498d27c490b4c9bc4ca961c8ed182e6841ef6f532868ede7
|
|
| MD5 |
51a7c70ba6253117afbbe46b326fe594
|
|
| BLAKE2b-256 |
713a597f692ad558bc8b5eb51e57f3242467483f0d66fc81e003312da939c36a
|
File details
Details for the file result_parser_agent-1.2.0-py3-none-any.whl.
File metadata
- Download URL: result_parser_agent-1.2.0-py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1121cd606d29242f6df0853deafe5c47292343af94381fb88524893bae9c044
|
|
| MD5 |
cfdf3d6e78b7acc9a11e322932cd6dc0
|
|
| BLAKE2b-256 |
de0ad706da9d4079491d1479651c4a313d8596f0b86e90472618793060fefd4d
|