Commit Graph

66 Commits

Author SHA1 Message Date
alberto 37c456c5ef Hospital test analyses the EEGs before training the curves
The site source trains from the analysed EEGs of children without the diagnosis, so the analysis comes first; the later analysis scores the promoted curves.
2026-12-01 14:10:42 -06:00
alberto edd3093d5d F1e: the hospital test trains the curves and the association before the page cases 2026-12-01 14:05:40 -06:00
alberto 326502f90c F1h: Gobernanza without Vista previa and Subir archivos, button spacing
Remove both training-input endpoints and their endpoint-only test. Keep bundle import and clinical-validation uploads, which use their own API paths. External-folder training continues through cluster and TEA_REFERENCE_ROOT.
2026-12-01 13:49:28 -06:00
alberto 2c5568f5d1 Training source titles and test 2026-12-01 13:32:26 -06:00
alberto 82f7a18a9f F1a: user fixes
Keep the TrainingSource union named in OpenAPI and serialize the selected variant directly into the flat job config. Keep the inputs GET for file-type metadata and upload availability, and remove the listing and its description. Cover both job payloads, reject site-only extraneous fields, and verify upload validation.
2026-12-01 11:32:48 -06:00
alberto 6c1d098619 T3: training form and train request carry the training source (site or folder) 2026-12-01 00:53:28 -06:00
alberto 4063a9824b Tests that start a whole platform go (P7): backups; sources keep their in-process cases 2026-12-01 00:23:32 -06:00
alberto f26d32a010 Merge origin/rebuild into parity/T1-merge (WebApi)
- main.py: both routers sets (execution, preview from tea/parity; sources, users from
  rebuild).
- runs.py: tea/parity's cancel, history and execution config; rebuild's /terminate is the
  same action and is not kept twice.
- eeg.py: tea/parity's (the record reads per-child FHIR resources, not rebuild's EEG
  detail with zones and relation).
- fhir.py: tea/parity's patient rows with TEA filters, plus rebuild's name/identifier
  search applied to whatever rows the request selects.
- models.py: tea/parity's endpoints; /models/{domain} returns rebuild's name + title.
- tests: P7 deletions kept (test_cacu, test_cama, test_conectar, test_synthea*, test_tea);
  test_webapp keeps tea/parity's runner, now with the first administrator (sign-in).
2026-11-30 23:56:11 -06:00
alberto b61843b639 TEA page runner over the synthetic TEA hospital
test_webapp (marker webapp, deselected by default) builds the synthetic TEA
hospital, starts the Dagster webserver, daemon and the API on a fresh SQLite
platform in sync mode, saves the hospital_tea ConceptMap and pipeline
through the API, runs the ingest and the sensor's tea_eeg run, then runs
Playwright against it. The study EDF, its ADOS-2 report and birth date
are handed to the page tests for the Gobernanza preview. An empty
TEA_REFERENCE_ROOT is set because the training inputs endpoint answers
503 without one.
2026-11-30 19:17:46 -06:00
alberto 80049112aa The suite keeps only logic tests
Check API validation and response shaping through direct calls.

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

removed WebApi/tests/test_bundles.py::test_export_and_import_through_the_api — slow integration (logic now covered by test_layout_and_manifest_hold_every_file_hash and test_roundtrip_registers_candidates_with_lineage)
removed WebApi/tests/test_bundles.py::test_import_refuses_a_wrong_sha_and_a_non_zip — slow integration (logic now covered by test_import_rejects_invalid_uploads)
removed WebApi/tests/test_bundles.py::test_importing_the_same_bundle_again_fails_the_run — slow integration (logic now covered by test_importing_twice_is_a_conflict_and_partial_imports_skip)
removed WebApi/tests/test_bundles.py::test_export_guard_failure_is_422 — slow integration (logic now covered by test_reference_group_size and test_selection_champion_latest_all)
removed WebApi/tests/test_bundles.py::test_an_untrusted_bundle_is_refused — slow integration (logic now covered by test_import_rejects_invalid_uploads and test_import_refuses_an_untrusted_digest)
removed WebApi/tests/test_cacu.py — parity-only
removed WebApi/tests/test_cacu.py::test_cacu_from_the_hospital_to_indicators_and_risks — parity-only
removed WebApi/tests/test_cama.py — parity-only
removed WebApi/tests/test_cama.py::test_cama_from_the_hospital_to_indicators — parity-only
removed WebApi/tests/test_conectar.py — slow integration (logic now covered by test_person_ids_survive_a_review_merge_and_split and test_a_concept_map_onto_a_code_no_field_allows_is_refused)
removed WebApi/tests/test_conectar.py::test_an_operator_connects_a_site_and_settles_its_review — slow integration (logic now covered by test_person_ids_survive_a_review_merge_and_split and test_a_concept_map_onto_a_code_no_field_allows_is_refused)
removed WebApi/tests/test_fhir_door.py — slow integration (logic now covered by test_fhir_in_joins_encounter_results_and_subject_by_full_url and tests/test_core_tea_fhir.py for FHIR mappings)
removed WebApi/tests/test_fhir_door.py::test_what_one_platform_serves_another_places_through_the_fhir_door — slow integration (logic now covered by test_fhir_in_joins_encounter_results_and_subject_by_full_url and tests/test_core_tea_fhir.py for FHIR mappings)
removed WebApi/tests/test_fhir_door.py::test_a_new_label_is_a_concept_map_row_not_code — slow integration (logic now covered by test_hospital_codes_and_dates_become_platform_values)
removed WebApi/tests/test_governance.py::test_version_lifecycle — slow integration (logic now covered by models/tests/test_bundle.py::test_version_lifecycle)
removed WebApi/tests/test_governance.py::test_imported_lineage — slow integration (logic now covered by test_roundtrip_registers_candidates_with_lineage)
removed WebApi/tests/test_governance.py::test_preview — slow integration (logic now covered by test_the_job_deletes_its_files_and_returns_the_result_as_output and test_shape_outputs)
removed WebApi/tests/test_governance.py::test_training_inputs — slow integration (logic now covered by the direct-call test_training_inputs)
removed WebApi/tests/test_runs.py::test_unknown_run_is_404 — implementation-detail
removed WebApi/tests/test_runs.py::test_failed_run_reports_its_error — slow integration (logic now covered by test_shape_failure_message_is_the_ops_own_exception)
removed WebApi/tests/test_runs.py::test_history_filters_by_job_and_domain — implementation-detail
removed WebApi/tests/test_runs.py::test_run_requests_validate_the_execution_choice — slow integration (logic now covered by test_resolve_rejects_unlisted_scheduler_and_scheduler_in_local_mode)
removed WebApi/tests/test_runs.py::test_execution_options_and_health — implementation-detail
removed WebApi/tests/test_runs.py::test_tea_eegs_analyze_validates_scope — slow integration (logic now covered by test_scope_validation)
removed WebApi/tests/test_runs.py::test_a_locked_run_storage_is_read_again — implementation-detail
removed WebApi/tests/test_runs.py::test_cancel_waits_for_a_starting_run — implementation-detail
removed WebApi/tests/test_runs.py::test_cancel_a_finished_run_is_409 — slow integration (logic now covered by test_cancel_a_finished_run_is_409 with a client double)
removed WebApi/tests/test_runs_concurrency.py — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for the queued transition)
removed WebApi/tests/test_runs_concurrency.py::test_writing_runs_never_overlap — implementation-detail
removed WebApi/tests/test_runs_concurrency.py::test_cancelling_an_ingest_run_leaves_no_silver_or_gold — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for the API state transition)
removed WebApi/tests/test_runs_concurrency.py::test_cancelling_a_queued_run_never_starts_it — slow integration (logic now covered by test_cancel_returns_the_terminal_or_cancelling_state for the queued transition)
removed WebApi/tests/test_runs_concurrency.py::test_a_dead_run_does_not_stay_running — implementation-detail
removed WebApi/tests/test_synthea.py — slow integration (logic now covered by test_fhir_in_joins_encounter_results_and_subject_by_full_url and test_hospital_codes_and_dates_become_platform_values)
removed WebApi/tests/test_synthea.py::test_a_synthea_population_comes_in_through_the_fhir_door — slow integration (logic now covered by test_fhir_in_joins_encounter_results_and_subject_by_full_url and test_hospital_codes_and_dates_become_platform_values)
removed WebApi/tests/test_synthea_cama.py — slow integration (logic now covered by test_fhir_in_joins_encounter_results_and_subject_by_full_url for FHIR ingestion mapping)
removed WebApi/tests/test_synthea_cama.py::test_a_synthea_cama_population_comes_in_through_the_fhir_door — slow integration (logic now covered by test_fhir_in_joins_encounter_results_and_subject_by_full_url for FHIR ingestion mapping)
removed WebApi/tests/test_tea.py — parity-only
removed WebApi/tests/test_tea.py::test_tea_from_the_hospital_to_indicators — parity-only
removed WebApi/tests/test_training_config.py::test_tea_training_config_schema — slow integration (logic now covered by the direct-call test_tea_training_config_schema)
removed WebApi/tests/test_training_config.py::test_other_domains_have_no_reference — slow integration (logic now covered by the direct-call test_other_domains_have_no_reference)
removed WebApi/tests/test_training_config.py::test_train_validates_the_reference — slow integration (logic now covered by the direct-call test_train_validates_the_reference and test_bad_references_fail_with_a_reason)
removed WebApi/tests/test_webapp.py — slow integration (logic now covered by existing WebApp unit tests for figure, row and export builders; loaded-page browser coverage is deferred to P5.5)
removed WebApi/tests/test_webapp.py::test_every_page_loads_from_the_api — slow integration (logic now covered by existing WebApp unit tests for figure, row and export builders; loaded-page browser coverage is deferred to P5.5)
2026-11-30 16:48:32 -06:00
alberto ec5d945f71 Cleanup of the TEA parity work: no prose in code, no hacks, everything in its place
1. No prose in code
- Remove parity-added Python comments and docstrings across the EEG, FHIR,
  execution, preview, training and run code and tests. Preserve endpoint
  descriptions as explicit FastAPI schema metadata.

2. No hacks, no glued code
- Read the declared TEA patient filters and training inputs directly and
  use the same TEA check for exposing and validating reference options.
- Give the Dagster GraphQL request one helper. Keep lock backoff and
  cancellation polling because their timing and error behavior are
  covered by run tests and they handle different Dagster states.
- Use the renamed FHIR report ID helper in the hospital test. Keep
  TEA_GATE_SLOW local to that test and preserve the test assertions.

3. Everything in its place
- Keep endpoint and run handling in WebApi and reuse Core and Persistance
  for domain rules and reads. Leave tests in the existing testpaths.
2026-11-30 13:41:49 -06:00
alberto 54b1995681 TEA gate: stored scores keyed by the served EEG report id (person and study date) 2026-11-30 10:42:56 -06:00
alberto 52bcf34720 TEA gate: the extension helper reads complex extensions (curve-centiles) too 2026-11-30 09:10:39 -06:00
Roberto Treviño d92d1697b8 The review test answers what parting a torn person raises; Synthea's day is fixed 2026-11-30 02:14:14 -06:00
alberto 983680ead3 TEA per-child FHIR resources: ADOS-2, EEG report, checks, metrics, Condition, RiskAssessment: routes and the per-child gate 2026-11-30 01:14:13 -06:00
alberto 3300ec3048 TEA gate: TEA_GATE_SLOW stretches its waits on a busy shared server (default 1) 2026-11-29 23:10:46 -06:00
Roberto Treviño 8a2ce3bbb4 Training defaults to every model of the domain 2026-11-29 21:12:31 -06:00
alberto 08f240cde9 Merge P4.3 into P4.1 for one combined gate 2026-11-29 19:46:01 -06:00
alberto 80b3d23b75 Add governance and TEA preview REST endpoints
Use the models router for curves and training inputs, the EEG router for summary, and a separate preview router. Keep the preview result typed with the existing persistence model and declare multipart binary schemas for generated Blob parameters.
2026-11-29 19:45:50 -06:00
alberto b401f98f19 TEA follow-up: Patient search with TEA filters and $eeg-summary
Use _patient_rows and shared Query declarations for follow-up selection. Validate filters with an empty row before reading candidates, and use doseq for repeated values in paging links. Keep operation routes out of the metadata scan for read and search interactions. Use _follow_up_gate to compare the 29 captured queries by normalized record number, scalar counts and metrics.
2026-11-29 19:42:17 -06:00
alberto 9e5aa20092 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 88b22b9491 Backups restore whole on both databases; a damaged one restores nothing 2026-11-29 12:39:00 -06:00
Roberto Treviño c9b60b190b Models are listed with their titles 2026-11-29 12:39:00 -06:00
alberto f830003abd Run tests: execution options follow the configured schedulers; the queued-cancel test cancels whichever run Dagster left queued and checks none of its steps ran 2026-11-29 07:43:49 -06:00
alberto c7caf56f83 Cancel waits up to 30 s for a run that is still starting (Dagster cannot terminate it then); still starting is a 409 with Retry-After 2026-11-29 06:06:50 -06:00
alberto 0a4deea370 Dask scheduler and workers for the test profile and CI; writes-overlap, cancel and remote-mode tests: run concurrency and cancel tests; TEA gate cancels a re-analysis and checks nothing changed 2026-11-29 04:47:23 -06:00
alberto 25955b80e8 TEA gate: re-analysis comparison keeps empty values empty 2026-11-29 03:38:20 -06:00
Roberto Treviño 8b0b121aaa The site's recurrences go through Conectar's review 2026-11-29 01:50:22 -06:00
Roberto Treviño ae4638e4dd API workers share startup and OAuth sign-ins through the data folder 2026-11-29 01:32:08 -06:00
alberto 51bcdbdfe3 TEA hospital test follows the sensor flow; re-analysis by id in local mode; first_n
Update tests/test_tea.py. Wait for sensor analysis immediately after ingest. Keep training and promotion before scoring and submit the pending scope to apply curves.

Use monotonic polling deadlines, check failures before success, and allow 900 seconds for the expected-failure run to reach a terminal state. Pick the first valid API study, resolve its EDF through silver, compare verdict and level exactly, and compare numeric fields and code-keyed metrics with pytest.approx.
2026-11-29 01:25:29 -06:00
Roberto Treviño 4212c4d0b5 The CaMa door test counts the recurrences on a timeline 2026-11-29 01:06:41 -06:00
Roberto Treviño d59c20432e Sort the TEA gate's imports 2026-11-28 21:28:54 -06:00
Roberto Treviño d8d834f308 EEG study serves its ADOS-2 association rows; TEA gate as roundtrips 2026-11-28 21:28:38 -06:00
alberto 2131ff60a5 Merge P3.7 into P3.5 for one combined gate 2026-11-28 16:31:56 -06:00
alberto a4c3d6c1b0 Merge tea/parity into P3.5 2026-11-28 16:31:56 -06:00
alberto e3e774fca4 Merge tea/parity into P3.7 2026-11-28 16:31:55 -06:00
alberto 09691afc76 TEA gate: the 62-EEG analysis may take up to an hour on a 2-CPU test container 2026-11-28 16:31:45 -06:00
alberto 70c9506b97 tea_preview job: one file previewed, result as run output: GET /runs/{id}?outputs=true; the TEA gate also previews one hospital EDF 2026-11-28 13:37:27 -06:00
Roberto Treviño 7222cbdb49 EEG metrics carry their age band; reference comparisons skip crossed strata; the no-session test reads no platform data 2026-11-28 13:29:22 -06:00
alberto 7e25dde319 Training config: reference name and mains frequency: GET /models/{domain}/{name}/training-config; POST train accepts reference 2026-11-28 13:26:18 -06:00
Roberto Treviño 052fb23fab In-process fixture moves to the root conftest (a tests conftest shadowed it) 2026-11-28 10:26:24 -06:00
Roberto Treviño b515746406 Source types, connection test, server folders, uploads and OAuth sign-in for the Conectar dialog; sign-in for the web app with fastapi-users, the API left open 2026-11-28 09:29:59 -06:00
alberto 3438a3135b Merge P3.4: model bundle endpoints 2026-11-28 09:24:48 -06:00
alberto 88bbc6155f Generic model bundles: export and import: export and import endpoints 2026-11-28 09:24:38 -06:00
alberto e434e085fe Runs API reads Dagster again when its SQLite run storage is locked; still locked is a 503 with Retry-After
The Postgres TEA gate got a 502 polling an ingest: logsForRun failed with
'database is locked' while the run wrote its events.
2026-11-28 08:43:00 -06:00
alberto e4967347f5 Merge P1 gate: TEA end-to-end parity test against the sitio-b hospital 2026-11-28 08:14:28 -06:00
alberto 4793cf01f0 Runs API: a run's state, steps, live progress, info and warnings apart, the failure's own message; cancel; history by job and domain; execution options and health; POST /tea/eegs/analyze
test_runs.py: 17 passed on SQLite and Postgres
(compose test stack). test_conectar.py fails on an identity-merge count, as it does on tea/parity
without this change.
2026-11-28 06:54:00 -06:00
alberto 8fa2be8aab TEA gate compares the indicators after the curves score: M30 counts the alterations they find 2026-11-28 06:38:32 -06:00
alberto de4485094f TEA gate compares M24 by age and sex and M31 by sex; the platform-only M30 group per alteration is left out of the comparison 2026-11-28 05:56:42 -06:00
alberto 074fdb5305 TEA gate: ADOS-2 rows match by the platform's record number again (N-0010 is kept as N0010) 2026-11-28 04:50:07 -06:00