feat(commands): multi-select ordered command pipeline with step reordering and single-pass composition (AI-05, AI-07)
This commit is contained in:
parent
f49acf0105
commit
10af20a0ad
157 changed files with 29455 additions and 913 deletions
30
apps/desktop/sidecar/tests/test_cpu_budget.py
Normal file
30
apps/desktop/sidecar/tests/test_cpu_budget.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""Scheduling headroom, including small PCs and restricted process CPU capacity."""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
import cpu_budget
|
||||
|
||||
|
||||
class CpuBudgetTest(unittest.TestCase):
|
||||
def test_reserves_headroom_and_caps_workers(self) -> None:
|
||||
for cpus, expected in [(1, 1), (2, 1), (3, 1), (4, 2), (6, 4), (8, 4), (16, 4), (64, 4)]:
|
||||
with self.subTest(cpus=cpus):
|
||||
self.assertEqual(cpu_budget.inference_cpu_threads(cpus), expected)
|
||||
|
||||
def test_unknown_capacity_uses_one_worker(self) -> None:
|
||||
for cpus in (None, 0, -1):
|
||||
with self.subTest(cpus=cpus):
|
||||
self.assertEqual(cpu_budget.inference_cpu_threads(cpus), 1)
|
||||
|
||||
def test_prefers_process_capacity_when_available(self) -> None:
|
||||
with mock.patch.object(cpu_budget.os, "process_cpu_count", return_value=4, create=True):
|
||||
with mock.patch.object(cpu_budget.os, "cpu_count", return_value=64):
|
||||
self.assertEqual(cpu_budget.local_inference_cpu_threads(), 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue