-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpipeline_api.json
More file actions
4532 lines (4532 loc) · 209 KB
/
pipeline_api.json
File metadata and controls
4532 lines (4532 loc) · 209 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
"aca_2025_override": {
"docstring": "Set 2025 ACA take-up to match APTC enrollment targets.",
"id": "aca_2025_override",
"kind": "function",
"line": 404,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.enhanced_cps.create_aca_2025_takeup_override"
],
"artifacts_in": [
"extended_cps_2024"
],
"artifacts_out": [
"aca_2025_takeup"
],
"description": "Adds synthetic 2025 ACA take-up assignments until calibrated person-level APTC enrollment reaches the target.",
"id": "aca_2025_override",
"label": "ACA 2025 Take-Up Override",
"node_type": "process",
"pathways": [
"data_build"
],
"pydoc": true,
"source_file": "policyengine_us_data/datasets/cps/enhanced_cps.py",
"stability": "moving",
"status": "transitional"
},
"object_path": "policyengine_us_data.datasets.cps.enhanced_cps.create_aca_2025_takeup_override",
"signature": "def create_aca_2025_takeup_override(base_takeup: np.ndarray, person_enrolled_if_takeup: np.ndarray, person_weights: np.ndarray, person_tax_unit_ids: np.ndarray, tax_unit_ids: np.ndarray, target_people: float = ACA_POST_CALIBRATION_PERSON_TARGETS[2025], person_state_codes: np.ndarray | None = None, target_people_by_state: dict[str, float] | None = None, tax_unit_aca_ptc: np.ndarray | None = None, tax_unit_weights: np.ndarray | None = None, target_spending_by_state: dict[str, float] | None = None) -> np.ndarray",
"source_file": "policyengine_us_data/datasets/cps/enhanced_cps.py"
},
"acs_qrf": {
"docstring": "Impute rent and real_estate_taxes from ACS with state.\n\nArgs:\n data: CPS data dict.\n state_fips: State FIPS per household.\n time_period: Tax year.\n dataset_path: Path to CPS h5 for Microsimulation.\n\nReturns:\n Updated data dict.",
"id": "acs_qrf",
"kind": "function",
"line": 508,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.source_impute._impute_acs"
],
"description": "Impute rent and real estate tax variables from ACS donor data.",
"id": "acs_qrf",
"label": "ACS QRF Imputation",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/calibration/source_impute.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/calibration/test_source_impute.py"
]
},
"object_path": "policyengine_us_data.calibration.source_impute._impute_acs",
"signature": "def _impute_acs(data: Dict[str, Dict[int, np.ndarray]], state_fips: np.ndarray, time_period: int, dataset_path: Optional[str] = None) -> Dict[str, Dict[int, np.ndarray]]",
"source_file": "policyengine_us_data/calibration/source_impute.py"
},
"add_auto_loan": {
"docstring": "\"Add auto loan balance, interest and net_worth variable.",
"id": "add_auto_loan",
"kind": "function",
"line": 2938,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_auto_loan_interest_and_net_worth"
],
"description": "Impute auto loan balance, auto loan interest, and net worth from SCF donor data.",
"id": "add_auto_loan",
"label": "Auto Loan And Net Worth Imputation",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "legacy",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_auto_loan_interest_and_net_worth",
"signature": "def add_auto_loan_interest_and_net_worth(self, cps: h5py.File) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_household_variables": {
"docstring": "Populate household-level geography variables used by PolicyEngine US.\n\nArgs:\n cps: Output CPS H5 group receiving derived household variables.\n household: Raw CPS household table.",
"id": "add_household_variables",
"kind": "function",
"line": 1519,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_household_variables"
],
"description": "Populate household geography variables including state, county, and NYC flag.",
"id": "add_household_variables",
"label": "Add Household Variables",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "stable",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_household_variables",
"signature": "def add_household_variables(cps: h5py.File, household: DataFrame) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_id_variables": {
"docstring": "Add basic ID and weight variables.\n\nArgs:\n cps (h5py.File): The CPS dataset file.\n person (DataFrame): The person table of the ASEC.\n tax_unit (DataFrame): The tax unit table created from the person table\n of the ASEC.\n family (DataFrame): The family table of the ASEC.\n spm_unit (DataFrame): The SPM unit table created from the person table\n of the ASEC.\n household (DataFrame): The household table of the ASEC.",
"id": "add_id_variables",
"kind": "function",
"line": 988,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_id_variables"
],
"description": "Create person, household, tax-unit, SPM-unit, family, and marital-unit IDs.",
"id": "add_id_variables",
"label": "Add ID Variables",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "stable",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/datasets/test_cps_identification.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_id_variables",
"signature": "def add_id_variables(cps: h5py.File, person: DataFrame, tax_unit: DataFrame, family: DataFrame, spm_unit: DataFrame, household: DataFrame) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_org_inputs": {
"docstring": "Impute ORG-derived wage and union inputs onto CPS persons.",
"id": "add_org_inputs",
"kind": "function",
"line": 2822,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_org_labor_market_inputs"
],
"description": "Impute hourly wage, hourly-pay status, and union coverage from CPS ORG donors.",
"id": "add_org_inputs",
"label": "ORG Labor-Market Inputs",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/datasets/test_org.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_org_labor_market_inputs",
"signature": "def add_org_labor_market_inputs(cps: h5py.File) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_personal_income_variables": {
"docstring": "Add income variables.\n\nArgs:\n cps (h5py.File): The CPS dataset file.\n person (DataFrame): The CPS person table.\n year (int): The CPS year",
"id": "add_personal_income_variables",
"kind": "function",
"line": 1194,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_personal_income_variables"
],
"description": "Populate CPS income, transfer, retirement, and QBI-related personal inputs.",
"id": "add_personal_income_variables",
"label": "Add Income Variables",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_personal_income_variables",
"signature": "def add_personal_income_variables(cps: h5py.File, person: DataFrame, year: int)",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_personal_variables": {
"docstring": "Add personal demographic variables.\n\nArgs:\n cps (h5py.File): The CPS dataset file.\n person (DataFrame): The CPS person table.",
"id": "add_personal_variables",
"kind": "function",
"line": 1050,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_personal_variables"
],
"description": "Populate CPS personal demographics and occupation-derived inputs.",
"id": "add_personal_variables",
"label": "Add Personal Variables",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_personal_variables",
"signature": "def add_personal_variables(cps: h5py.File, person: DataFrame) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_previous_year_income": {
"docstring": "",
"id": "add_previous_year_income",
"kind": "function",
"line": 1561,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_previous_year_income"
],
"description": "Link CPS records across adjacent years and populate prior-year income inputs.",
"id": "add_previous_year_income",
"label": "Previous-Year Income",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_previous_year_income",
"signature": "def add_previous_year_income(self, cps: h5py.File) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_rent": {
"docstring": "",
"id": "add_rent",
"kind": "function",
"line": 362,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_rent"
],
"description": "Impute rent and real estate taxes using ACS donor data.",
"id": "add_rent",
"label": "Rent Imputation",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "legacy",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_rent",
"signature": "def add_rent(self, cps: h5py.File, person: DataFrame, household: DataFrame)",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_spm_variables": {
"docstring": "",
"id": "add_spm_variables",
"kind": "function",
"line": 1480,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_spm_variables"
],
"description": "Populate CPS supplemental poverty measure variables.",
"id": "add_spm_variables",
"label": "Add SPM Variables",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_spm_variables",
"signature": "def add_spm_variables(self, cps: h5py.File, spm_unit: DataFrame) -> None",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_ssn_card_type": {
"docstring": "Assign SSN card type using PRCITSHP, employment status, and ASEC-UA conditions.\nCodes:\n- 0: \"NONE\" - Likely undocumented immigrants\n- 1: \"CITIZEN\" - US citizens (born or naturalized)\n- 2: \"NON_CITIZEN_VALID_EAD\" - Non-citizens with work/study authorization\n- 3: \"OTHER_NON_CITIZEN\" - Non-citizens with indicators of legal status",
"id": "add_ssn_card_type",
"kind": "function",
"line": 1667,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_ssn_card_type"
],
"description": "Classify SSN card type and immigration-related CPS inputs from ASEC conditions.",
"id": "add_ssn_card_type",
"label": "Add SSN Card Type",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_ssn_card_type",
"signature": "def add_ssn_card_type(cps: h5py.File, person: pd.DataFrame, spm_unit: pd.DataFrame, time_period: int, undocumented_target: float = 13000000.0, undocumented_workers_target: float = 8300000.0, undocumented_students_target: float = 0.21 * 1900000.0) -> np.ndarray",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_takeup": {
"docstring": "",
"id": "add_takeup",
"kind": "function",
"line": 510,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_takeup"
],
"description": "Apply stochastic takeup and reported-anchor alignment for benefit programs.",
"id": "add_takeup",
"label": "Benefit Takeup",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_takeup",
"signature": "def add_takeup(self)",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"add_tips": {
"docstring": "",
"id": "add_tips",
"kind": "function",
"line": 2566,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.cps.add_tips"
],
"description": "Impute tip income and household asset inputs from SIPP donor data.",
"id": "add_tips",
"label": "Tips And Asset Imputation",
"node_type": "library",
"pathways": [
"data_build"
],
"source_file": "policyengine_us_data/datasets/cps/cps.py",
"stability": "moving",
"status": "legacy",
"validation_commands": [
"uv run pytest validation/stage_1/test_cps.py"
]
},
"object_path": "policyengine_us_data.datasets.cps.cps.add_tips",
"signature": "def add_tips(self, cps: h5py.File)",
"source_file": "policyengine_us_data/datasets/cps/cps.py"
},
"atomic_promote": {
"docstring": "",
"id": "atomic_promote",
"kind": "function",
"line": 141,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.promote_local_h5s.promote"
],
"artifacts_out": [
"production H5 release",
"release manifest"
],
"description": "Promote staged H5 files to production storage and publish release manifests.",
"id": "atomic_promote",
"label": "Atomic Promote Local H5 Files",
"node_type": "entrypoint",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/calibration/promote_local_h5s.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/test_promote_local_h5s.py"
]
},
"object_path": "policyengine_us_data.calibration.promote_local_h5s.promote",
"signature": "def promote(files: list, rel_paths: list, version: str, run_id: str = '')",
"source_file": "policyengine_us_data/calibration/promote_local_h5s.py"
},
"build_areas_worker": {
"docstring": "Worker function that builds a subset of H5 files.\nUses subprocess to avoid import conflicts with Modal's environment.",
"id": "build_areas_worker",
"kind": "function",
"line": 912,
"metadata": {
"api_refs": [
"modal_app.local_area.build_areas_worker"
],
"artifacts_out": [
"one or more H5 files"
],
"description": "Modal worker entrypoint for state, district, city, or typed local H5 requests.",
"id": "build_areas_worker",
"label": "Build Areas Worker",
"node_type": "entrypoint",
"pathways": [
"local_h5"
],
"source_file": "modal_app/local_area.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/test_modal_local_area.py",
"uv run pytest tests/integration/build_outputs/h5_worker_runtime/test_worker_script_tiny_fixture.py"
]
},
"object_path": "modal_app.local_area.build_areas_worker",
"signature": "def build_areas_worker(branch: str, run_id: str, scope: str, work_items: List[Dict] | None = None, calibration_inputs: WorkerCalibrationInputs | Mapping[str, object] | None = None, validate: bool = True, scope_fingerprint: str | None = None, request_payloads: List[Dict] | None = None) -> Dict",
"source_file": "modal_app/local_area.py"
},
"build_cities": {
"docstring": "Build city H5 files with checkpointing, optionally uploading.",
"id": "build_cities",
"kind": "function",
"line": 627,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.publish_local_area.build_cities"
],
"artifacts_out": [
"cities/*.h5"
],
"description": "Build supported city H5 files with county probability filtering.",
"id": "build_cities",
"label": "Build City H5 Files",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/calibration/publish_local_area.py",
"stability": "moving",
"status": "current"
},
"object_path": "policyengine_us_data.calibration.publish_local_area.build_cities",
"signature": "def build_cities(weights_path: Path, dataset_path: Path, geography, output_dir: Path, completed_cities: set, hf_batch_size: int = 10, takeup_filter: List[str] = None, upload: bool = False)",
"source_file": "policyengine_us_data/calibration/publish_local_area.py"
},
"build_datasets": {
"docstring": "Build all datasets with preemption-resilient checkpointing.\n\nArgs:\n upload: Whether to upload completed datasets.\n branch: Git branch to build from.\n sequential: Use sequential (non-parallel) execution.\n clear_checkpoints: Clear existing checkpoints before starting.\n skip_tests: Skip running the test suite (useful for calibration runs).\n skip_enhanced_cps: Skip enhanced_cps.py and small_enhanced_cps.py\n (useful for calibration runs that only need source_imputed H5).\n skip_stage_5: Skip source-imputed CPS and small enhanced CPS after\n enhanced_cps_2024.h5 is built.\n stage_only: Upload to HF staging only, without promoting a release.\n version: policyengine-us-data package version used for staging and\n dataset-build contracts.",
"id": "build_datasets",
"kind": "function",
"line": 642,
"metadata": {
"api_refs": [
"modal_app.data_build.build_datasets"
],
"artifacts_out": [
"dataset_build_output.json",
"dataset_inventory.json",
"source_dataset_schema_summary.json",
"target_database_schema_summary.json",
"source_imputed_stratified_extended_cps_2024.h5",
"source_imputed_stratified_extended_cps.h5",
"policy_data.db"
],
"description": "Build base datasets, source-imputed artifacts, and optional uploads inside the Modal runtime.",
"id": "build_datasets",
"label": "Build Datasets On Modal",
"node_type": "entrypoint",
"pathways": [
"data_build",
"orchestration"
],
"source_file": "modal_app/data_build.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/test_modal_data_build.py"
]
},
"object_path": "modal_app.data_build.build_datasets",
"signature": "def build_datasets(upload: bool = False, branch: str = 'main', sequential: bool = False, clear_checkpoints: bool = False, skip_tests: bool = False, skip_enhanced_cps: bool = False, skip_stage_5: bool = False, stage_only: bool = False, run_id: str = '', version: str = DATA_PACKAGE_VERSION)",
"source_file": "modal_app/data_build.py"
},
"build_districts": {
"docstring": "Build district H5 files with checkpointing, optionally uploading.",
"id": "build_districts",
"kind": "function",
"line": 540,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.publish_local_area.build_districts"
],
"artifacts_out": [
"districts/*.h5"
],
"description": "Build congressional-district H5 files from calibrated weights and exact geography.",
"id": "build_districts",
"label": "Build District H5 Files",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/calibration/publish_local_area.py",
"stability": "moving",
"status": "current"
},
"object_path": "policyengine_us_data.calibration.publish_local_area.build_districts",
"signature": "def build_districts(weights_path: Path, dataset_path: Path, geography, output_dir: Path, completed_districts: set, hf_batch_size: int = 10, takeup_filter: List[str] = None, upload: bool = False)",
"source_file": "policyengine_us_data/calibration/publish_local_area.py"
},
"build_h5": {
"docstring": "Build an H5 file by cloning records for each nonzero weight.\n\nArgs:\n weights: Clone-level weight vector, shape (n_clones_total * n_hh,).\n geography: GeographyAssignment from assign_random_geography.\n dataset_path: Path to base dataset H5 file.\n output_path: Where to write the output H5 file.\n cd_subset: If provided, only include clones for these CDs.\n county_fips_filter: If provided, zero out weights for clones\n whose county FIPS is not in this set.\n takeup_filter: List of takeup vars to apply.\n\nReturns:\n Path to the output H5 file.",
"id": "build_h5",
"kind": "function",
"line": 328,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.publish_local_area.build_h5"
],
"artifacts_in": [
"calibration_weights.npy",
"source_imputed_stratified_extended_cps*.h5"
],
"artifacts_out": [
"states/*.h5",
"districts/*.h5",
"cities/*.h5",
"US.h5"
],
"description": "Expand calibrated clone weights into local-area H5 datasets with geography and takeup updates.",
"details": "This is the main bundled H5 construction routine and remains a critical transitional waypoint.",
"id": "build_h5",
"label": "Build Local Area H5",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/calibration/publish_local_area.py",
"stability": "moving",
"status": "transitional",
"validation_commands": [
"uv run pytest tests/unit/calibration/test_publish_local_area.py",
"uv run pytest tests/integration/test_tiny_h5_pipeline.py"
]
},
"object_path": "policyengine_us_data.calibration.publish_local_area.build_h5",
"signature": "def build_h5(weights: np.ndarray, geography, dataset_path: Path, output_path: Path, cd_subset: List[str] = None, county_fips_filter: set = None, takeup_filter: List[str] = None) -> Path",
"source_file": "policyengine_us_data/calibration/publish_local_area.py"
},
"build_matrix": {
"docstring": "Build sparse calibration matrix.\n\nTwo-phase build: (1) simulate each clone and save\nCOO entries to disk, (2) assemble CSR from caches.\n\nArgs:\n geography: GeographyAssignment with state_fips,\n cd_geoid, block_geoid arrays and n_records,\n n_clones attributes.\n sim: Microsimulation for parameters and entity\n relationships.\n target_filter: Dict for target_overview filtering.\n hierarchical_domains: Domain names for\n hierarchical uprating + CD reconciliation.\n cache_dir: Directory for per-clone COO caches.\n If None, COO data held in memory.\n sim_modifier: Optional callback(sim, clone_idx)\n called per clone after state_fips is set but\n before cache clearing. Use for takeup\n re-randomization.\n rerandomize_takeup: If True, use geo-salted\n entity-level takeup draws instead of base h5\n takeup values for takeup-affected targets.\n county_level: If True (default), iterate counties\n within each state during precomputation. If\n False, compute once per state and alias to all\n counties (faster for county-invariant vars).\n\nReturns:\n (targets_df, X_sparse, target_names)",
"id": "build_matrix",
"kind": "function",
"line": 2567,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.unified_matrix_builder.UnifiedMatrixBuilder.build_matrix"
],
"artifacts_out": [
"X_sparse",
"targets_df",
"target_names"
],
"description": "Build the in-memory sparse matrix for calibration targets and clone households.",
"id": "build_matrix",
"label": "Build Calibration Matrix",
"node_type": "library",
"pathways": [
"calibration_package"
],
"source_file": "policyengine_us_data/calibration/unified_matrix_builder.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/calibration/test_unified_matrix_builder.py"
]
},
"object_path": "policyengine_us_data.calibration.unified_matrix_builder.UnifiedMatrixBuilder.build_matrix",
"signature": "def build_matrix(self, geography, sim, target_filter: Optional[dict] = None, hierarchical_domains: Optional[List[str]] = None, cache_dir: Optional[str] = None, sim_modifier = None, rerandomize_takeup: bool = True, county_level: bool = True, workers: int = 1) -> Tuple[pd.DataFrame, sparse.csr_matrix, List[str]]",
"source_file": "policyengine_us_data/calibration/unified_matrix_builder.py"
},
"build_matrix_chunked": {
"docstring": "Build a sparse matrix by materializing mixed-geography chunks.\n\nThin facade: target querying, uprating, constraint extraction,\nand manifest handling live here; chunking, per-chunk execution,\nand streaming final assembly live in\n:class:`ChunkedMatrixAssembler`.",
"id": "build_matrix_chunked",
"kind": "function",
"line": 3332,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.unified_matrix_builder.UnifiedMatrixBuilder.build_matrix_chunked"
],
"artifacts_out": [
"chunked COO shards",
"X_sparse"
],
"description": "Stream matrix construction through clone-household chunks with resumable shard caches.",
"id": "build_matrix_chunked",
"label": "Build Calibration Matrix In Chunks",
"node_type": "library",
"pathways": [
"calibration_package"
],
"source_file": "policyengine_us_data/calibration/unified_matrix_builder.py",
"stability": "experimental",
"status": "current",
"validation_commands": [
"uv run pytest tests/integration/test_chunked_matrix_builder.py"
]
},
"object_path": "policyengine_us_data.calibration.unified_matrix_builder.UnifiedMatrixBuilder.build_matrix_chunked",
"signature": "def build_matrix_chunked(self, geography, sim, target_filter: Optional[dict] = None, hierarchical_domains: Optional[List[str]] = None, chunk_size: int = 25000, chunk_dir: Optional[str] = None, keep_chunks: bool = False, resume_chunks: bool = False, rerandomize_takeup: bool = True, parallel: bool = False, num_matrix_workers: int = 50, run_id: str = '') -> Tuple[pd.DataFrame, sparse.csr_matrix, List[str]]",
"source_file": "policyengine_us_data/calibration/unified_matrix_builder.py"
},
"build_publishing_input_bundle": {
"docstring": "Build the normalized coordinator input bundle for one publish scope.",
"id": "build_publishing_input_bundle",
"kind": "function",
"line": 411,
"metadata": {
"api_refs": [
"policyengine_us_data.build_outputs.fingerprinting.PublishingInputBundle",
"modal_app.local_area._build_publishing_input_bundle"
],
"description": "Assemble artifact paths and run metadata for scope fingerprinting.",
"id": "build_publishing_input_bundle",
"label": "Build Publishing Input Bundle",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "modal_app/local_area.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/test_modal_local_area.py"
]
},
"object_path": "modal_app.local_area._build_publishing_input_bundle",
"signature": "def _build_publishing_input_bundle(*, weights_path: Path, dataset_path: Path, db_path: Path | None, geography_path: Path | None, calibration_package_path: Path | None, run_config_path: Path | None, run_id: str, version: str, n_clones: int | None, seed: int, legacy_blocks_path: Path | None = None) -> PublishingInputBundle",
"source_file": "modal_app/local_area.py"
},
"build_states": {
"docstring": "Build state H5 files with checkpointing, optionally uploading.",
"id": "build_states",
"kind": "function",
"line": 454,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.publish_local_area.build_states"
],
"artifacts_out": [
"states/*.h5"
],
"description": "Build state-level H5 files from calibrated weights and exact geography.",
"id": "build_states",
"label": "Build State H5 Files",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/calibration/publish_local_area.py",
"stability": "moving",
"status": "current"
},
"object_path": "policyengine_us_data.calibration.publish_local_area.build_states",
"signature": "def build_states(weights_path: Path, dataset_path: Path, geography, output_dir: Path, completed_states: set, hf_batch_size: int = 10, takeup_filter: List[str] = None, upload: bool = False, state_filter: str = None)",
"source_file": "policyengine_us_data/calibration/publish_local_area.py"
},
"build_worker_bootstrap": {
"docstring": "Persist optional worker bootstrap artifacts for one local H5 scope.",
"id": "build_worker_bootstrap",
"kind": "function",
"line": 504,
"metadata": {
"api_refs": [
"policyengine_us_data.build_outputs.bootstrap.WorkerBootstrapBuilder",
"modal_app.local_area._build_worker_bootstrap"
],
"artifacts_out": [
"bootstrap/{scope}/worker_bootstrap.json",
"bootstrap/{scope}/entity_graph.npz"
],
"description": "Persist deterministic local H5 worker setup artifacts for one scope.",
"id": "build_worker_bootstrap",
"label": "Build Worker Bootstrap",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "modal_app/local_area.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/test_modal_local_area.py"
]
},
"object_path": "modal_app.local_area._build_worker_bootstrap",
"signature": "def _build_worker_bootstrap(*, inputs: PublishingInputBundle, scope: str, artifacts_dir: Path, scope_fingerprint: str | None = None)",
"source_file": "modal_app/local_area.py"
},
"calibration_diagnostics": {
"docstring": "",
"id": "calibration_diagnostics",
"kind": "function",
"line": 1249,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.unified_calibration.compute_diagnostics"
],
"artifacts_out": [
"unified_diagnostics.csv"
],
"description": "Compare fitted weighted sums to calibration targets and summarize error.",
"id": "calibration_diagnostics",
"label": "Compute Calibration Diagnostics",
"node_type": "library",
"pathways": [
"weight_fit"
],
"source_file": "policyengine_us_data/calibration/unified_calibration.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/calibration/test_unified_calibration.py"
]
},
"object_path": "policyengine_us_data.calibration.unified_calibration.compute_diagnostics",
"signature": "def compute_diagnostics(weights: np.ndarray, X_sparse, targets_df, target_names: list) -> 'pd.DataFrame'",
"source_file": "policyengine_us_data/calibration/unified_calibration.py"
},
"calibration_geography_loader": {
"docstring": "Resolve, load, and checksum exact geography artifacts.\n\nThe loader hides compatibility ordering across current saved geography\nbundles, calibration packages, and legacy block arrays. Public callers can\nuse `resolve_source` to inspect what would be loaded or `load` to return the\nnormalized `GeographyAssignment`.",
"id": "calibration_geography_loader",
"kind": "class",
"line": 148,
"metadata": {
"api_refs": [
"policyengine_us_data.build_outputs.geography_loader.CalibrationGeographyLoader"
],
"description": "Resolve and load saved, package-backed, or legacy calibration geography artifacts.",
"id": "calibration_geography_loader",
"label": "CalibrationGeographyLoader",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/build_outputs/geography_loader.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/build_outputs/test_geography_loader.py"
]
},
"object_path": "policyengine_us_data.build_outputs.geography_loader.CalibrationGeographyLoader",
"signature": "class CalibrationGeographyLoader",
"source_file": "policyengine_us_data/build_outputs/geography_loader.py"
},
"clone_assembly": {
"docstring": "Standalone clone-value assembly (no ``self``).\n\nIdentical logic to\n``UnifiedMatrixBuilder._assemble_clone_values`` but usable\nfrom a worker process.",
"id": "clone_assembly",
"kind": "function",
"line": 615,
"metadata": {
"api_refs": [
"policyengine_us_data.calibration.unified_matrix_builder._assemble_clone_values_standalone"
],
"artifacts_out": [
"sparse calibration COO/CSR shards"
],
"description": "Assemble target values for clone-household columns across assigned geographies.",
"id": "clone_assembly",
"label": "Clone Value Assembly",
"node_type": "library",
"pathways": [
"calibration_package"
],
"source_file": "policyengine_us_data/calibration/unified_matrix_builder.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/calibration/test_unified_matrix_builder.py",
"uv run pytest tests/integration/test_chunked_matrix_builder.py"
]
},
"object_path": "policyengine_us_data.calibration.unified_matrix_builder._assemble_clone_values_standalone",
"signature": "def _assemble_clone_values_standalone(state_values: dict, clone_states: np.ndarray, person_hh_indices: np.ndarray, target_vars: set, constraint_vars: set, reform_vars: set = None, county_values: dict = None, clone_counties: np.ndarray = None, county_dependent_vars: set = None, allow_state_fallback_for_county_dependent_targets: bool = False) -> tuple",
"source_file": "policyengine_us_data/calibration/unified_matrix_builder.py"
},
"clone_features": {
"docstring": "Replace clone-half person-level feature variables with donor matches.",
"id": "clone_features",
"kind": "function",
"line": 412,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.extended_cps._splice_clone_feature_predictions"
],
"artifacts_in": [
"qrf_pass2",
"record_double"
],
"artifacts_out": [
"clone_feature_splice"
],
"description": "Replaces clone-half CPS feature variables with donor-matched predictions so doubled records retain plausible demographics and occupation labels.",
"id": "clone_features",
"label": "Splice Clone Features",
"node_type": "process",
"pathways": [
"data_build"
],
"pydoc": true,
"source_file": "policyengine_us_data/datasets/cps/extended_cps.py",
"stability": "moving",
"status": "transitional"
},
"object_path": "policyengine_us_data.datasets.cps.extended_cps._splice_clone_feature_predictions",
"signature": "def _splice_clone_feature_predictions(data: dict, predictions: pd.DataFrame, time_period: int) -> dict",
"source_file": "policyengine_us_data/datasets/cps/extended_cps.py"
},
"clone_weight_matrix": {
"docstring": "Structured view of clone-level household weights.\n\nThe canonical in-memory representation remains the flat vector of length\n``n_records * n_clones``. Matrix views are derived on demand as\n``(n_clones, n_records)`` arrays.\n\nAttributes:\n values: Flat clone-level weight vector.\n n_records: Number of base records represented by each clone.\n n_clones: Number of clone copies represented in the flat vector.",
"id": "clone_weight_matrix",
"kind": "class",
"line": 36,
"metadata": {
"api_refs": [
"policyengine_us_data.build_outputs.weights.CloneWeightMatrix"
],
"artifacts_in": [
"calibration_weights.npy",
"national_calibration_weights.npy"
],
"description": "Explicit shape contract for flat clone-level calibration weights.",
"id": "clone_weight_matrix",
"label": "CloneWeightMatrix",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "policyengine_us_data/build_outputs/weights.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/build_outputs/test_weights.py"
]
},
"object_path": "policyengine_us_data.build_outputs.weights.CloneWeightMatrix",
"signature": "class CloneWeightMatrix",
"source_file": "policyengine_us_data/build_outputs/weights.py"
},
"computed_export_contract": {
"docstring": "Assert that final exported variables are leaf inputs.",
"id": "computed_export_contract",
"kind": "function",
"line": 1585,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.extended_cps.ExtendedCPS._assert_no_computed_variables_exported"
],
"artifacts_in": [
"extended_cps_stage2"
],
"artifacts_out": [
"validated_extended_cps"
],
"description": "Fails the build if the final export still contains variables computed by policyengine-us formulas, adds, or subtracts.",
"id": "computed_export_contract",
"label": "Validate Leaf-Input Export",
"node_type": "process",
"pathways": [
"data_build"
],
"pydoc": true,
"source_file": "policyengine_us_data/datasets/cps/extended_cps.py",
"stability": "moving",
"status": "transitional"
},
"object_path": "policyengine_us_data.datasets.cps.extended_cps.ExtendedCPS._assert_no_computed_variables_exported",
"signature": "def _assert_no_computed_variables_exported(cls, data, time_period)",
"source_file": "policyengine_us_data/datasets/cps/extended_cps.py"
},
"coordinate_publish": {
"docstring": "Coordinate the full publishing workflow.",
"id": "coordinate_publish",
"kind": "function",
"line": 1275,
"metadata": {
"api_refs": [
"modal_app.local_area.coordinate_publish"
],
"artifacts_in": [
"calibration_weights.npy",
"source_imputed_stratified_extended_cps*.h5"
],
"artifacts_out": [
"staged local-area H5 files"
],
"description": "Coordinate local H5 partitioning, worker phases, validation, staging, and promotion.",
"id": "coordinate_publish",
"label": "Coordinate Local H5 Publish",
"node_type": "entrypoint",
"pathways": [
"local_h5",
"orchestration"
],
"source_file": "modal_app/local_area.py",
"stability": "moving",
"status": "current",
"validation_commands": [
"uv run pytest tests/unit/test_modal_local_area.py"
]
},
"object_path": "modal_app.local_area.coordinate_publish",
"signature": "def coordinate_publish(branch: str = 'main', num_workers: int = 50, skip_upload: bool = False, n_clones: int = 430, validate: bool = True, run_id: str = '', candidate_version: str = '', expected_fingerprint: str = '', work_items_override: List[Dict] | None = None) -> Dict",
"source_file": "modal_app/local_area.py"
},
"coordinate_work_partition": {
"docstring": "Compatibility wrapper over the extracted pure partitioning seam.",
"id": "coordinate_work_partition",
"kind": "function",
"line": 686,
"metadata": {
"api_refs": [
"policyengine_us_data.build_outputs.partitioning.partition_weighted_work_items",
"modal_app.local_area.partition_work"
],
"description": "Compatibility wrapper for local H5 weighted work partitioning.",
"id": "coordinate_work_partition",
"label": "Coordinate Work Partition",
"node_type": "library",
"pathways": [
"local_h5"
],
"source_file": "modal_app/local_area.py",
"stability": "moving",
"status": "legacy",
"validation_commands": [
"uv run pytest tests/unit/test_modal_local_area.py"
]
},
"object_path": "modal_app.local_area.partition_work",
"signature": "def partition_work(work_items: List[Dict], num_workers: int, completed: set) -> List[List[Dict]]",
"source_file": "modal_app/local_area.py"
},
"cps_only": {
"docstring": "Second-stage QRF: train on CPS, predict for PUF clones.\n\nFor the PUF clone half of the extended CPS we need plausible values\nof CPS-only variables (retirement distributions, transfers, hours,\nSPM components, etc.) that are consistent with the clone's\nPUF-imputed income -- not just naively copied from the CPS donor.\n\nWe train a QRF on CPS person-level data where:\n * predictors = demographics + key income variables\n * outputs = CPS-only variables listed in\n ``CPS_ONLY_IMPUTED_VARIABLES``\n\nFor PUF clone prediction we use the PUF-imputed income values\nfrom the second half of ``data`` (the clone half, which already\nhas PUF-imputed income from stage 1).\n\nUses ``fit_predict()`` with ``max_train_samples`` instead of\nmanual sampling + separate fit/predict.\n\nArgs:\n data: Extended dataset dict after ``puf_clone_dataset()`` --\n already doubled, with PUF-imputed income in the second half.\n time_period: Tax year.\n dataset_path: Path to the CPS h5 file for Microsimulation.\n\nReturns:\n DataFrame with one column per CPS-only variable, containing\n predicted values for the PUF clone half (person-level).",
"id": "cps_only",
"kind": "function",
"line": 451,
"metadata": {
"api_refs": [
"policyengine_us_data.datasets.cps.extended_cps._impute_cps_only_variables"
],
"artifacts_in": [
"record_double",
"preprocess_cps"
],
"artifacts_out": [
"cps_only_predictions"
],
"description": "Runs the second-stage CPS-only QRF imputation for PUF clone records inside the extended CPS build.",
"id": "cps_only",
"label": "Impute CPS-Only Variables",
"node_type": "process",
"pathways": [
"data_build"
],
"pydoc": true,
"source_file": "policyengine_us_data/datasets/cps/extended_cps.py",
"stability": "moving",
"status": "transitional"
},
"object_path": "policyengine_us_data.datasets.cps.extended_cps._impute_cps_only_variables",
"signature": "def _impute_cps_only_variables(data: dict, time_period: int, dataset_path: str) -> pd.DataFrame",