Check that we found all expected start/end pairs. Raises on missing scopes.
(insertions: list[tuple[int, str]], filepath: str)
| 202 | |
| 203 | |
| 204 | def _validate_insertions(insertions: list[tuple[int, str]], filepath: str) -> None: |
| 205 | """Check that we found all expected start/end pairs. Raises on missing scopes.""" |
| 206 | texts = [t for _, t in insertions] |
| 207 | errors = [] |
| 208 | for scope in ["kernel", "setup", "mask", "tile-mgmt", "sample", "store"]: |
| 209 | has_start = f'start "{scope}"' in texts |
| 210 | has_end = f'end "{scope}"' in texts |
| 211 | if has_start != has_end: |
| 212 | errors.append( |
| 213 | f"{filepath}: found {'start' if has_start else 'end'} " |
| 214 | f"but not {'end' if has_start else 'start'} for scope {scope!r}" |
| 215 | ) |
| 216 | if not has_start and not has_end: |
| 217 | errors.append(f"{filepath}: could not find scope {scope!r}") |
| 218 | if errors: |
| 219 | raise RuntimeError( |
| 220 | "Proton scope insertion failed. Missing scopes indicate the TTGIR " |
| 221 | "patterns have changed (compiler renamed variables?).\n" |
| 222 | + "\n".join(f" - {e}" for e in errors) |
| 223 | ) |
| 224 | |
| 225 | |
| 226 | def find_and_process_ttgir(dump_dir: str) -> None: |
no outgoing calls
no test coverage detected