Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/benchmark_radar/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
21 changes: 21 additions & 0 deletions tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3375,3 +3375,24 @@ def test_collection_method_falls_back_to_a_static_default_without_items():
assert collection_method("brave", []) == "API"
assert collection_method("datacite", []) == "API"
assert collection_method("openaire", []) == "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"
Loading