From 107d4361e9a61f34f2a912b63ac515afb1c83c33 Mon Sep 17 00:00:00 2001 From: Shinji Watanabe Date: Mon, 19 Oct 2026 07:40:10 -0400 Subject: [PATCH] Keep the table name when a row's url is the bare Hub marker Four table.csv rows store "https://huggingface.co/" as their url. _resolve_huggingface read that as a full repository URL and returned its empty tail as the repo id, so snapshot_download raised HFValidationError on "". The scheduled model test failed on two of them (byan/librispeech_asr_train_asr_conformer_..., reazon-research/ reazonspeech-espnet-v1); the two pyf98 speechcommands SLU rows had the same fault but are not loaded by the test. Co-Authored-By: Claude Opus 5.5 --- espnet_model_zoo/downloader.py | 9 +++++++-- test/test_downloader.py | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/espnet_model_zoo/downloader.py b/espnet_model_zoo/downloader.py index a235d49..a7b57ed 100644 --- a/espnet_model_zoo/downloader.py +++ b/espnet_model_zoo/downloader.py @@ -111,13 +111,18 @@ def _resolve_huggingface(name, url): test here, download() then recognised it and returned a snapshot directory, and download_and_unpack() tried to unpack that directory as an archive. All three now come out as (repo_id, "https://huggingface.co/"). + + A row whose url is the marker itself, "https://huggingface.co/", is the + first shape, not the third: the URL names no repository, so the id stays + the name. Taking the empty tail as the id sent "" to snapshot_download. """ for candidate in (name, url): if isinstance(candidate, str) and candidate.startswith( "https://huggingface.co/" ): - repo_id = candidate[len("https://huggingface.co/") :] - return repo_id, "https://huggingface.co/" + repo_id = candidate[len("https://huggingface.co/") :].strip("/") + if repo_id: + return repo_id, "https://huggingface.co/" return name, url diff --git a/test/test_downloader.py b/test/test_downloader.py index be96c79..678ff71 100644 --- a/test/test_downloader.py +++ b/test/test_downloader.py @@ -122,6 +122,30 @@ def fake_huggingface_download(name=None, **kw): assert d.download_and_unpack(marker_tag) == {"cache_dir": marker_tag} +def test_table_row_with_bare_hub_marker_url_keeps_its_name(tmp_path, monkeypatch): + # Four table.csv rows hold "https://huggingface.co/" - the marker with a + # trailing slash - as their url. Read as a full repository URL, its empty + # tail became the repo id and snapshot_download rejected "". + tag = "reazon-research/reazonspeech-espnet-v1" + d = ModelDownloader(tmp_path) + assert d.get_url(tag) == "https://huggingface.co/" + seen = [] + + def fake_huggingface_download(name=None, **kw): + seen.append(name) + return name + + monkeypatch.setattr(d, "huggingface_download", fake_huggingface_download) + monkeypatch.setattr( + d, + "_unpack_cache_dir_for_huggingface", + lambda cache_dir: {"cache_dir": cache_dir}, + ) + assert d.download_and_unpack(tag) == {"cache_dir": tag} + assert d.download(tag) == tag + assert seen == [tag, tag] + + def _fake_snapshot(root: Path): # The shape of a packed espnet model as huggingface_hub lays it out: a # meta.yaml naming the config and weights, a config whose paths are