Skip to main content

Hardware-aware dependency compatibility framework for Python ML stacks

Project description

๐Ÿพ Compatibillabuddy

An autonomous AI agent that diagnoses AND repairs broken Python ML environments โ€” with self-correction.

PyPI version Python CI License: MIT Tests


Built for the Google DeepMind ร— Devpost Gemini API Hackathon โ€” Marathon Agent Track

๐Ÿง  An autonomous system that plans, executes, verifies, and self-corrects โ€” not a chatbot, not a prompt wrapper.

The Problem

$ pip install torch numpy pandas scikit-learn
# โœ… Successfully installed ...

$ python -c "import torch; print(torch.cuda.is_available())"
# โŒ False โ€” wrong CUDA version for your GPU driver

$ python -c "import sklearn"
# โŒ ImportError: numpy ABI incompatibility

ML environments don't just have version conflicts โ€” they have hardware mismatches, ABI breaks, and runtime incompatibilities that pip, uv, and poetry can't catch. These failures waste hours of developer time across the ML ecosystem.

Compatibillabuddy treats hardware as a first-class dependency and ships an autonomous Gemini-powered agent that can diagnose AND repair these issues without human intervention.

How It Works

flowchart TD
    A["๐Ÿง‘ User: 'Fix my environment'"] --> B["๐Ÿ“ธ Snapshot Environment"]
    B --> C["๐Ÿฉบ Run Doctor (diagnose)"]
    C --> D{Issues Found?}
    D -- No --> E["โœ… Report: Environment Healthy"]
    D -- Yes --> F["๐Ÿง  Gemini Plans Fix Order"]
    F --> G["๐Ÿ”ง Execute Fix (pip install/uninstall)"]
    G --> H["๐Ÿ” Verify Fix (re-diagnose)"]
    H --> I{Improved?}
    I -- Yes --> J{More Issues?}
    J -- Yes --> G
    J -- No --> K["โœ… Report: All Fixed + Changelog"]
    I -- No --> L["โช Rollback to Snapshot"]
    L --> M["๐Ÿ”„ Try Alternative Fix"]
    M --> H

The agent doesn't guess โ€” it runs real diagnostics via structured tools, executes real pip commands with safety guardrails, and verifies every fix before moving on. If a fix makes things worse, it rolls back automatically and tries an alternative.

Installation

# Core framework (no AI, works offline)
pip install compatibillabuddy

# With Gemini-powered AI agent
pip install "compatibillabuddy[agent]"

Quick Start

1. Diagnose Your Environment (No AI Required)

# Human-readable console report
compatibuddy doctor

# Machine-readable JSON
compatibuddy doctor --format json

# Save to file
compatibuddy doctor --output report.json --format json

2. Autonomous Repair (Gemini Agent)

# Set your API key
export GEMINI_API_KEY="your-key-here"  # Linux/Mac
$env:GEMINI_API_KEY = "your-key-here"  # PowerShell

# Dry run โ€” see what the agent WOULD do (safe, default)
compatibuddy repair

# Live mode โ€” actually execute fixes
compatibuddy repair --live

# JSON output for programmatic use
compatibuddy repair --format json

# Choose model and retry limits
compatibuddy repair --model gemini-2.5-pro --max-retries 5

3. Interactive Chat

# Start an interactive session with the agent
compatibuddy agent

# You: What GPU do I have?
# Agent: [calls tool_probe_hardware] You have an NVIDIA RTX 4090 with CUDA 12.3...
# You: Run a diagnosis
# Agent: [calls tool_run_doctor] Found 2 issues...
# You: Fix the CUDA mismatch
# Agent: [calls tool_snapshot_environment, tool_run_pip, tool_verify_fix] ...

Architecture

compatibillabuddy/
โ”œโ”€โ”€ hardware/          # GPU detection, nvidia-smi parsing, platform info
โ”‚   โ”œโ”€โ”€ probe.py       # probe_hardware() โ†’ HardwareProfile
โ”‚   โ””โ”€โ”€ inspector.py   # inspect_environment() โ†’ EnvironmentInventory
โ”œโ”€โ”€ kb/                # Knowledge base of known-bad combinations
โ”‚   โ”œโ”€โ”€ engine.py      # TOML rulepack loader + evaluator
โ”‚   โ””โ”€โ”€ rulepacks/     # Community-extensible rule definitions
โ”‚       โ””โ”€โ”€ ml_core.toml
โ”œโ”€โ”€ engine/            # Core diagnosis orchestrator
โ”‚   โ”œโ”€โ”€ models.py      # Pydantic v2 models (GPU, packages, issues)
โ”‚   โ”œโ”€โ”€ doctor.py      # diagnose() โ†’ DiagnosisResult
โ”‚   โ””โ”€โ”€ report.py      # Rich console + JSON report formatters
โ”œโ”€โ”€ agent/             # Gemini-powered autonomous agent
โ”‚   โ”œโ”€โ”€ config.py      # API key resolution, model selection
โ”‚   โ”œโ”€โ”€ tools.py       # 9 tools: diagnose, repair, snapshot, rollback
โ”‚   โ””โ”€โ”€ core.py        # AgentSession: chat loop + auto_repair()
โ””โ”€โ”€ cli/               # Typer CLI
    โ”œโ”€โ”€ doctor.py      # compatibuddy doctor
    โ”œโ”€โ”€ agent.py       # compatibuddy agent (interactive)
    โ””โ”€โ”€ repair.py      # compatibuddy repair (autonomous)

Agent Tools

The Gemini agent has access to 9 structured tools โ€” not arbitrary shell access:

Tool Purpose
tool_probe_hardware Detect OS, CPU, GPU, CUDA version
tool_inspect_environment List all installed Python packages
tool_run_doctor Full compatibility diagnosis
tool_explain_issue Detailed explanation of a specific issue
tool_search_rules Search knowledge base for rules about a package
tool_snapshot_environment Capture pip freeze as rollback point
tool_run_pip Execute pip install/uninstall with safety guardrails
tool_verify_fix Re-diagnose and compare before/after
tool_rollback Restore packages to a previous snapshot

Safety Guardrails

The repair agent operates under strict safety constraints:

  • Virtual environment isolation โ€” refuses to modify system Python
  • Snapshot before every change โ€” full rollback capability
  • Dry-run by default โ€” shows what it would do without executing
  • Protected package blocklist โ€” never uninstalls pip, setuptools, wheel, or itself
  • Operation limit โ€” stops after 10 pip commands per session
  • Only pip install/uninstall โ€” no arbitrary shell commands
  • Automatic rollback โ€” if a fix introduces new problems, reverts immediately

What Makes This Different

Feature Compatibillabuddy Generic AI Chatbot
Runs real diagnostics โœ… Structured tool calls โŒ Guesses from description
Executes real fixes โœ… pip commands with guardrails โŒ "Try running this command..."
Verifies every fix โœ… Re-diagnoses after each change โŒ No verification
Self-corrects โœ… Rollback + alternative on failure โŒ No error recovery
Works offline โœ… compatibuddy doctor (no AI) โŒ Requires API
Hardware-aware โœ… GPU/CUDA as first-class dependency โŒ Ignores hardware
Extensible rules โœ… TOML rulepacks, community-driven โŒ Hardcoded knowledge
Production quality โœ… PyPI, 280+ tests, CI/CD โŒ Demo/prototype

Known Compatibility Rules

The bundled ml_core.toml rulepack covers:

  • CUDA mismatches โ€” PyTorch, TensorFlow, JAX vs. detected CUDA version
  • NumPy ABI breaks โ€” pandas, scikit-learn, scipy built against incompatible NumPy
  • Driver conflicts โ€” GPU driver version vs. framework requirements

Rules are written in TOML and can be extended by the community:

[[rule]]
id = "cuda-torch-mismatch"
description = "PyTorch installed without CUDA support on a CUDA-capable system"
severity = "error"
category = "cuda-mismatch"
fix_suggestion = "pip install torch --index-url https://download.pytorch.org/whl/cu121"

[rule.when]
package_installed = "torch"
gpu_vendor = "nvidia"

Development

git clone https://github.com/jemsbhai/compatibillabuddy.git
cd compatibillabuddy
pip install -e ".[all]"

# Run tests
pytest

# Lint
ruff check src/ tests/
ruff format --check src/ tests/

# Integration tests (requires GEMINI_API_KEY)
pytest tests/integration/ -m integration -v

Tech Stack

  • Python 3.10+ (tested on 3.10โ€“3.13)
  • Pydantic v2 โ€” structured data models with JSON schema export
  • Typer + Rich โ€” CLI with beautiful terminal output
  • google-genai SDK โ€” Gemini function calling for the agent
  • packaging โ€” PEP 440 version matching
  • pytest โ€” 280+ tests with CI on 3 OS ร— 4 Python versions
  • Hatchling โ€” modern Python build backend

License

MIT โ€” see LICENSE.

Author

Muntaser Syed โ€” muntaser@ieee.org

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

compatibillabuddy-0.2.1.tar.gz (57.6 kB view details)

Uploaded Source

Built Distribution

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

compatibillabuddy-0.2.1-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file compatibillabuddy-0.2.1.tar.gz.

File metadata

  • Download URL: compatibillabuddy-0.2.1.tar.gz
  • Upload date:
  • Size: 57.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for compatibillabuddy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 56ab0d2e7e386fbfb556c128406e779040bda5a01444495d7e829dd567b3a1c8
MD5 ddd134807d082cc1c3ea013e98bcf026
BLAKE2b-256 0970a974971865fc6a18d1e648a6a66a6175c18a22892c1bd1ae248c623d1944

See more details on using hashes here.

Provenance

The following attestation bundles were made for compatibillabuddy-0.2.1.tar.gz:

Publisher: release.yml on jemsbhai/compatibillabuddy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compatibillabuddy-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for compatibillabuddy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 706ff116aa5b4964a6d4112728834bdae9b40b26da9ffc49f4f52bcf6e7d93b2
MD5 60c79458ec8cd44a4121102f37a270a6
BLAKE2b-256 df483335ae593359f96955a665024b6869522d541cf733906e62b3477485e832

See more details on using hashes here.

Provenance

The following attestation bundles were made for compatibillabuddy-0.2.1-py3-none-any.whl:

Publisher: release.yml on jemsbhai/compatibillabuddy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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