ePump Inspector Library and CLI for Firestore database analysis
Project description
Database Inspector Tool
A Python-based inspector tool for querying and analyzing ePump.app's Firestore database.
Features
- Database Abstraction: Easy to switch between different database backends
- AI Analysis Queries: Retrieve AI training and analysis data
- AI Feedback Queries: Access user feedback on AI interactions
- Workout Data: Query workout sessions and exercise data
- User Data: Retrieve user information
- Generic Collections: Query any Firestore collection path
- JSON Output: All results in JSON format for easy processing
Installation
Option 1: Using Poetry (Recommended)
cd tool
# Install Poetry if you haven't already
curl -sSL https://install.python-poetry.org | python3 -
# Install dependencies and create virtual environment
poetry install
# Activate the virtual environment
poetry shell
# Or run commands directly with poetry
poetry run epump-inspector --help
Option 2: Using pip (Legacy)
cd tool
pip install -r requirements.txt
Configuration
Option 1: Environment File (.env) - Recommended
# Copy the example file
cp .env.example .env
# Edit .env with your actual values
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_CREDENTIALS=/path/to/your/service-account.json
DEFAULT_LIMIT=10
Option 2: Environment Variables
export FIREBASE_PROJECT_ID="your-project-id"
export FIREBASE_CREDENTIALS="/path/to/service-account.json"
Option 3: Command-Line Arguments
python inspector.py --project-id your-project-id --credentials /path/to/service-account.json COMMAND
Note: The tool will load configuration in this priority order:
- Command-line arguments (highest priority)
- Environment variables
- .env file values (lowest priority)
Usage
Get AI Analysis Data
# Using Poetry
poetry run epump-inspector ai-analysis
poetry run epump-inspector ai-analysis --user-id USER_ID --limit 20 --pretty
# Using direct Python (if not using Poetry)
python inspector.py ai-analysis
python inspector.py ai-analysis --user-id USER_ID --limit 20 --pretty
# If you're in the Poetry shell
epump-inspector ai-analysis --pretty
Get AI Feedback
# Using Poetry
poetry run epump-inspector ai-feedback
poetry run epump-inspector ai-feedback --user-id USER_ID --limit 50
# Using direct Python
python inspector.py ai-feedback --user-id USER_ID --limit 50
Get Workout Data
# Using Poetry
poetry run epump-inspector workouts
poetry run epump-inspector workouts --user-id USER_ID
# Using direct Python
python inspector.py workouts --user-id USER_ID
Get User Data
# Using Poetry
poetry run epump-inspector users --limit 5
# Using direct Python
python inspector.py users --limit 5
Query Generic Collections
# Using Poetry
poetry run epump-inspector collection --path users
poetry run epump-inspector collection --path users/USER_ID/supplements --pretty
# Using direct Python
python inspector.py collection --path users/USER_ID/ai_feedback --pretty
Output Format
All commands output JSON with the following structure:
{
"command": "ai-analysis",
"count": 10,
"user_id": "optional_user_id",
"data": [
{
"_id": "document_id",
"field1": "value1",
"field2": "value2"
}
]
}
Database Abstraction
The tool uses a DAO (Data Access Object) pattern for database abstraction:
DatabaseDAO: Abstract base class defining the interfaceFirestoreDAO: Firestore implementation
To add a new database backend:
- Create a new class inheriting from
DatabaseDAO - Implement all abstract methods
- Update
inspector.pyto use the new DAO
Available Methods in DAO
connect(**kwargs): Connect to databasedisconnect(): Disconnect from databaseget_ai_analysis(user_id, limit): Get AI analysis dataget_ai_feedback(user_id, limit): Get AI feedback dataget_workouts(user_id, limit): Get workout dataget_users(limit): Get user dataget_collection(path, limit): Get generic collection data
Examples
Process AI Analysis with jq
# Using Poetry
poetry run epump-inspector ai-analysis --limit 100 | jq '.data[] | {id: ._id, user: .user_id, created: .timestamp}'
poetry run epump-inspector ai-feedback | jq '[.data[] | select(.positive == true)] | length'
# Using direct Python
python inspector.py ai-analysis --limit 100 | jq '.data[] | {id: ._id, user: .user_id, created: .timestamp}'
python inspector.py ai-feedback | jq '[.data[] | select(.positive == true)] | length'
Export to CSV
# Using Poetry
poetry run epump-inspector users | jq -r '.data[] | [._id, .email, .created_at] | @csv' > users.csv
# Using direct Python
python inspector.py users | jq -r '.data[] | [._id, .email, .created_at] | @csv' > users.csv
Filter by Date
# Using Poetry
poetry run epump-inspector workouts | jq '.data[] | select(.date >= "2024-01-01")'
# Using direct Python
python inspector.py workouts | jq '.data[] | select(.date >= "2024-01-01")'
Error Handling
Errors are returned as JSON:
{
"error": "Error message",
"command": "command_name"
}
Security Notes
- Store Firebase credentials securely
- Never commit service account files to version control
- Use environment variables for sensitive data
- Limit service account permissions to read-only access when possible
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.0.tar.gz.
File metadata
- Download URL: epump_inspector-1.0.0.tar.gz
- Upload date:
- Size: 14.1 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 |
3d70d1e3dac71052131d495b0be3ae18b2c2296034bb458c432da619a17b2b0b
|
|
| MD5 |
efbbbcb435a25ddd1aaece973f041c56
|
|
| BLAKE2b-256 |
a1a637ee55003382661305a20b10c63610efecd8e1950d26a7592d4f810d14ec
|
File details
Details for the file epump_inspector-1.0.0-py3-none-any.whl.
File metadata
- Download URL: epump_inspector-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.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 |
d38cad277807cbad309d05c00d12040047b55c5d184a5b97ddc8e5c646c8eb00
|
|
| MD5 |
805eea1a4f24d711abf2d075027b2aef
|
|
| BLAKE2b-256 |
9c37b9fd0df1c20b028c2e0102fe6b5cfba62d99b545e38fbae0244c276c1699
|