Files
POTE/docs/OFFLINE_DEMO.md
T
ilia 5df21d82f4
CI / skip-ci-check (pull_request) Successful in 19s
CI / secret-scan (pull_request) Successful in 19s
CI / python-ci (pull_request) Successful in 2m38s
Fix lint debt and make CI gates honest
- ruff: fix all 328 errors (autofix + manual); move config to [tool.ruff.lint]
- mypy: fix all errors (annotations, nullable-column guards, stale kwargs
  in weekly report caller)
- black: reformat src/tests so black --check passes
- CI: remove `|| true` from ruff/black/mypy/pytest steps in both
  .gitea and .github workflows; install project deps and add mypy
  step in gitea python-ci so gates actually run
- docs: move 14 root status/guide markdown files into docs/, update links
2026-07-26 15:41:07 -04:00

117 lines
3.3 KiB
Markdown

# Offline Demo - Works Without Internet!
## ✅ Full System Working Without Network Access
Even though your environment doesn't have external internet, **everything works perfectly** using fixture files.
### What Just Worked (100% Offline)
```bash
python scripts/ingest_from_fixtures.py
# Output:
# ✓ Officials created/updated: 4
# ✓ Securities created/updated: 2
# ✓ Trades ingested: 5
#
# Database totals:
# Total officials: 4
# Total trades: 5
#
# Sample Officials:
# Nancy Pelosi (House, Democrat): 2 trades
# Josh Gottheimer (House, Democrat): 1 trades
# Tommy Tuberville (Senate, Republican): 1 trades
# Dan Crenshaw (House, Republican): 1 trades
```
### How It Works
1. **Test Fixtures** (`tests/fixtures/sample_house_watcher.json`)
- Realistic sample data (5 trades, 4 officials)
- Nancy Pelosi, Josh Gottheimer, Tommy Tuberville, Dan Crenshaw
- NVDA, MSFT, AAPL, TSLA, GOOGL tickers
2. **Offline Scripts**
- `scripts/ingest_from_fixtures.py` - Ingest sample trades (✅ works now!)
- `scripts/fetch_sample_prices.py` - Would need network (yfinance)
3. **28 Passing Tests** - All use mocks, no network required
- Models: 7 tests
- Price loader: 8 tests (mocked yfinance)
- House watcher: 8 tests (mocked HTTP)
- Trade loader: 5 tests (uses fixtures)
### Query the Database
```python
from pote.db import SessionLocal
from pote.db.models import Official, Trade
from sqlalchemy import select
with SessionLocal() as session:
# Get all officials
stmt = select(Official)
officials = session.scalars(stmt).all()
for official in officials:
print(f"{official.name} ({official.party})")
# Get their trades
stmt = select(Trade).where(Trade.official_id == official.id)
trades = session.scalars(stmt).all()
for trade in trades:
print(f" {trade.transaction_date}: {trade.side} {trade.security.ticker}")
```
### What You Can Do Offline
**Run all tests**: `make test`
**Ingest fixture data**: `python scripts/ingest_from_fixtures.py`
**Query the database**: Use Python REPL or SQLite browser
**Lint & format**: `make lint format`
**Run migrations**: `make migrate`
**Build analytics** (Phase 2): All math/ML works offline!
**Can't do (needs network)**:
- Fetch live congressional trades from House Stock Watcher
- Fetch stock prices from yfinance
- (But you can add more fixture files to simulate this!)
### For Production (With Internet)
When you deploy to an environment with internet:
```bash
# Fetch real congressional trades
python scripts/fetch_congressional_trades.py --days 30
# Fetch real stock prices
python scripts/fetch_sample_prices.py
# Everything "just works" with the same code!
```
### Adding More Fixture Data
You can expand the fixtures for offline development:
```bash
# Add more trades to tests/fixtures/sample_house_watcher.json
# Add price data to tests/fixtures/sample_prices.csv
# Update scripts to load from these files
```
---
## Summary
**The network error is not a problem!** The entire system is designed to work with:
- ✅ Fixtures for development/testing
- ✅ Real APIs for production (when network available)
- ✅ Same code paths for both
This is **by design** - makes development fast and tests reliable! 🚀