Skip to content

move demographic/birth factors into inputs data pipeline - #293

Open
tomjemmett wants to merge 2 commits into
remove_tretspef_groupedfrom
move_pop_extract_to_inputs
Open

tomjemmett wants to merge 2 commits into
remove_tretspef_groupedfrom
move_pop_extract_to_inputs

Conversation

@tomjemmett

Copy link
Copy Markdown
Member
  • creates the population data as tables in the reference layer
  • extracts these tables in the inputs-data layer
  • removes these extracts from the model data layer

Stack created with GitHub Stacks CLI • Give Feedback 💬

* creates the population data as tables in the reference layer
* extracts these tables in the inputs-data layer
* removes these extracts from the model data layer
@tomjemmett
tomjemmett added this pull request to stack #294 October 13, 2026 12:53
@tomjemmett tomjemmett linked an issue Oct 19, 2026 that may be closed by this pull request
@tomjemmett tomjemmett added this to the v6.2.0 milestone Oct 19, 2026
@tomjemmett tomjemmett self-assigned this Oct 19, 2026
@tomjemmett
tomjemmett marked this pull request as ready for review October 19, 2026 10:27
@tomjemmett
tomjemmett requested a review from a team as a code owner October 19, 2026 10:27
Copilot AI balanced review requested due to automatic review settings October 19, 2026 10:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The mlcsu config uses the non-existent unhp catalog for the two new reference tables, which would break table resolution in that environment.

2 open issues
What changed in this PR

This PR relocates the demographic-factors and birth-factors population data out of the model_data layer and into the inputs-data pipeline, backed by new reference-layer tables. New reference tables (reference_population_provider_demographics / _births) are created once in the reference layer, extracted into the inputs-data layer, and the old per-run model_data extracts (and their shared helpers) are removed. It also bundles some stacked refactors: a parameterized get_spark(PartitionOverwriteMode), dropping the unused spark arg from a couple of aggregated-data generators, and renaming the IP efficiencies TPMA extract (plus fixing its type filter to "efficiency").

Changes:

  • Add reference/population_provider.py to build provider demographic/birth factor tables, and inputs_data/demographics.py to extract them; remove model_data/birth_factors.py, demographic_factors.py, the related helper functions, and synthetic-data generators.
  • Point generate_provider_gams at the new inputs path and inline _create_icb_population_projections; wire new table names and workflow tasks/entry points.
  • Parameterize get_spark with PartitionOverwriteMode (default DYNAMIC) and use STATIC in raw/aggregated extracts; rename ip_efficiency TPMAs to ip_efficiencies and fix the mitigator type filter.
File Description
src/​nhp/​data/​reference/​population_provider.py New reference-layer builder for provider demographic/birth factor tables; main() docstring is copied from an unrelated function
src/​nhp/​data/​inputs_data/​demographics.py New inputs-data extract for demographic/birth factors and provider catchments
src/​nhp/​data/​table_names/​table_names.py Adds the two new reference table-name fields
src/​nhp/​data/​table_names/​udal.py UDAL mappings for the new reference tables
src/​nhp/​data/​table_names/​mlcsu.py MLCSU mappings; catalog typo unhp instead of nhp
src/​nhp/​data/​get_spark.py Adds PartitionOverwriteMode enum and parameterizes the partition overwrite mode
src/​nhp/​data/​raw_data/​{aae,inpatients,outpatients,outpatients_mitigators}.py Switch main() to get_spark(PartitionOverwriteMode.STATIC)
src/​nhp/​data/​aggregated_data/​{outpatients,ecds}.py Use STATIC mode and drop unused spark arg from generators
src/​nhp/​data/​model_data/​ip_tpmas.py Rename to ip_efficiencies and fix TPMA type filter to "efficiency"
src/​nhp/​data/​model_data/​helpers.py Remove the now-relocated population-projection helpers
src/​nhp/​data/​model_data/​health_status_adjustment/​generate_provider_gams.py Read demographics from the inputs path; adjust the base-year filter
src/​nhp/​data/​model_data/​health_status_adjustment/​generate_icb_gams.py Inline the ICB population-projection helper
src/​nhp/​data/​model_data/​generate_synthetic_data.py Remove synthetic birth/demographic factor generation
src/​nhp/​data/​model_data/​{birth_factors,demographic_factors}.py Deleted (moved to reference/inputs layers)
pyproject.toml Add/remove the corresponding entry points
databricks_workflows/​*.yaml Wire new reference/inputs tasks and remove old model-data tasks

Review effort: Balanced

Comment thread src/nhp/data/table_names/mlcsu.py
Comment thread src/nhp/data/reference/population_provider.py
@tomjemmett
tomjemmett force-pushed the move_pop_extract_to_inputs branch from 41349ba to 52ecc2d Compare October 21, 2026 14:24

This branch has not been deployed

No deployments
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.

Move demographic data from model_data to inputs

2 participants