diff --git a/README.md b/README.md index f5ced5da..049337a4 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ authority for account capacity and model/GPU uniqueness. If the platform reports that a model/GPU is already being validated, the claim is retained and the runner immediately draws replacement candidates from the same scan instead of retrying the duplicate every cycle. Startup logs and the -health response expose `agent_version`; version `2026.08.02.1` or newer includes +health response expose `agent_version`; version `2026.08.02.2` or newer includes this behavior. ## Deploy diff --git a/modelhub_submmit_api/hf_discovery.py b/modelhub_submmit_api/hf_discovery.py index d7cddb46..1ed73c5c 100644 --- a/modelhub_submmit_api/hf_discovery.py +++ b/modelhub_submmit_api/hf_discovery.py @@ -105,7 +105,8 @@ class HuggingFaceDiscovery: min_downloads: int, updated_after=None, ) -> list[HFModelSummary]: - page_size = min(max(1, limit), 100) + # ModelScope OpenAPI rejects values above 50 with InputParameterError. + page_size = min(max(1, limit), 50) max_items = min(max(1, limit), 3000) task_tag = MODELSCOPE_TASK_TAGS.get(pipeline_tag, pipeline_tag) models: list[HFModelSummary] = [] diff --git a/modelhub_submmit_api/version.py b/modelhub_submmit_api/version.py index 06caf026..78403870 100644 --- a/modelhub_submmit_api/version.py +++ b/modelhub_submmit_api/version.py @@ -1 +1 @@ -AGENT_VERSION = "2026.08.02.1" +AGENT_VERSION = "2026.08.02.2" diff --git a/tests/test_modelscope_discovery.py b/tests/test_modelscope_discovery.py new file mode 100644 index 00000000..31953e43 --- /dev/null +++ b/tests/test_modelscope_discovery.py @@ -0,0 +1,41 @@ +from __future__ import annotations + +import sys +import unittest +from pathlib import Path + + +PACKAGE_DIR = Path(__file__).resolve().parents[1] / "modelhub_submmit_api" +if str(PACKAGE_DIR) in sys.path: + sys.path.remove(str(PACKAGE_DIR)) +sys.path.insert(0, str(PACKAGE_DIR)) + +from hf_discovery import HuggingFaceDiscovery # noqa: E402 + + +class RecordingHttpClient: + def __init__(self) -> None: + self.queries: list[dict] = [] + + def request_json(self, _method: str, _path: str, *, query: dict) -> dict: + self.queries.append(query) + return {"success": True, "data": {"models": []}} + + +class ModelScopeDiscoveryTests(unittest.TestCase): + def test_openapi_page_size_never_exceeds_platform_limit(self) -> None: + http_client = RecordingHttpClient() + discovery = HuggingFaceDiscovery(http_client=http_client) # type: ignore[arg-type] + + models = discovery.list_recent_models( + pipeline_tags=["text-generation"], + limit=1000, + min_downloads=0, + ) + + self.assertEqual([], models) + self.assertEqual(50, http_client.queries[0]["page_size"]) + + +if __name__ == "__main__": + unittest.main()