Skip to content
This repository was archived by the owner on Jul 2, 2026. It is now read-only.

Commit bb187c7

Browse files
authored
Merge pull request #963 from PolicyEngine/feat/pipeline-status-reporting
Add durable pipeline status reporting
2 parents 2ca73b6 + 4fa414e commit bb187c7

18 files changed

Lines changed: 1577 additions & 78 deletions

File tree

.github/copilot-instructions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ from branches in `PolicyEngine/policyengine-us-data`; never create fork PRs.
1313
For PRs that change pipeline behavior, stage boundaries, generated artifacts, or
1414
public library functions, read
1515
`docs/engineering/skills/documentation_review.md` during review.
16+
17+
For deployed Modal pipeline run status or failure diagnosis, read
18+
`docs/engineering/skills/pipeline_operations.md`.

.github/workflows/pr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ jobs:
149149
env:
150150
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
151151
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
152+
MODAL_PROXY_TOKEN_ID: ${{ secrets.MODAL_PROXY_TOKEN_ID }}
153+
MODAL_PROXY_TOKEN_SECRET: ${{ secrets.MODAL_PROXY_TOKEN_SECRET }}
152154
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
153155
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
154156
MODAL_ENVIRONMENT: staging-us-data-pr-${{ github.event.pull_request.number }}

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ When reviewing PRs that change pipeline behavior, stage boundaries, generated
1717
artifacts, or public library functions, read
1818
`docs/engineering/skills/documentation_review.md`.
1919

20+
When diagnosing a deployed Modal pipeline run or a failed publication pipeline,
21+
read `docs/engineering/skills/pipeline_operations.md`.
22+
2023
## GitHub PRs
2124

2225
Read `docs/engineering/skills/github-prs.md` before opening, replacing, or

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ When reviewing PRs that change pipeline behavior, stage boundaries, generated
2525
artifacts, or public library functions, read
2626
`docs/engineering/skills/documentation_review.md`.
2727

28+
When diagnosing a deployed Modal pipeline run or a failed publication pipeline,
29+
read `docs/engineering/skills/pipeline_operations.md`.
30+
2831
## Safety boundaries
2932

3033
Do not fabricate data, validation metrics, academic results, or performance

changelog.d/962.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add structured Modal pipeline status reporting with durable run-scoped error records.

docs/engineering/skills/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ Current skills:
1616
conventions.
1717
- `pipeline_docs.md`: decorator-backed pipeline map maintenance and generated
1818
pydoc-style artifacts.
19+
- `pipeline_operations.md`: model-neutral workflow for diagnosing deployed Modal
20+
pipeline status and durable error records.
1921
- `testing.md`: test layout, fixture scope, helper placement, and quality guard
2022
expectations.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Pipeline Operations
2+
3+
Use this skill when diagnosing a deployed Modal pipeline run, especially when a
4+
GitHub Actions pipeline launch fails or a user asks for the status of a run.
5+
6+
## Source Of Truth
7+
8+
Treat the pipeline status endpoint and run-scoped error records as the first
9+
diagnostic source. Modal dashboard logs are useful supporting evidence, but they
10+
are not the durable error record for this repo.
11+
12+
The status system reports:
13+
14+
- the run-level manifest;
15+
- all stage and substage manifests present for that run;
16+
- missing expected runtime manifest IDs;
17+
- the latest durable error record, when one exists;
18+
- a redacted, bounded traceback when one exists.
19+
20+
## Status Surfaces
21+
22+
The structured status payload is canonical. The pipeline status sub-app exposes
23+
three Modal functions:
24+
25+
- `get_pipeline_status`: Python-callable structured JSON for agents, scripts,
26+
dashboards, and tests. Prefer this for diagnosis and automation.
27+
- `pipeline_status_endpoint`: protected HTTP endpoint returning the same
28+
structured JSON for non-Python clients. Use Modal proxy auth headers.
29+
- `pipeline_status_snippet`: human-readable text used by
30+
`modal run modal_app/pipeline.py::main --action status`. This is for quick
31+
terminal inspection only and must not be treated as a schema.
32+
33+
## Fetch Status
34+
35+
First identify the run context from the GitHub Actions summary, workflow logs, or
36+
run-context output:
37+
38+
- `run_id`
39+
- Modal app name
40+
- Modal environment
41+
42+
For agent or CLI diagnosis, call the deployed Modal function:
43+
44+
```bash
45+
uv run python - <<'PY'
46+
import json
47+
import modal
48+
49+
app_name = "POLICYENGINE_US_DATA_MODAL_APP"
50+
environment_name = "main"
51+
run_id = "US_DATA_RUN_ID"
52+
53+
fn = modal.Function.from_name(
54+
app_name,
55+
"get_pipeline_status",
56+
environment_name=environment_name,
57+
)
58+
print(json.dumps(fn.remote(run_id), indent=2))
59+
PY
60+
```
61+
62+
The status payload includes a traceback when one is available. Tracebacks are
63+
redacted and bounded by keeping the newest text if they are very long.
64+
65+
If the local environment cannot sync the full project environment, use the same
66+
snippet with a Modal-only temporary environment by replacing `uv run python`
67+
with `uv run --no-sync --with modal python`.
68+
69+
If using the HTTP endpoint, authenticate with Modal proxy auth headers. Do not
70+
publish or paste proxy auth values into PRs, issues, logs, or docs.
71+
72+
```bash
73+
curl \
74+
-H "Modal-Key: $MODAL_PROXY_TOKEN_ID" \
75+
-H "Modal-Secret: $MODAL_PROXY_TOKEN_SECRET" \
76+
"https://<status-endpoint>.modal.run?run_id=<run_id>"
77+
```
78+
79+
## Interpret Results
80+
81+
Use `status` and `message` for the short answer. Then inspect:
82+
83+
- `error.stage_id`: canonical top-level stage, such as `3_fit_weights`;
84+
- `error.substage_id`: narrower substage, such as
85+
`3a_weight_fitting_regional`;
86+
- `error.record_path`: immutable error record path in the pipeline volume;
87+
- `error.latest_path`: latest error pointer for the run;
88+
- `stage_manifests[].manifest.error`: manifest-local failure details;
89+
- `missing_expected_manifest_ids`: expected runtime manifests that have not yet
90+
been written.
91+
92+
When reporting back, name the failing stage and substage, summarize the exception
93+
type and message, and cite whether the traceback came from the status endpoint or
94+
from Modal dashboard logs.
95+
96+
## Safety Rules
97+
98+
- Do not paste tracebacks into PRs, issues, or chat unless the user needs that
99+
detail.
100+
- Redact secrets before sharing command output, even though the status endpoint
101+
already applies obvious redaction.
102+
- Do not infer that a missing later-stage manifest is a failure if the run is
103+
still running.
104+
- If the run was hard-killed before Python exception handling ran, the endpoint
105+
may show a running run with no durable error. In that case, report the last
106+
completed/running manifest and then use Modal dashboard logs as secondary
107+
evidence.

0 commit comments

Comments
 (0)