47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
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_minus_ten_once_then_minus_five(self) -> None:
|
|
args = argparse.Namespace(
|
|
recent_model_reserve_slots=10,
|
|
dynamic_old_model_cleanup_reserve_slots=5,
|
|
)
|
|
|
|
self.assertEqual(
|
|
("initial", 10),
|
|
resolve_age_cleanup_policy(args, initial_cleanup_pending=True),
|
|
)
|
|
self.assertEqual(
|
|
("dynamic", 5),
|
|
resolve_age_cleanup_policy(args, initial_cleanup_pending=False),
|
|
)
|
|
|
|
def test_dynamic_cleanup_cannot_be_stricter_than_initial_cleanup(self) -> None:
|
|
args = argparse.Namespace(
|
|
recent_model_reserve_slots=10,
|
|
dynamic_old_model_cleanup_reserve_slots=20,
|
|
)
|
|
|
|
self.assertEqual(
|
|
("dynamic", 10),
|
|
resolve_age_cleanup_policy(args, initial_cleanup_pending=False),
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|