Commit Graph

59 Commits

Author SHA1 Message Date
alberto c649ad9308 T17: models sweep: unused helpers in execution, association and the EEG analysis and checks removed 2026-12-01 06:07:45 -06:00
alberto 83639e708d Merge parity/main into parity/T3-training-source 2026-12-01 01:09:45 -06:00
alberto 8fd4930ca9 T3: TEA age curves train from one training source: the site or a folder
PLAN-feature-parity §2.3 and user decisions 2 and 6.
- jobs._cohort(source, as_of) replaces _reference: kind "site" (default) takes the valid
  EEGs of the children without the diagnosis by the cut-off (persistance.eeg
  .without_diagnosis, rebuild's ruled-out group in tea/parity's design); kind "folder"
  takes a folder under TEA_REFERENCE_ROOT with its EDFs and edades.csv (path, age in
  months), measured at the folder's mains and cached by content as before.
- The legacy TEA_REFERENCE_DIR / TEA_REFERENCE_AGES path, the hk1k name and the
  years-to-months ages table are gone: Helsinki is one such folder.
- Reports and params name the cohort (site or the folder), its digest, and the cut-off
  (site) or mains (folder).
- definitions: Training.source (TrainingSourceConfig) replaces reference.
- tests: test_tea_reference -> test_tea_training_source (folder listing and errors, the
  site cohort's cut-off rules).
2026-12-01 00:53:27 -06:00
alberto 7751c176f0 T2: removed tests/recurrence_reference.py — reference-parity helper, no test uses it 2026-12-01 00:46:19 -06:00
alberto fde57b9074 test_link_answers starts a whole platform: removed (P7) 2026-12-01 00:23:32 -06:00
alberto 2ff5c04238 Merge origin/rebuild into parity/T1-merge (models)
Per PLAN-feature-parity §2.1/2.2/2.4: non-TEA from rebuild, TEA backend from tea/parity.
- tea/association.py, tea/jobs.py, tea/eeg/reference.py: tea/parity's (tea-lib association
  checked against the reference; reference-cohort training; execution.map). rebuild's
  ruled-out training and its own association go; T3 adds the site cohort as a training
  source in tea/parity's design.
- cluster.py deleted: tea/parity's persistance.cluster + models.execution run every batch.
  The optional [dask] extra goes with it (Persistance depends on dask directly).
- definitions.py: tea/parity's jobs (tea_eeg, preview, bundles, sensor) plus rebuild's
  backup job and nightly schedule. Scoring takes Jobs.routine(); rebuild's scored() was
  the same list, so it is not kept as a second name.
- graph.py: tea/parity's edf reader node plus rebuild's file_format and otherwise-routes.
- jobs.py: rebuild's (every model is routine; no reference-trained branch).
- tests: tea/parity's logic tests kept where both changed (test_eeg, test_recurrence,
  test_silver); test_survival_seer stays deleted (P7).
2026-11-30 23:56:11 -06:00
alberto 7088e0e946 ADOS-2 preview carries each item's code and title from the Core list
The preview result names the module's items by the titles in
core.tea.ados2_items, module items first, so the Gobernanza dialog and its
PDF print what the report asks instead of field names.
2026-11-30 19:17:46 -06:00
alberto 7c05de6398 Merge tea/P8-ados2-titles into tea/final 2026-11-30 17:00:09 -06:00
alberto c59afacad9 ADOS-2 preview reads every catalog item; totals come from the module's list
core.tea no longer has module-independent SA/RRB lists: the preview parses
all ADOS2_ITEMS and the scoring takes each module's own items from
core.tea.ados2_items.
2026-11-30 16:56:26 -06:00
alberto c1a1e294dc The suite keeps only logic tests
Keep deterministic model, signal, DSL and SQLite storage checks.

Checks: ruff check, ruff format --check, lint-imports (two contracts kept), and pytest (115 passed, 7 warnings in 42.52s).

removed models/tests/test_bundle.py::test_guard_runs_on_export_and_on_import — implementation-detail
removed models/tests/test_cacu_models.py — parity-only
removed models/tests/test_cacu_models.py::test_predictions_match_the_current_models — parity-only
removed models/tests/test_cacu_models.py::test_survival_matches_the_current_model_with_its_index_fixed — parity-only
removed models/tests/test_cacu_models.py::test_a_cohort_the_site_lacks_is_reported_not_trained — implementation-detail
removed models/tests/test_cama_models.py — parity-only
removed models/tests/test_cama_models.py::test_survival_matches_the_current_model — parity-only
removed models/tests/test_edf_node.py — slow integration (logic now covered by test_header_reads_the_facts, test_not_an_edf_is_not_valid and test_collected_files_are_kept_once_by_content)
removed models/tests/test_edf_node.py::test_edf_pipeline_keeps_and_links_the_files — slow integration (logic now covered by test_header_reads_the_facts, test_not_an_edf_is_not_valid and test_collected_files_are_kept_once_by_content)
removed models/tests/test_edf_upload.py — slow integration (logic now covered by test_tea_eeg_first_n_selects_exactly_n_pending_studies for study selection)
removed models/tests/test_edf_upload.py::test_an_uploaded_edf_is_analysed_by_itself — slow integration (logic now covered by test_tea_eeg_first_n_selects_exactly_n_pending_studies for study selection)
removed models/tests/test_eeg.py::test_verdicts_and_checks — parity-only
removed models/tests/test_eeg.py::test_metric_values — parity-only
removed models/tests/test_eeg.py::test_reference_features — parity-only
removed models/tests/test_eeg.py::test_curves — parity-only
removed models/tests/test_execution.py::test_map_empty_items_starts_nothing — implementation-detail
removed models/tests/test_execution.py::test_map_local_equals_sync — slow integration (logic now covered by test_map_sync_keeps_input_order_and_reports_each_item)
removed models/tests/test_execution.py::test_map_lazy_items_are_not_all_loaded_at_once — implementation-detail
removed models/tests/test_execution.py::test_progress_tag_and_log_lines_inside_running — implementation-detail
removed models/tests/test_execution.py::test_no_tag_outside_running — implementation-detail
removed models/tests/test_execution.py::test_version_mismatch_fails_before_any_task — implementation-detail
removed models/tests/test_execution.py::test_local_cancel_leaves_no_worker_processes — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for cancellation states)
removed models/tests/test_execution.py::test_health_sync_and_local — slow integration (logic now covered by test_resolve_defaults_and_allow_list for execution defaults)
removed models/tests/test_execution.py::test_health_unreachable_remote — slow integration (logic now covered by test_resolve_rejects_unlisted_scheduler_and_scheduler_in_local_mode for scheduler validation)
removed models/tests/test_execution.py::test_health_rejects_unlisted_scheduler — implementation-detail
removed models/tests/test_execution.py::test_progress_reaches_the_dagster_run — slow integration (logic now covered by test_shape_progress_tag and test_map_sync_keeps_input_order_and_reports_each_item)
removed models/tests/test_execution.py::test_map_remote_equals_sync — slow integration (logic now covered by test_map_sync_keeps_input_order_and_reports_each_item)
removed models/tests/test_execution.py::test_health_remote — slow integration (logic now covered by test_resolve_defaults_and_allow_list for remote execution choice)
removed models/tests/test_execution.py::test_remote_cancel_cancels_futures — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for cancellation states)
removed models/tests/test_execution.py::test_progress_json_is_stable — implementation-detail
removed models/tests/test_execution.py::test_map_on_error_converts_a_failed_item[local] — slow integration (logic now covered by test_map_on_error_converts_a_failed_item)
removed models/tests/test_execution.py::test_map_raises_without_on_error[local] — slow integration (logic now covered by test_map_raises_without_on_error)
removed models/tests/test_ingest.py — slow integration (logic now covered by test_collected_files_are_kept_once_by_content and test_the_drawn_patterns_read_every_report)
removed models/tests/test_ingest.py::test_a_site_reaches_bronze_once_and_its_documents_are_read — slow integration (logic now covered by test_collected_files_are_kept_once_by_content and test_the_drawn_patterns_read_every_report)
removed models/tests/test_recurrence.py::test_cohorts — parity-only
removed models/tests/test_recurrence.py::test_routines — parity-only
removed models/tests/test_recurrence.py::test_c_index_and_internal_auc — parity-only
removed models/tests/test_recurrence.py::test_saved_model — parity-only
removed models/tests/test_recurrence.py::test_calculator — parity-only
removed models/tests/test_recurrence.py::test_risk_factors — parity-only
removed models/tests/test_recurrence.py::test_train_reproduces_v1 — parity-only
removed models/tests/test_silver.py::test_a_site_becomes_silver_and_review_gets_the_rest — slow integration (logic now covered by test_person_ids_survive_a_review_merge_and_split and test_a_code_nobody_mapped_is_held_with_the_reason)
removed models/tests/test_survival_seer.py — parity-only
removed models/tests/test_survival_seer.py::test_each_scenario_takes_the_originals_patients_and_deaths — parity-only
removed models/tests/test_survival_seer.py::test_each_scenarios_observed_curves_are_the_originals — parity-only
removed models/tests/test_survival_seer.py::test_the_models_points_are_the_survival_of_the_cases_it_learned_from — parity-only
removed models/tests/test_tea_association.py::test_reference_parity — parity-only
removed models/tests/test_tea_job.py::test_tea_eeg_runs_the_four_steps_in_order — implementation-detail
removed models/tests/test_tea_job.py::test_a_failing_analysis_stops_the_graph — implementation-detail
removed models/tests/test_tea_job.py::test_a_bad_scope_fails_before_any_work — implementation-detail
removed models/tests/test_tea_job.py::test_config_mirrors_match_the_shared_models — implementation-detail
removed models/tests/test_tea_job.py::test_definitions_load_with_every_job_and_the_sensor — implementation-detail
removed models/tests/test_tea_job.py::test_relate_returns_none_without_a_champion — implementation-detail
removed models/tests/test_tea_job.py::test_tea_eeg_first_n_analyses_exactly_n — slow integration (logic now covered by test_tea_eeg_first_n_selects_exactly_n_pending_studies)
removed models/tests/test_tea_job.py::test_tea_eeg_remote_mode_gives_the_same_analysis — slow integration (logic now covered by test_dominant_peak_recovers_a_posterior_rhythm_above_background and test_centile_interpolation_preserves_scoring)
removed models/tests/test_tea_preview.py::test_scores_come_from_the_champions — implementation-detail
removed models/tests/test_tea_preview.py::test_no_champions_warns_and_leaves_z_empty — implementation-detail
removed models/tests/test_tea_preview.py::test_ados2_read_with_the_pipeline_patterns — implementation-detail
removed models/tests/test_tea_preview.py::test_ados2_problems_are_warnings_not_errors — implementation-detail
removed models/tests/test_tea_preview.py::test_the_job_deletes_its_files_and_returns_the_result_as_output — slow integration (logic now covered by the direct-op test_the_job_deletes_its_files_and_returns_the_result_as_output)
removed models/tests/test_tea_preview.py::test_the_job_deletes_its_files_when_the_study_fails — implementation-detail
removed models/tests/test_tea_reference.py::test_a_named_reference_resolves_under_the_root — implementation-detail
removed models/tests/test_tea_reference.py::test_60_hz_changes_the_digest_and_is_passed_on — implementation-detail
removed models/tests/test_tea_reference.py::test_the_cache_is_named_by_cohort_and_digest_and_reused — implementation-detail
removed models/tests/test_tea_reference.py::test_legacy_environment_still_works — implementation-detail
removed models/tests/test_tea_reference.py::test_train_records_cohort_and_line_hz — implementation-detail
removed models/tests/test_tea_reference.py::test_the_train_op_passes_the_reference_or_refuses_it — implementation-detail
removed models/tests/test_tea_reference.py::test_reference_config_mirrors_the_shared_model — implementation-detail
2026-11-30 16:48:32 -06:00
alberto d8445fcabf Cleanup of the TEA parity work: no prose in code, no hacks, everything in its place
1. No prose in code
- Remove parity-added comments and docstrings from TEA jobs, analysis and
  scoring helpers, execution, definitions, and tests. Keep base prose and
  Ruff and type-checker directives.

2. No hacks, no glued code
- Delegate both association cohort queries to persistance.eeg. Keep the
  predictor mapping and DataFrame shaping in the job, sharing biomarker
  codes and EEG study IDs with Core. Preserve column names and order, row
  selection, score filtering, and earliest fitting study.
- Use the existing MODELS registry for curve scoring in place of CURVES.
  Keep GOLD because the generic score job reads it.
- Catch lookup, database, and validation failures when loading a preview
  pipeline, preserving the existing warning. Keep execution-boundary
  exception handling for submitted tasks, telemetry and shutdown.
- Name the association test for the missing-champion case. Preserve its
  assertion and the other test assertions.

3. Everything in its place
- Keep SQL in Persistance, cohort shaping in models, and tests in their
  existing testpaths. Keep the association fits together with their
  shared design and result machinery.
2026-11-30 13:41:49 -06:00
Roberto Treviño 77350b8fec A reviewer's answer holds when more records join a person 2026-11-30 02:14:13 -06:00
Roberto Treviño a9945bc021 A training run takes every model; the public cohorts' code lives with the tests 2026-11-29 21:12:17 -06:00
alberto a818847b99 Expose TEA baseline centiles by age
Share log-age interpolation with scoring and preserve nulls outside coverage. Use a synthetic geometric midpoint and values on both sides of the median to check numeric parity.
2026-11-29 19:45:50 -06:00
alberto e71a7baac5 ADOS-2 association model: Firth/ordinal port, MLflow model, bronze and gold, gate
Port the association estimator and add its source-parity tests in models.
Wire cohort selection, fingerprint deduplication, MLflow registration, and
champion scoring into the TEA jobs. Add both bronze tables, gold models
and key tests, and extend the existing WebApi hospital gate.

Follow the spec's resolved silver/bronze cohort and full CSV fingerprint.
No adaptations beyond the resolved spec. Preserve the source numerical
code with Ruff formatting and reflowed docstrings.

Internal choices:
- Select the first ADOS-2 with a SQL window and assemble predictor columns
  by EDF in pandas. Normalize dates to days across SQLite and PostgreSQL
  and use the undated CSS path if evaluation date is absent.
- Treat unstaged analysis or score tables as empty inputs. Retain the
  existing as_of argument without a cutoff in the specified cohort.
- Keep missing and non-finite report and bronze values as null, including
  open confidence limits. Store counts as bigint and direction as boolean.
  Reuse the EEG bronze merge writer after deleting the prior projection.
- Use a NumPy default_rng seeded with 0, uniform ages, normal predictors,
  and independent draws of module, item codes, and CSS for source parity.
  Load the reference modules in a test-only namespace with stub contracts.
- Record model and WebApi changes in their existing submodule branches
  and update the corresponding gitlinks in the parent commit.

Checks: Ruff lint and format check passed. lint-imports kept both
contracts. The association unit suite passed all five tests. Eight
lightweight TEA job tests passed, with two integration tests deselected.
SQLite smoke checks passed for cohort, registration and deduplication, promotion,
prediction, bronze writes, and both dbt models and their four key tests.
Fixture replay matched the 15 published pairs and 470 published scores.
The full hospital API gate runs on the test machines.
2026-11-29 13:34:01 -06:00
Roberto Treviño 3a749ba8d1 A nightly Dagster job backs up the data folder 2026-11-29 12:38:56 -06:00
Roberto Treviño f369e8f2eb Survival rates its scenarios' risk factors as Luis's code does; recurrence shares the factor code 2026-11-29 12:38:56 -06:00
Roberto Treviño f3f79831bf Each domain's jobs name the models a score run takes 2026-11-29 07:03:08 -06:00
Roberto Treviño 43207fa3a5 Scoring runs every champion, slow models too 2026-11-29 06:43:08 -06:00
alberto 8c910e7500 Dask scheduler and workers for the test profile and CI; writes-overlap, cancel and remote-mode tests: remote-mode TEA analysis equals sync on synthetic EEGs 2026-11-29 04:47:23 -06:00
Roberto Treviño 7e8e8b44d8 Silver checks the site's recurrences and positive nodes 2026-11-29 01:50:23 -06:00
alberto 0b4f7593e5 TEA hospital test follows the sensor flow; re-analysis by id in local mode; first_n
Update tests/test_tea_job.py. Use the synthetic TEA builder with the existing pipeline and concept map, ingest via the platform fixture without a daemon, and run first_n synchronously in process.

Use SQLite and its temporary platform environment, count an absent analysis table as zero, and clear the cached engine around the in-process calls.
2026-11-29 01:25:29 -06:00
Roberto Treviño 5c781f2a52 The recurrence report names the site's own cohort 2026-11-29 01:20:40 -06:00
Roberto Treviño 8e9da2c73a The site cohort keeps redundant covariates for its scenarios 2026-11-29 00:41:24 -06:00
Roberto Treviño 53e6f77c9e Every model trains on the site: EEG age curves on the children with TEA ruled out, recurrence on the site's patients (St. Gallen subtype), and the EEG–ADOS-2 association 2026-11-28 21:28:36 -06:00
alberto c6c55e0ffe Merge P3.7 into P3.5 for one combined gate 2026-11-28 16:31:56 -06:00
alberto 3950b3c1f5 tea_preview job: one file previewed, result as run output: preview analyses one staged EDF (and an ADOS-2 PDF) against the champions, writes nothing 2026-11-28 13:37:27 -06:00
alberto b7eaf7055d Training config: reference name and mains frequency: train takes a named reference cohort and its mains frequency; legacy TEA_REFERENCE_DIR stays the default 2026-11-28 13:26:18 -06:00
alberto 9ed686e87a Merge tea/parity into P3.6 2026-11-28 10:31:00 -06:00
alberto dce0e0c690 EDF reader node in the ingestion DSL: run_edf keeps each row and adds the header facts or the file's error; read.header parses the fixed EDF header without edfio 2026-11-28 10:30:48 -06:00
Roberto Treviño 924f662a21 Survival scores name the report's clinical scenarios each patient falls in 2026-11-28 09:29:59 -06:00
alberto d954faa28e Generic model bundles: export and import: the import_bundle job 2026-11-28 09:24:36 -06:00
Roberto Treviño 1a46a5ba73 Link each distinct identity once, not every pair of a patient's records 2026-11-28 01:17:40 -06:00
Roberto Treviño 61eb3a30d0 Read works through files a batch at a time and keeps each batch 2026-11-27 22:29:23 -06:00
Roberto Treviño 0c78f8cf7d OCR only on the pages without text; otherwise routes; batches on Dask through its own API 2026-11-27 19:17:49 -06:00
alberto cc95054a96 The tea_eeg job: analyse, score the age curves, relate ADOS-2, rebuild gold; a sensor starts it after an ingest
Analysis and the reference cohort's measuring run on execution.map; relate is the
Phase 2 seam. A LocalCluster starts inside a multiprocess Dagster step (checked on a
real run), so the ops keep the default executor.
2026-11-27 18:02:28 -06:00
alberto 9220b8c52c execution.map runs a heavy op's items in this process, on local workers or on a Dask scheduler, and reports progress on the run 2026-11-27 17:19:55 -06:00
Roberto Treviño 385cc5b80b Read keeps the file and says its format; extract takes fields from columns; EEG batches carry their recording, on Dask where it is installed 2026-11-27 16:25:01 -06:00
Roberto Treviño 3546269eaf Review queues a scan read only in part, and an undated name one typo from a person 2026-11-27 14:02:08 -06:00
Roberto Treviño 7b9ae69de2 CaCu models record the outcomes each split holds 2026-11-27 11:05:28 -06:00
Roberto Treviño 4ff4a3a7d8 A person nothing names is held for review; a scan may misread one valid code as another 2026-11-27 08:46:05 -06:00
Roberto Treviño 999f0fb926 A model whose cohort is empty at a site is skipped, not a failed train run 2026-11-27 05:07:54 -06:00
Roberto Treviño 02aab07a67 Extract reads several columns as one document; reviewers' corrections of study fields applied at the target; the site gates on ISSSTELEON's test source 2026-11-27 01:45:16 -06:00
Roberto Treviño 44cb0dc894 CaMa survival with stage and first-course treatment, clinical scenario report, measured against the SEER-trained original 2026-11-26 19:03:38 -06:00
Roberto Treviño 76eb8cc8af Files read by hash; fractional Weibull solved and fitted to convergence; recurrence reads its reference cohorts from the platform 2026-11-26 14:25:53 -06:00
Roberto Treviño f305cdd044 TEA EEG analysis and age curves, TEA jobs; CaMa recurrence on METABRIC and SCAN-B; reference-data models and routine runs 2026-11-26 07:06:52 -06:00
Roberto Treviño e2f7e95e83 Shared interval survival for CaMa and CaCu, one jobs module for every domain, Dagster train and score by domain 2026-11-25 23:20:52 -06:00
Roberto Treviño d3d9cc3950 Link node keeps names as written; compares them normalised 2026-11-25 17:39:32 -06:00
Roberto Treviño 8c0ec5106c Long silver from targets, stable person ids, ConceptMap translation, the fhir node 2026-11-25 16:17:23 -06:00
Roberto Treviño b6857dab2a CaCu training and scoring jobs on gold, MLflow versions with their reports 2026-11-25 01:16:45 -06:00