Archived
Honor GINO day reservation at new dispatch and preserve running guard
This commit is contained in:
1 parent
9a4f8563ee
commit
8af022e434
7 files changed
+953
-13
No files matched your search
@@ -37,6 +37,7 @@ class GuardReplay(unittest.TestCase):
|
||||
stopped = []
|
||||
real_stop = gpu_guard.stop_group
|
||||
real_tree = gpu_guard.process_tree
|
||||
ticket = dict(ordinal='', dispatch_before_unix=time.time() + 15)
|
||||
|
||||
def stop_owned(pid):
|
||||
stopped.append(pid)
|
||||
@@ -64,12 +65,16 @@ class GuardReplay(unittest.TestCase):
|
||||
raise AssertionError(card)
|
||||
spawn = root / 'actual-worker-spawn.json'
|
||||
if not spawn.exists():
|
||||
if ordering == 'expired-before-spawn':
|
||||
ticket['dispatch_before_unix'] = time.time() - 1
|
||||
return dict(idle=True, occupants=[], unix=10., memory_MiB=0)
|
||||
observed.append('gpu-sample')
|
||||
pid = os.getpid() if ordering == 'foreign' else read(spawn)['process']['pid']
|
||||
sample = dict(idle=False, unix=42.125, memory_MiB=4,
|
||||
occupants=[dict(pid=pid, process_name='fixture-python', memory_MiB='4')])
|
||||
if ordering == 'gpu-first':
|
||||
if ordering == 'crossed-after-spawn':
|
||||
ticket['dispatch_before_unix'] = time.time() - 1
|
||||
if ordering in ('gpu-first', 'crossed-after-spawn'):
|
||||
exit_and_wait()
|
||||
return sample
|
||||
|
||||
@@ -80,8 +85,14 @@ class GuardReplay(unittest.TestCase):
|
||||
patch.object(gpu_guard, 'dispatch_environment',
|
||||
side_effect=lambda _, env: (dict(env, CUDA_VISIBLE_DEVICES=''), []))):
|
||||
began = time.monotonic()
|
||||
ticket['guard_started_monotonic'] = began
|
||||
outcome = gpu_guard.guard(root, command, uuid=uuid, limits=limit, deadline=began + 15,
|
||||
ticket=dict(ordinal='', guard_started_monotonic=began), validate_result=lambda: sha(result))
|
||||
ticket=ticket, validate_result=lambda: sha(result))
|
||||
if ordering == 'expired-before-spawn':
|
||||
self.assertEqual(outcome['status'], 'STOPPED')
|
||||
self.assertEqual(outcome['trigger'], 'CARD_RESERVATION_EXPIRED_BEFORE_SPAWN')
|
||||
self.assertFalse((root / 'actual-worker-spawn.json').exists())
|
||||
return observed
|
||||
spawn = read(root / 'actual-worker-spawn.json')['process']
|
||||
if ordering == 'foreign':
|
||||
self.assertEqual(outcome['status'], 'STOPPED')
|
||||
@@ -110,6 +121,12 @@ class GuardReplay(unittest.TestCase):
|
||||
def test_real_foreign_identity_has_exact_stop_receipt(self):
|
||||
self.replay('foreign')
|
||||
|
||||
def test_reservation_expires_after_idle_but_before_spawn(self):
|
||||
self.replay('expired-before-spawn')
|
||||
|
||||
def test_running_guard_continues_after_reservation_end(self):
|
||||
self.replay('crossed-after-spawn')
|
||||
|
||||
def test_reused_worker_pid_is_foreign(self):
|
||||
with TemporaryDirectory() as folder:
|
||||
root = Path(folder)
|
||||
@@ -193,11 +210,11 @@ class FormalBinding(unittest.TestCase):
|
||||
budgets = binding['budget_per_seed_stage_gpu_seconds']
|
||||
self.assertEqual(sum(sum(b.values()) for b in budgets.values()), 40000)
|
||||
self.assertEqual(binding['device_pci_ordinals'], {'0': 2, '1': 3, '2': 0})
|
||||
latest = formal.RESERVATION_END.timestamp() - 300
|
||||
formal.check_reservation(latest - 1, 300)
|
||||
for when in (latest, formal.RESERVATION_END.timestamp(), formal.RESERVATION_START.timestamp() - 1):
|
||||
end = formal.RESERVATION_END.timestamp()
|
||||
formal.check_reservation(end - 1)
|
||||
for when in (end, formal.RESERVATION_START.timestamp() - 1):
|
||||
with self.assertRaises(PermissionError):
|
||||
formal.check_reservation(when, 300)
|
||||
formal.check_reservation(when)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in new issue
Block a user