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

Function main

scripts/baseline_workflow_metrics.py:363–401  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

361
362
363def main() -> int:
364 args = parse_args()
365 since = dt.datetime.now(dt.UTC) - dt.timedelta(days=args.days)
366 all_stats: list[WorkflowStats] = []
367 # Only do the expensive all-repo scan if at least one reusable workflow
368 # appears in the target list.
369 need_repo_scan = any(w in REUSABLE_WORKFLOWS for w in WORKFLOWS)
370 all_repo_runs: list[dict] = []
371 if need_repo_scan:
372 print("• (scanning all repo runs for reusable attribution)", file=sys.stderr)
373 all_repo_runs = fetch_all_repo_runs(since)
374 for workflow in WORKFLOWS:
375 print(f"• {workflow}", file=sys.stderr)
376 if workflow in REUSABLE_WORKFLOWS:
377 runs = fetch_reusable_runs(workflow, all_repo_runs)
378 all_stats.append(summarize(workflow, args.days, runs, reusable=True))
379 else:
380 runs = fetch_runs(workflow, since)
381 all_stats.append(summarize(workflow, args.days, runs))
382
383 args.out.parent.mkdir(parents=True, exist_ok=True)
384 args.out.write_text(
385 json.dumps(
386 {
387 "repo": REPO,
388 "window_days": args.days,
389 "generated_at": dt.datetime.now(dt.UTC).isoformat(),
390 "workflows": [dataclasses.asdict(s) for s in all_stats],
391 },
392 indent=2,
393 default=str,
394 )
395 + "\n",
396 encoding="utf-8",
397 )
398 args.md.write_text(render_markdown(all_stats, since), encoding="utf-8")
399 print(f"wrote {args.out}", file=sys.stderr)
400 print(f"wrote {args.md}", file=sys.stderr)
401 return 0
402
403
404if __name__ == "__main__":

Callers 1

Calls 6

fetch_all_repo_runsFunction · 0.85
fetch_reusable_runsFunction · 0.85
summarizeFunction · 0.85
fetch_runsFunction · 0.85
render_markdownFunction · 0.85
parse_argsFunction · 0.70

Tested by

no test coverage detected