|
| 1 | +name: Site Snapshot |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + site-snapshot: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + defaults: |
| 17 | + run: |
| 18 | + working-directory: microplex-us |
| 19 | + steps: |
| 20 | + - name: Check out microplex-us |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + path: microplex-us |
| 24 | + |
| 25 | + - name: Check out core microplex |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + repository: CosilicoAI/microplex |
| 29 | + ref: 71f270edecac3ef748411deb3beb77109c56a721 |
| 30 | + path: microplex |
| 31 | + |
| 32 | + - name: Set up Python |
| 33 | + uses: actions/setup-python@v5 |
| 34 | + with: |
| 35 | + python-version: "3.13" |
| 36 | + |
| 37 | + - name: Set up uv |
| 38 | + uses: astral-sh/setup-uv@v6 |
| 39 | + |
| 40 | + - name: Verify snapshot tooling |
| 41 | + run: | |
| 42 | + uv run --extra dev --with pydantic --with-editable ../microplex pytest -q \ |
| 43 | + tests/test_package_imports.py \ |
| 44 | + tests/pipelines/test_check_site_snapshot.py \ |
| 45 | + tests/pipelines/test_imputation_ablation.py \ |
| 46 | + tests/pipelines/test_site_snapshot.py \ |
| 47 | + tests/pipelines/test_version_benchmark.py |
| 48 | +
|
| 49 | + - name: Check generated site snapshot |
| 50 | + run: | |
| 51 | + snapshot_path="$(uv run python - <<'PY' |
| 52 | + import json |
| 53 | + import tempfile |
| 54 | + from pathlib import Path |
| 55 | +
|
| 56 | + from microplex_us.pipelines.site_snapshot import write_us_microplex_site_snapshot |
| 57 | +
|
| 58 | + root = Path(tempfile.mkdtemp()).resolve() |
| 59 | + artifact_dir = root / "run-1" |
| 60 | + artifact_dir.mkdir() |
| 61 | + for filename in ( |
| 62 | + "seed_data.parquet", |
| 63 | + "synthetic_data.parquet", |
| 64 | + "calibrated_data.parquet", |
| 65 | + "targets.json", |
| 66 | + ): |
| 67 | + (artifact_dir / filename).write_text("{}" if filename == "targets.json" else "") |
| 68 | +
|
| 69 | + (artifact_dir / "manifest.json").write_text( |
| 70 | + json.dumps( |
| 71 | + { |
| 72 | + "created_at": "2026-03-29T00:00:00+00:00", |
| 73 | + "config": {"n_synthetic": 2000}, |
| 74 | + "artifacts": { |
| 75 | + "seed_data": "seed_data.parquet", |
| 76 | + "synthetic_data": "synthetic_data.parquet", |
| 77 | + "calibrated_data": "calibrated_data.parquet", |
| 78 | + "targets": "targets.json", |
| 79 | + "policyengine_harness": "policyengine_harness.json", |
| 80 | + }, |
| 81 | + "synthesis": { |
| 82 | + "scaffold_source": "cps_asec_2023", |
| 83 | + "state_program_support_proxies": { |
| 84 | + "available": ["ssi"], |
| 85 | + "missing": ["snap"], |
| 86 | + }, |
| 87 | + }, |
| 88 | + "calibration": { |
| 89 | + "n_loaded_targets": 100, |
| 90 | + "n_supported_targets": 90, |
| 91 | + "converged": False, |
| 92 | + "weight_collapse_suspected": False, |
| 93 | + }, |
| 94 | + "policyengine_harness": { |
| 95 | + "candidate_mean_abs_relative_error": 0.9, |
| 96 | + "baseline_mean_abs_relative_error": 1.1, |
| 97 | + "mean_abs_relative_error_delta": -0.2, |
| 98 | + }, |
| 99 | + } |
| 100 | + ) |
| 101 | + ) |
| 102 | + (artifact_dir / "policyengine_harness.json").write_text( |
| 103 | + json.dumps( |
| 104 | + { |
| 105 | + "summary": { |
| 106 | + "candidate_mean_abs_relative_error": 0.9, |
| 107 | + "baseline_mean_abs_relative_error": 1.1, |
| 108 | + "mean_abs_relative_error_delta": -0.2, |
| 109 | + "candidate_composite_parity_loss": 0.8, |
| 110 | + "baseline_composite_parity_loss": 1.2, |
| 111 | + "target_win_rate": 0.2, |
| 112 | + "slice_win_rate": 0.5, |
| 113 | + "supported_target_rate": 0.9, |
| 114 | + "tag_summaries": {}, |
| 115 | + "parity_scorecard": {}, |
| 116 | + "attribute_cell_summaries": {}, |
| 117 | + } |
| 118 | + } |
| 119 | + ) |
| 120 | + ) |
| 121 | + snapshot_path = root / "snapshots" / "site_snapshot_us.json" |
| 122 | + write_us_microplex_site_snapshot(artifact_dir, snapshot_path) |
| 123 | + print(snapshot_path) |
| 124 | + PY |
| 125 | + )" |
| 126 | + uv run microplex-us-check-site-snapshot "$snapshot_path" |
0 commit comments