Bootstrap architecture rules from task history
This commit is contained in:
@@ -15,10 +15,61 @@ if str(PACKAGE_DIR) in sys.path:
|
||||
sys.path.insert(0, str(PACKAGE_DIR))
|
||||
|
||||
from outcome_tracker import OutcomeTracker # noqa: E402
|
||||
from poll_runner import _load_task_compatibility_contexts, resolve_age_cleanup_policy # noqa: E402
|
||||
from poll_runner import ( # noqa: E402
|
||||
_bootstrap_architecture_history,
|
||||
_load_task_compatibility_contexts,
|
||||
resolve_age_cleanup_policy,
|
||||
)
|
||||
|
||||
|
||||
class PollPolicyTests(unittest.TestCase):
|
||||
def test_architecture_bootstrap_falls_back_when_public_logs_are_hidden(self) -> None:
|
||||
class HistoryClient:
|
||||
@staticmethod
|
||||
def list_tasks_page(**_kwargs): # noqa: ANN003
|
||||
return {
|
||||
"data": {
|
||||
"records": [
|
||||
{
|
||||
"taskId": "public-failure",
|
||||
"modelId": "public/model",
|
||||
"gpuType": "gpu",
|
||||
"status": "success",
|
||||
"verifyResult": -1,
|
||||
"logCosUrl": None,
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def list_tasks(**_kwargs): # noqa: ANN003
|
||||
return [
|
||||
{
|
||||
"taskId": "owned-success",
|
||||
"modelId": "owner/model",
|
||||
"gpuType": "gpu",
|
||||
"modelTaskLevelId": 23,
|
||||
"status": "success",
|
||||
"verifyResult": 1,
|
||||
"updateTime": datetime.now(timezone.utc).isoformat(),
|
||||
}
|
||||
]
|
||||
|
||||
with tempfile.TemporaryDirectory() as temporary_dir:
|
||||
root = Path(temporary_dir)
|
||||
tracker = OutcomeTracker(root / "outcomes.jsonl")
|
||||
summary = _bootstrap_architecture_history(
|
||||
modelhub_client=HistoryClient(), # type: ignore[arg-type]
|
||||
outcome_tracker=tracker,
|
||||
ledger_path=root / "ledger.jsonl",
|
||||
now=datetime.now(timezone.utc),
|
||||
)
|
||||
|
||||
self.assertEqual("owned_full_history", summary["source"])
|
||||
self.assertEqual(1, summary["terminalRecords"])
|
||||
self.assertEqual(0, summary["communityUsableFailureDetails"])
|
||||
|
||||
def test_cleanup_contexts_merge_outcomes_with_older_ledger_entries(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temporary_dir:
|
||||
root = Path(temporary_dir)
|
||||
|
||||
Reference in New Issue
Block a user