MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / fetch_reusable_runs

Function fetch_reusable_runs

scripts/baseline_workflow_metrics.py:214–233  ·  view source on GitHub ↗

Attribute a reusable workflow via `referenced_workflows` on caller runs. Wall/queue times come from the caller run, so they are caller-inclusive — a caller that inlines other jobs alongside the reusable workflow will overstate the reusable piece. Annotated in the rendered output.

(workflow: str, all_repo_runs: list[dict])

Source from the content-addressed store, hash-verified

212
213
214def fetch_reusable_runs(workflow: str, all_repo_runs: list[dict]) -> list[RunSummary]:
215 """Attribute a reusable workflow via `referenced_workflows` on caller runs.
216
217 Wall/queue times come from the caller run, so they are caller-inclusive —
218 a caller that inlines other jobs alongside the reusable workflow will
219 overstate the reusable piece. Annotated in the rendered output.
220 """
221 suffix = f".github/workflows/{workflow}"
222 runs: list[RunSummary] = []
223 for raw in all_repo_runs:
224 refs = raw.get("referenced_workflows") or []
225 # GitHub returns paths like "org/repo/.github/workflows/foo.yml@<sha>"
226 # — strip the `@ref` suffix before matching.
227 if not any(r.get("path", "").split("@", 1)[0].endswith(suffix) for r in refs):
228 continue
229 run = _run_from_raw(raw)
230 if run is None:
231 continue
232 runs.append(run)
233 return runs
234
235
236def _percentile(values: Iterable[float], p: float) -> float | None:

Callers 1

mainFunction · 0.85

Calls 2

_run_from_rawFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected