diff --git a/pyproject.toml b/pyproject.toml index ba1a950f..074de360 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,8 +18,10 @@ classifiers = [ "Topic :: Scientific/Engineering :: Artificial Intelligence", ] # Harbor is pinned: task content hashes are computed with its packager, and the -# tasks target its configuration schema. huggingface-hub provides `hf download`. -dependencies = ["harbor==0.25.0", "huggingface-hub>=1.0"] +# tasks target its configuration schema. huggingface-hub provides `hf download`, +# whose command-line flags download.py builds; it stays on the 1.x CLI until a +# new major version is tested. +dependencies = ["harbor==0.25.0", "huggingface-hub>=1.0,<2"] [project.scripts] websitebench = "websitebench.cli:main" diff --git a/tests/test_download_tasks.py b/tests/test_download_tasks.py index de794f29..d80b8577 100644 --- a/tests/test_download_tasks.py +++ b/tests/test_download_tasks.py @@ -7,11 +7,13 @@ import io import json import shutil +import subprocess import tarfile import tempfile import tomllib import unittest from pathlib import Path +from unittest import mock from harbor.publisher.packager import Packager @@ -102,6 +104,35 @@ def test_packed_directory_is_restored_before_the_check(self): download.verify_task(self.task, entry) +class HuggingFaceCli(unittest.TestCase): + def test_hf_download_accepts_every_flag_fetch_hf_passes(self): + """The locked huggingface-hub CLI still takes the flags download.py builds.""" + commands = [] + with ( + tempfile.TemporaryDirectory() as staging, + mock.patch.object( + download.subprocess, + "run", + side_effect=lambda command, **_: commands.append(command), + ), + ): + index = {"hf_dataset": "org/data", "hf_revision": "main"} + index["tasks"] = {"sample": {}} + download.fetch_hf(index, ["sample"], Path(staging), None) + flags = {part for part in commands[0] if part.startswith("--")} + self.assertEqual( + flags, {"--repo-type", "--local-dir", "--revision", "--include"} + ) + usage = subprocess.run( + [commands[0][0], "download", "--help"], + capture_output=True, + text=True, + check=True, + ).stdout + for flag in sorted(flags): + self.assertIn(flag, usage) + + class ReleaseIndex(unittest.TestCase): def test_index_lists_exactly_the_repository_tasks(self): index = download.load_index() diff --git a/uv.lock b/uv.lock index 5e6e3b99..548a9c10 100644 --- a/uv.lock +++ b/uv.lock @@ -2112,7 +2112,7 @@ dev = [ [package.metadata] requires-dist = [ { name = "harbor", specifier = "==0.25.0" }, - { name = "huggingface-hub", specifier = ">=1.0" }, + { name = "huggingface-hub", specifier = ">=1.0,<2" }, ] [package.metadata.requires-dev]