From 7055f142eabb17daff0459918acd1ce2a8eceb1a Mon Sep 17 00:00:00 2001 From: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> Date: Wed, 30 Sep 2026 15:06:13 -0400 Subject: [PATCH] Use canonical Hugging Face model page URLs Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com> --- src/benchmark_radar/sources.py | 3 ++- tests/test_sources.py | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/benchmark_radar/sources.py b/src/benchmark_radar/sources.py index 0e04bbe9..bcb688d2 100644 --- a/src/benchmark_radar/sources.py +++ b/src/benchmark_radar/sources.py @@ -480,7 +480,8 @@ def fetch_huggingface(config: dict[str, Any], since: datetime, limit: int) -> li source="Hugging Face", source_id=item_id, title=item_id, - url=f"https://huggingface.co/{kind}/{item_id}", + # Hub model pages omit the API's /models kind segment. + url=f"https://huggingface.co/{'' if kind == 'models' else kind + '/'}{item_id}", published_at=created or changed, updated_at=changed, # Never synthesize prose here: `score_item` reads `summary`, diff --git a/tests/test_sources.py b/tests/test_sources.py index eff385f8..48443e2c 100644 --- a/tests/test_sources.py +++ b/tests/test_sources.py @@ -2204,3 +2204,24 @@ def test_collection_method_falls_back_to_a_static_default_without_items(): # leaves nothing to inspect; fall back to the connector's usual method. assert collection_method("arxiv", []) == "RSS" assert collection_method("brave", []) == "API" + + +@pytest.mark.parametrize( + ("kind", "prefix"), [("models", ""), ("datasets", "datasets/"), ("spaces", "spaces/")] +) +def test_huggingface_links_follow_repository_kind_routes(monkeypatch, kind, prefix): + monkeypatch.setattr( + "benchmark_radar.sources.get_json", + lambda *args, **kwargs: [ + { + "id": "lab/benchmark", + "createdAt": "2026-08-08T12:00:00Z", + "lastModified": "2026-08-08T12:00:00Z", + } + ], + ) + # Model pages live at /owner/repo; /models/owner/repo was a broken link. + items = fetch_huggingface( + {"kinds": [kind], "searches": ["benchmark"]}, datetime(2026, 8, 8, tzinfo=UTC), 10 + ) + assert items[0].url == f"https://huggingface.co/{prefix}lab/benchmark"