feat: dynamically clean incompatible architectures
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@@ -11,10 +14,48 @@ 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
|
||||
from outcome_tracker import OutcomeTracker # noqa: E402
|
||||
from poll_runner import _load_task_compatibility_contexts, resolve_age_cleanup_policy # noqa: E402
|
||||
|
||||
|
||||
class PollPolicyTests(unittest.TestCase):
|
||||
def test_cleanup_contexts_merge_outcomes_with_older_ledger_entries(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temporary_dir:
|
||||
root = Path(temporary_dir)
|
||||
tracker = OutcomeTracker(root / "outcomes.jsonl")
|
||||
tracker.record_submission(
|
||||
"owner/new",
|
||||
"gpu-a",
|
||||
"vllm",
|
||||
"text-generation",
|
||||
"task-new",
|
||||
datetime.now(timezone.utc).isoformat(),
|
||||
model_profile={"architectures": ["Qwen2ForCausalLM"]},
|
||||
)
|
||||
ledger_path = root / "ledger.jsonl"
|
||||
ledger_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"taskId": "task-old",
|
||||
"modelId": "owner/old",
|
||||
"targetGpu": "gpu-b",
|
||||
"framework": "mindie",
|
||||
"taskType": "text-generation",
|
||||
}
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
contexts = _load_task_compatibility_contexts(
|
||||
tracker,
|
||||
ledger_path=ledger_path,
|
||||
)
|
||||
|
||||
self.assertEqual(["Qwen2ForCausalLM"], contexts["task-new"]["modelProfile"]["architectures"])
|
||||
self.assertEqual("mindie", contexts["task-old"]["framework"])
|
||||
self.assertEqual({}, contexts["task-old"]["modelProfile"])
|
||||
|
||||
def test_age_cleanup_uses_minus_ten_once_then_minus_five(self) -> None:
|
||||
args = argparse.Namespace(
|
||||
recent_model_reserve_slots=10,
|
||||
|
||||
Reference in New Issue
Block a user