fix: respect ModelScope model page limit
This commit is contained in:
@@ -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
|
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
|
is retained and the runner immediately draws replacement candidates from the
|
||||||
same scan instead of retrying the duplicate every cycle. Startup logs and 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.
|
this behavior.
|
||||||
|
|
||||||
## Deploy
|
## Deploy
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ class HuggingFaceDiscovery:
|
|||||||
min_downloads: int,
|
min_downloads: int,
|
||||||
updated_after=None,
|
updated_after=None,
|
||||||
) -> list[HFModelSummary]:
|
) -> 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)
|
max_items = min(max(1, limit), 3000)
|
||||||
task_tag = MODELSCOPE_TASK_TAGS.get(pipeline_tag, pipeline_tag)
|
task_tag = MODELSCOPE_TASK_TAGS.get(pipeline_tag, pipeline_tag)
|
||||||
models: list[HFModelSummary] = []
|
models: list[HFModelSummary] = []
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
AGENT_VERSION = "2026.08.02.1"
|
AGENT_VERSION = "2026.08.02.2"
|
||||||
|
|||||||
41
tests/test_modelscope_discovery.py
Normal file
41
tests/test_modelscope_discovery.py
Normal file
@@ -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()
|
||||||
Reference in New Issue
Block a user