|
16 | 16 | _new_run_metadata, |
17 | 17 | _pipeline_error_summary, |
18 | 18 | _run_required_promotion_subprocess, |
| 19 | + _traceback_text_for_pipeline_failure, |
19 | 20 | _try_reload_pipeline_volume_after_h5_builds, |
20 | 21 | ) |
21 | 22 | from modal_app.step_manifests.state import RunMetadata # noqa: E402 |
22 | 23 | from modal_app.step_manifests.store import ( # noqa: E402 |
23 | 24 | read_run_meta, |
24 | 25 | write_run_meta, |
25 | 26 | ) |
| 27 | +from policyengine_us_data.build_datasets.commands import DatasetCommandError # noqa: E402 |
| 28 | +from policyengine_us_data.build_datasets.results import DatasetCommandResult # noqa: E402 |
| 29 | +from policyengine_us_data.build_datasets.status import Stage1ErrorRecord # noqa: E402 |
26 | 30 | from policyengine_us_data.utils.run_context import RunContext # noqa: E402 |
27 | 31 | from policyengine_us_data.utils.step_manifest import ArtifactReference # noqa: E402 |
28 | 32 |
|
@@ -128,6 +132,43 @@ def test_pipeline_error_summary_falls_back_to_bounded_traceback(monkeypatch): |
128 | 132 | assert "old traceback" not in summary |
129 | 133 |
|
130 | 134 |
|
| 135 | +def test_pipeline_failure_traceback_prefers_stage_1_command_tail(): |
| 136 | + result = DatasetCommandResult( |
| 137 | + command_name="policyengine_us_data/datasets/cps/extended_cps.py", |
| 138 | + argv=("python", "-m", "policyengine_us_data.datasets.cps.extended_cps"), |
| 139 | + status="failed", |
| 140 | + returncode=1, |
| 141 | + started_at="2026-05-22T12:00:00Z", |
| 142 | + completed_at="2026-05-22T12:00:01Z", |
| 143 | + duration_s=1.0, |
| 144 | + combined_output_tail=("actual ecps failure\n",), |
| 145 | + error=Stage1ErrorRecord( |
| 146 | + substep_id="1c_extended_cps_puf_clone", |
| 147 | + command_name="policyengine_us_data/datasets/cps/extended_cps.py", |
| 148 | + error_type="RuntimeError", |
| 149 | + message="Command failed", |
| 150 | + returncode=1, |
| 151 | + metadata={ |
| 152 | + "argv": [ |
| 153 | + "python", |
| 154 | + "-m", |
| 155 | + "policyengine_us_data.datasets.cps.extended_cps", |
| 156 | + ], |
| 157 | + "output_tail": ["actual ecps failure\n"], |
| 158 | + }, |
| 159 | + ), |
| 160 | + ) |
| 161 | + |
| 162 | + traceback_text = _traceback_text_for_pipeline_failure( |
| 163 | + DatasetCommandError(result), |
| 164 | + "fallback traceback", |
| 165 | + ) |
| 166 | + |
| 167 | + assert "fallback traceback" not in traceback_text |
| 168 | + assert "policyengine_us_data.datasets.cps.extended_cps" in traceback_text |
| 169 | + assert "actual ecps failure" in traceback_text |
| 170 | + |
| 171 | + |
131 | 172 | def test_new_run_metadata_accepts_release_context_fields_once(): |
132 | 173 | context = RunContext.from_mapping( |
133 | 174 | { |
|
0 commit comments