types
Versioned cache records.
Each sub-package is one logical cache table (<name>/) containing one package
per schema version (v1/, v2/, ...). A version package vertically integrates
the SQLAlchemy ORM (schema.py), the Pydantic record (model.py), the CRUD
helpers (store.py), and its inbound migration (migrations.py), and
re-exports canonical aliases from its __init__.py. Discovery is driven by
bitfount.cache.registry.
The ORM (schema.py) is the single authoring source of truth for a version's
table. migrations.py holds an Alembic op-API upgrade(op) / downgrade(op)
pair taking v(N-1) -> vN, autogenerated from the ORM diff by
python -m bitfount.cache.tools.gen_migration <name> <N> — never hand-authored
from scratch. v1 has no predecessor, so its migrations.py defines neither.
Mental model — who owns what (this diverges from canonical Alembic on purpose):
- The ORM owns table existence. A missing table is created directly from
its target-version ORM by
ensure_types(implementations/sqlite.py), not by replaying a v1create_tablemigration. The additive-only invariant is what makes creating straight at the target safe: every later version is a superset, so lower-version consumers still read/write the table correctly. - Migrations own the incremental delta between two existing versions
(
vN.upgrade= v(N-1) -> vN) — the ALTERs (add/rename/drop/retype) autogen emits. There is no v1create_table/drop_table: v1 has no prior version, a v1 create would merely duplicate the ORM, and the driver never reaches it (_apply_upgradeswalkscurrent+1 .. targetwithcurrent >= 1).
Consequence: a fresh cache open is one table.create() per type from the ORM —
never a full v1..vN chain replay.
Module
Submodules
- bitfount.cache.types.cst_calculation -
cst_calculationcache type. - bitfount.cache.types.ehr_data -
ehr_datacache record — per-patient EHR demographics and code lists. - bitfount.cache.types.ehr_patient_ids -
ehr_patient_idscache record — patient IDs from the EHR listing endpoint. - bitfount.cache.types.file_metadata -
file_metadatacache record — filesystem metadata for datasource files. - bitfount.cache.types.flow_specs -
flow_specscache record — persisted replay material for background runs. - bitfount.cache.types.fluid_calculation -
fluid_calculationcache record — per-scan fluid volume metrics. - bitfount.cache.types.ga_calculation -
ga_calculationcache type. - bitfount.cache.types.ga_calculation_without_fovea -
ga_calculation_without_foveacache type. - bitfount.cache.types.gcc_calculation -
gcc_calculationcache type. - bitfount.cache.types.lesion_calculation -
lesion_calculationcache record — per-scan en-face area metrics. - bitfount.cache.types.model_inferences -
model_inferencescache record — raw model inference results. - bitfount.cache.types.patient_eligibility -
patient_eligibilitycache record — rolled-up per-patient verdicts. - bitfount.cache.types.patient_enrichment -
patient_enrichmentcache record — externally supplied patient data. - bitfount.cache.types.patient_level_eligibility -
patient_level_eligibilitycache record — per-patient EHR eligibility verdicts. - bitfount.cache.types.patients -
patientscache record — patient identity rows. - bitfount.cache.types.runs -
runscache record — lifecycle tracking for flow executions. - bitfount.cache.types.scan_eligibility -
scan_eligibilitycache record — per-scan eligibility verdicts. - bitfount.cache.types.scan_metadata -
scan_metadatacache record — vendor-normalized per-scan header metadata. - bitfount.cache.types.schema - Shared columns for every versioned cache record.
- bitfount.cache.types.schema_versions -
schema_versionscache record — pipeline schema version snapshots. - bitfount.cache.types.trials_published_data_pointer -
trials_published_data_pointer— per-project published task-hash pointer.