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

Function gh_api

scripts/baseline_workflow_metrics.py:118–127  ·  view source on GitHub ↗

Call the GitHub REST API via the gh CLI and return parsed JSON.

(path: str)

Source from the content-addressed store, hash-verified

116
117
118def gh_api(path: str) -> dict | list:
119 """Call the GitHub REST API via the gh CLI and return parsed JSON."""
120 cmd = ["gh", "api", "-H", "Accept: application/vnd.github+json", path]
121 try:
122 result = subprocess.run(cmd, check=True, capture_output=True, text=True)
123 except FileNotFoundError:
124 sys.exit("gh CLI not found on PATH. Install: https://cli.github.com/")
125 except subprocess.CalledProcessError as exc:
126 sys.exit(f"gh api failed for {path}: {exc.stderr.strip()}")
127 return json.loads(result.stdout)
128
129
130def parse_iso(value: str | None) -> dt.datetime | None:

Callers 2

fetch_runsFunction · 0.85
fetch_all_repo_runsFunction · 0.85

Calls 1

runMethod · 0.45

Tested by

no test coverage detected