Skip to content

E2.2: cut legacy hardware API, make backend run on SQLite - #69

Draft
RaapTechllc wants to merge 1 commit into
mainfrom
cursor/era-2-backend-cut-e9a0
Draft

RaapTechllc wants to merge 1 commit into
mainfrom
cursor/era-2-backend-cut-e9a0

Conversation

@RaapTechllc

Copy link
Copy Markdown
Owner

Second step of the Era 2 cut (plan in #67; frontend half in #68). Backend + docs only. Independent of #68 at the code level; merge in either order.

Deleted

  • Models Benchmark, HardwareSpec, ReferenceProfile, ModelQuality and their seed data (HARDWARE_SPECS, REFERENCE_PROFILES, MODEL_QUALITY, SAMPLE_BENCHMARKS)
  • Schemas BenchmarkSubmit, BenchmarkResponse, HardwareSpecResponse, ReferenceProfileResponse, ModelQualityResponse, LeaderboardEntry, CompareResponse, StatsResponse
  • Routes /api/v1/{submit,benchmarks,benchmarks/{id},leaderboard,hardware,profiles,compare,stats,models} and compute_hei
  • The 15 legacy test_api.py cases; replaced by three smoke tests asserting the routes and OpenAPI schemas are gone

Existing Postgres tables are left in place; the drop migration is E2.5.

SQLite support

  • models.py: JSON().with_variant(JSONB, "postgresql"), generic Uuid, BigInteger().with_variant(Integer, "sqlite") for autoincrement PKs
  • aiosqlite added to requirements.txt; DATABASE_URL=sqlite+aiosqlite:///./minibench.db now works for local dev
  • conftest.py: MINIBENCH_TEST_DB=auto|postgres|sqlite (default auto: Postgres if reachable, else a temp SQLite file). Raw psycopg2 helpers replaced by SQLAlchemy execute/table_count. CI still runs Postgres.
  • Two behaviours that silently depended on Postgres are now explicit: VARCHAR length limits are checked in Python before insert (same 422 contract on both backends), and submitted_at is set client-side at microsecond precision so "latest run wins" ordering is deterministic (SQLite's CURRENT_TIMESTAMP is second-granular)
  • test_migrations.py is marked Postgres-only (replays raw ALTER TABLE SQL)

Verification

cd backend && pytest on SQLite: 69 passed, 1 skipped. Postgres run pending CI on this PR.

Open in Web Open in Cursor 

Remove the Era 1 benchmarks/hardware_specs/reference_profiles/model_quality
models, schemas, seed data and the /benchmarks, /submit, /leaderboard,
/hardware, /profiles, /compare, /stats, /models routes. Tables are left in
place for the E2.5 drop migration.

Make column types portable (JSON with a JSONB variant, generic Uuid, Integer
PK variant for SQLite) and add aiosqlite so the API runs without Postgres.
Validate VARCHAR lengths in Python so the 422 storage-limit contract holds on
both backends, and set submitted_at client-side at microsecond precision so
latest-run ordering is deterministic everywhere.

Tests pick Postgres when reachable and otherwise a temp SQLite file
(MINIBENCH_TEST_DB=auto|postgres|sqlite); the migration replay is
Postgres-only and skips on SQLite.

Co-authored-by: RaapTechllc <RaapTechllc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants