feat: reserve queue capacity for recent models

This commit is contained in:
CoolBoy
2026-08-11 01:29:54 +08:00
parent 38ab25fc3c
commit f12d96b138
13 changed files with 927 additions and 46 deletions

46
tests/test_poll_policy.py Normal file
View File

@@ -0,0 +1,46 @@
from __future__ import annotations
import argparse
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 poll_runner import resolve_age_cleanup_policy # noqa: E402
class PollPolicyTests(unittest.TestCase):
def test_age_cleanup_uses_eighty_once_then_ninety_five(self) -> None:
args = argparse.Namespace(
old_model_queue_threshold=80,
dynamic_old_model_cleanup_threshold=95,
)
self.assertEqual(
("initial", 80),
resolve_age_cleanup_policy(args, initial_cleanup_pending=True),
)
self.assertEqual(
("dynamic", 95),
resolve_age_cleanup_policy(args, initial_cleanup_pending=False),
)
def test_dynamic_cleanup_cannot_be_stricter_than_admission(self) -> None:
args = argparse.Namespace(
old_model_queue_threshold=80,
dynamic_old_model_cleanup_threshold=70,
)
self.assertEqual(
("dynamic", 80),
resolve_age_cleanup_policy(args, initial_cleanup_pending=False),
)
if __name__ == "__main__":
unittest.main()