Skip to main content

ePump Inspector Library and CLI for Firestore database analysis

Project description

ePump Inspector

A Python library and CLI tool for inspecting and analyzing ePump.app Firestore database data. Designed for both command-line usage and programmatic access for machine learning and data analysis tasks.

Features

  • ๐Ÿ” Database Inspection: Complete read-only access to Firestore database
  • ๐Ÿ“Š ML/Analysis Ready: Core library designed for machine learning workflows
  • ๐Ÿ–ฅ๏ธ Command Line Interface: Convenient CLI for quick database queries
  • ๐ŸŽฏ Type Safety: Full type hints and structured configuration
  • ๐Ÿ” Security First: Comprehensive .gitignore patterns for credentials
  • ๐Ÿ“ˆ Performance: Efficient querying with configurable limits
  • ๐Ÿ Python 3.8+: Modern Python with Poetry package management

Installation

Using Poetry (Recommended)

# Install dependencies
poetry install

# Run CLI commands
poetry run epump-inspector users

# Or activate the virtual environment
poetry shell
epump-inspector users

Using pip

pip install -e .
epump-inspector users

Configuration

Environment Variables

Create a .env file in the project root:

FIREBASE_PROJECT_ID=epump-e3713
FIREBASE_CREDENTIALS=/path/to/service-account.json
DEFAULT_LIMIT=10
LOG_LEVEL=warning

Firebase Setup

  1. Go to Firebase Console
  2. Select your project (epump-e3713)
  3. Go to Project Settings โ†’ Service Accounts
  4. Generate new private key
  5. Save JSON file and set FIREBASE_CREDENTIALS path

CLI Usage

Basic Commands

# Get all users
epump-inspector users

# Get comprehensive user data (perfect for ML)
epump-inspector user-data --user-email user@example.com

# Get system summary
epump-inspector summary --limit 5

# Get workouts for specific user
epump-inspector workouts --user-email user@example.com

# Get API keys status
epump-inspector api-keys

# Pretty print JSON output
epump-inspector users --pretty

Advanced Commands

# Get specific workout analysis
epump-inspector workout-analyses --user-email user@example.com --workout-id WORKOUT_ID

# Get AI feedback data
epump-inspector ai-feedback --user-email user@example.com

# Check migration status
epump-inspector migration-status --user-email user@example.com

# Generic collection access
epump-inspector collection --path "users/user@example.com/workout_sessions"

Library Usage

Basic Example

from epump_inspector import DatabaseInspector, InspectorConfig

# Using environment configuration
inspector = DatabaseInspector()

# Or custom configuration
config = InspectorConfig(
    project_id="epump-e3713",
    credentials_path="/path/to/credentials.json",
    default_limit=20,
    log_level="info"
)
inspector = DatabaseInspector(config)

# Use context manager for automatic connection handling
with inspector.connection():
    users = inspector.get_users(limit=10)
    workouts = inspector.get_workouts(user_email="user@example.com")
    
    print(f"Found {len(users)} users and {len(workouts)} workouts")

ML/Data Analysis Example

from epump_inspector import DatabaseInspector

inspector = DatabaseInspector()

with inspector.connection():
    # Get comprehensive user data for ML analysis
    user_data = inspector.get_user_data(
        user_email="user@example.com",
        include_analyses=True  # Include workout analyses and AI suggestions
    )
    
    # Extract training data for AI models
    ai_feedback = inspector.get_ai_feedback(limit=1000)
    workout_analyses = inspector.get_workout_analyses(limit=1000)
    
    # Get system overview
    summary = inspector.get_all_users_summary(limit=100)
    
    # User data contains:
    # - workouts, supplements, diets
    # - health_goals, workout_goals, unified_goals
    # - ai_feedback, workout_analyses, ai_suggestions
    # - fitness_profile, active_diet
    # - goal_migration_completed status

Error Handling

from epump_inspector import DatabaseInspector, InspectorError, DataNotFoundError

inspector = DatabaseInspector()

try:
    with inspector.connection():
        # This will raise DataNotFoundError if not found
        workout = inspector.get_workout("user@example.com", "nonexistent-id")
        
except DataNotFoundError as e:
    print(f"Data not found: {e}")
except InspectorError as e:
    print(f"Inspector error: {e}")
except Exception as e:
    print(f"Unexpected error: {e}")

API Reference

Core Classes

DatabaseInspector

Main class for database operations.

Key Methods:

  • get_users(limit=10) - Get all users
  • get_workouts(user_email=None, limit=10) - Get workouts
  • get_user_data(user_email, include_analyses=True) - Comprehensive user data
  • get_all_users_summary(limit=10) - System overview

InspectorConfig

Configuration management.

Properties:

  • project_id - Firebase project ID
  • credentials_path - Path to service account JSON
  • default_limit - Default query limit
  • log_level - Logging level

Available Data Types

  • Users: User profiles and metadata
  • Workouts: Exercise sessions and workout data
  • Supplements: Supplement tracking data
  • Diets: Diet plans and active diet settings
  • Goals: Health goals, workout goals, unified goals
  • AI Data: AI suggestions, feedback, and workout analyses
  • API Keys: System API keys and tokens
  • Migration: Goal migration status

Development

Setup Development Environment

# Clone and install
git clone <repository>
cd tool
poetry install

# Run tests
poetry run pytest

# Code formatting
poetry run black .
poetry run flake8 .
poetry run mypy .

# Build package
poetry build

Project Structure

tool/
โ”œโ”€โ”€ epump_inspector/          # Core library package
โ”‚   โ”œโ”€โ”€ __init__.py          # Package exports
โ”‚   โ”œโ”€โ”€ core.py              # Main DatabaseInspector class
โ”‚   โ”œโ”€โ”€ config.py            # Configuration management
โ”‚   โ”œโ”€โ”€ cli.py               # Command-line interface
โ”‚   โ””โ”€โ”€ exceptions.py        # Custom exceptions
โ”œโ”€โ”€ database/                 # Database abstraction layer
โ”‚   โ”œโ”€โ”€ __init__.py          # Abstract DAO interface
โ”‚   โ””โ”€โ”€ firestore_dao.py     # Firestore implementation
โ”œโ”€โ”€ inspector.py             # Legacy CLI (maintained for compatibility)
โ”œโ”€โ”€ cli.py                   # Standalone CLI wrapper
โ”œโ”€โ”€ example_ml_usage.py      # ML usage examples
โ”œโ”€โ”€ pyproject.toml           # Poetry configuration
โ”œโ”€โ”€ .env.example             # Environment template
โ””โ”€โ”€ README.md                # This file

Security

  • All sensitive files are excluded via .gitignore
  • Credentials are loaded from environment variables
  • No hardcoded API keys or secrets
  • Type-safe configuration validation

Examples

See example_ml_usage.py for comprehensive ML/data analysis examples including:

  • User workout pattern analysis
  • Multi-user performance comparison
  • AI training data extraction
  • System health reporting

Support

For issues and questions:

  1. Check the examples in example_ml_usage.py
  2. Review the CLI help: epump-inspector --help
  3. Check logs with --log-level debug

License

MIT License - see LICENSE file for details.

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

epump_inspector-1.0.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

epump_inspector-1.0.1-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file epump_inspector-1.0.1.tar.gz.

File metadata

  • Download URL: epump_inspector-1.0.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.6.0

File hashes

Hashes for epump_inspector-1.0.1.tar.gz
Algorithm Hash digest
SHA256 24619564cdcad5ac43a6d6744563676751376920619af2f7b990e36be8b63fd6
MD5 7364af5545a22c1a5e285c7eac1f2f08
BLAKE2b-256 3b1b5e8611cf5411562917326d2ff59f7f8f390742743a5ce5a44f677bac2545

See more details on using hashes here.

File details

Details for the file epump_inspector-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: epump_inspector-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.13.3 Darwin/24.6.0

File hashes

Hashes for epump_inspector-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 83824bfb3aabd9136e595d7eda60fb700737606eeb8155e04b9c43999b18b77e
MD5 7b27173026c4532a63cf1dfbc09ae456
BLAKE2b-256 eb81652ed96cd4b47bc00254c15a008aa53e0b71c61bcc5b3ca6a2a6dedc75ae

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