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
- Go to Firebase Console
- Select your project (epump-e3713)
- Go to Project Settings โ Service Accounts
- Generate new private key
- Save JSON file and set
FIREBASE_CREDENTIALSpath
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 usersget_workouts(user_email=None, limit=10)- Get workoutsget_user_data(user_email, include_analyses=True)- Comprehensive user dataget_all_users_summary(limit=10)- System overview
InspectorConfig
Configuration management.
Properties:
project_id- Firebase project IDcredentials_path- Path to service account JSONdefault_limit- Default query limitlog_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:
- Check the examples in
example_ml_usage.py - Review the CLI help:
epump-inspector --help - 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24619564cdcad5ac43a6d6744563676751376920619af2f7b990e36be8b63fd6
|
|
| MD5 |
7364af5545a22c1a5e285c7eac1f2f08
|
|
| BLAKE2b-256 |
3b1b5e8611cf5411562917326d2ff59f7f8f390742743a5ce5a44f677bac2545
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83824bfb3aabd9136e595d7eda60fb700737606eeb8155e04b9c43999b18b77e
|
|
| MD5 |
7b27173026c4532a63cf1dfbc09ae456
|
|
| BLAKE2b-256 |
eb81652ed96cd4b47bc00254c15a008aa53e0b71c61bcc5b3ca6a2a6dedc75ae
|