Infer ecosystem metrics from explicit repos (#3353)

Co-authored-by: LauraGPT <[email protected]>
This commit is contained in:
zhifu gao
2026-07-23 04:41:34 +08:00
committed by GitHub
co-authored by LauraGPT
parent 54dd4d0cbd
commit 9eee3095c8
2 changed files with 66 additions and 6 deletions
+8 -6
View File
@@ -982,8 +982,8 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--repos",
nargs="+",
default=DEFAULT_ECOSYSTEM_REPOS,
help="GitHub repositories for --ecosystem mode",
default=None,
help="GitHub repositories for --ecosystem or --issues mode; multiple explicit repos imply --ecosystem",
)
parser.add_argument("--ecosystem", action="store_true", help="Collect the four-repository FunASR ecosystem")
parser.add_argument("--integrations", action="store_true", help="Collect tracked external integration PRs")
@@ -1010,14 +1010,16 @@ def parse_args() -> argparse.Namespace:
def main() -> int:
args = parse_args()
repos = args.repos or DEFAULT_ECOSYSTEM_REPOS
ecosystem_mode = args.ecosystem or bool(args.repos and len(args.repos) > 1)
try:
if args.integrations:
metrics = collect_integration_metrics(args.integration_prs)
elif args.issues:
metrics = collect_issue_metrics(args.repos)
elif args.ecosystem:
metrics = collect_issue_metrics(repos)
elif ecosystem_mode:
metrics = collect_ecosystem_metrics(
args.repos,
repos,
args.pypi_package,
args.baseline_stars,
args.target_additional_stars,
@@ -1035,7 +1037,7 @@ def main() -> int:
print(format_integration_markdown(metrics), end="")
elif args.issues:
print(format_issue_markdown(metrics), end="")
elif args.ecosystem:
elif ecosystem_mode:
print(format_ecosystem_markdown(metrics), end="")
else:
print(format_markdown(metrics, args.star_goal), end="")
+58
View File
@@ -1642,6 +1642,64 @@ def test_main_outputs_ecosystem_json(monkeypatch):
assert payload["ecosystem"]["remaining_to_target"] == 16602
def test_main_treats_explicit_multi_repos_as_ecosystem_json(monkeypatch):
module = load_growth_metrics_module()
repo_stars = {
"modelscope/FunASR": 18714,
"FunAudioLLM/Fun-ASR": 1318,
"FunAudioLLM/SenseVoice": 8718,
"modelscope/FunClip": 5872,
}
def fake_fetch_json(url, headers=None):
if url.endswith("/pulls?state=open&per_page=100"):
return []
if url.startswith("https://api.github.com/repos/"):
repo = url.removeprefix("https://api.github.com/repos/")
return {
"stargazers_count": repo_stars[repo],
"forks_count": 0,
"subscribers_count": 0,
"open_issues_count": 0,
"default_branch": "main",
"pushed_at": "2026-06-30T00:00:00Z",
"html_url": f"https://github.com/{repo}",
}
if url == "https://pypi.org/pypi/funasr/json":
return {"info": {"version": "1.3.14", "summary": "FunASR", "project_url": "https://pypi.org/project/funasr/"}}
raise AssertionError(f"unexpected URL: {url}")
monkeypatch.setattr(module, "fetch_json", fake_fetch_json)
monkeypatch.setattr(
sys,
"argv",
[
"collect_growth_metrics.py",
"--format",
"json",
"--repos",
"modelscope/FunASR",
"FunAudioLLM/Fun-ASR",
"FunAudioLLM/SenseVoice",
"modelscope/FunClip",
],
)
with redirect_stdout(io.StringIO()) as stdout:
assert module.main() == 0
payload = json.loads(stdout.getvalue())
assert "github" not in payload
assert payload["ecosystem"]["total_stars"] == 34622
assert [repo["repo"] for repo in payload["ecosystem"]["repositories"]] == [
"modelscope/FunASR",
"FunAudioLLM/Fun-ASR",
"FunAudioLLM/SenseVoice",
"modelscope/FunClip",
]
def test_main_outputs_integrations_json(monkeypatch):
module = load_growth_metrics_module()