|
191 | 191 | app = modal.App("interscript-ml-export", image=IMAGE) |
192 | 192 |
|
193 | 193 |
|
| 194 | +def normalize_precisions(precisions: "str | list[str]") -> list[str]: |
| 195 | + """Accept both invocation forms: the parity/margins entrypoints pass |
| 196 | + a pre-split list, direct ::parity_model-style CLI calls pass a |
| 197 | + comma string.""" |
| 198 | + if isinstance(precisions, str): |
| 199 | + precisions = precisions.split(",") |
| 200 | + return [q.strip() for q in precisions if q.strip()] |
| 201 | + |
| 202 | + |
194 | 203 | def pending_precisions( |
195 | | - out_dir: Path, mid: str, precisions: list[str] |
| 204 | + out_dir: Path, mid: str, precisions: "str | list[str]" |
196 | 205 | ) -> list[str]: |
197 | 206 | """Precision stages still to run: the margin report is the last |
198 | 207 | artifact a stage writes, so its presence means the stage (parity |
199 | 208 | block in the zip included) completed durably. Preemption restarts |
200 | 209 | resume at the next stage instead of redoing hours of decode.""" |
201 | 210 | return [ |
202 | | - p for p in precisions if not (out_dir / f"{mid}-margins-{p}.json").exists() |
| 211 | + p |
| 212 | + for p in normalize_precisions(precisions) |
| 213 | + if not (out_dir / f"{mid}-margins-{p}.json").exists() |
203 | 214 | ] |
204 | 215 |
|
205 | 216 |
|
@@ -336,9 +347,7 @@ def stage(event: str) -> None: |
336 | 347 | meta_path = Path("/root/interscript-ml", spec["metadata"]) |
337 | 348 | mid = re.search(r"^id:\s*(\S+)", meta_path.read_text(encoding="utf-8"), re.M).group(1) |
338 | 349 | reports: dict[str, str] = {} |
339 | | - todo = pending_precisions( |
340 | | - out_dir, mid, [q.strip() for q in precisions.split(",") if q.strip()] |
341 | | - ) |
| 350 | + todo = pending_precisions(out_dir, mid, precisions) |
342 | 351 | for precision in todo: |
343 | 352 | zip_path = out_dir / f"{mid}-{precision}.zip" |
344 | 353 | stage(f"onnx decode {precision}") |
@@ -406,7 +415,7 @@ def margin_model( |
406 | 415 | meta_path = Path("/root/interscript-ml", spec["metadata"]) |
407 | 416 | mid = re.search(r"^id:\s*(\S+)", meta_path.read_text(encoding="utf-8"), re.M).group(1) |
408 | 417 | reports: dict[str, str] = {} |
409 | | - for precision in [p.strip() for p in precisions.split(",") if p.strip()]: |
| 418 | + for precision in normalize_precisions(precisions): |
410 | 419 | zip_path = out_dir / f"{mid}-{precision}.zip" |
411 | 420 | if not zip_path.exists(): |
412 | 421 | reports[precision] = "zip not exported (skipped)" |
|
0 commit comments