Extract uncached files sequentially (fallback for small batches).
(
uncached_work: list[tuple[int, Path]],
per_file: list[dict | None],
root: Path,
total_files: int,
cache_location: Path | None = None,
)
| 12892 | |
| 12893 | |
| 12894 | def _extract_sequential( |
| 12895 | uncached_work: list[tuple[int, Path]], |
| 12896 | per_file: list[dict | None], |
| 12897 | root: Path, |
| 12898 | total_files: int, |
| 12899 | cache_location: Path | None = None, |
| 12900 | ) -> None: |
| 12901 | """Extract uncached files sequentially (fallback for small batches).""" |
| 12902 | _PROGRESS_INTERVAL = 100 |
| 12903 | for work_idx, (idx, path) in enumerate(uncached_work): |
| 12904 | if ( |
| 12905 | total_files >= _PROGRESS_INTERVAL |
| 12906 | and work_idx % _PROGRESS_INTERVAL == 0 |
| 12907 | and work_idx > 0 |
| 12908 | ): |
| 12909 | print( |
| 12910 | f" AST extraction: {work_idx}/{len(uncached_work)} uncached files ({work_idx * 100 // len(uncached_work)}%)", |
| 12911 | flush=True, |
| 12912 | ) |
| 12913 | extractor = _get_extractor(path) |
| 12914 | if extractor is None: |
| 12915 | per_file[idx] = {"nodes": [], "edges": []} |
| 12916 | continue |
| 12917 | bypass_cache = effective_suffix(path) in _JS_CACHE_BYPASS_SUFFIXES |
| 12918 | # XAML boundary anchors on `root` (the corpus), not the cache location. |
| 12919 | result = _safe_extract_with_xaml_root(extractor, path, root) |
| 12920 | # See _extract_single_file: don't cache an anomalous zero-node result (#1666), |
| 12921 | # but cache intentional declines/virtual manifests carrying `skipped` (#3910). |
| 12922 | if not bypass_cache and "error" not in result and (result.get("nodes") or result.get("skipped")): |
| 12923 | save_cached(path, result, root, cache_root=cache_location, salt=cache_salt(path)) |
| 12924 | per_file[idx] = result |
| 12925 | if total_files >= _PROGRESS_INTERVAL: |
| 12926 | # Consistent denominator with the intermediate lines (#1693). |
| 12927 | _done = len(uncached_work) |
| 12928 | print(f" AST extraction: {_done}/{_done} uncached files (100%)", flush=True) |
| 12929 | |
| 12930 | |
| 12931 | _PARALLEL_THRESHOLD = 20 |
no test coverage detected