Archive run and literature indexes with historical source provenance
This commit is contained in:
1 parent
036290bb23
commit
fc2d523129
159 files changed
+580873
-3
No files matched your search
@@ -0,0 +1,42 @@
|
||||
"""Operational checks only; synthetic child processes and generated arrays."""
|
||||
import json,sys,tempfile,unittest
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
from run_s1_fold import pack_tree,unpack_tree
|
||||
from supervise_s1_scoring import supervise
|
||||
|
||||
|
||||
class ExecutionTests(unittest.TestCase):
|
||||
def test_array_storage_roundtrip(self):
|
||||
data={('A',0):dict(a=np.array([0.,-0.,np.nan,np.inf]),x=np.arange(12).reshape(3,4),point=np.nan)}
|
||||
arrays={};structure=pack_tree(data,arrays)
|
||||
with tempfile.TemporaryDirectory(prefix='s1-packing-') as d:
|
||||
p=Path(d)/'arrays.npz';np.savez_compressed(p,**arrays)
|
||||
with np.load(p,allow_pickle=False) as loaded:restored=unpack_tree(json.loads(json.dumps(structure,allow_nan=False)),loaded)
|
||||
self.assertEqual(restored[('A',0)]['a'].tobytes(),data[('A',0)]['a'].tobytes())
|
||||
self.assertEqual(restored[('A',0)]['x'].tobytes(),data[('A',0)]['x'].tobytes())
|
||||
self.assertTrue(np.isnan(restored[('A',0)]['point']))
|
||||
|
||||
def test_supervisor_success_and_count_receipt(self):
|
||||
with tempfile.TemporaryDirectory(prefix='s1-supervisor-') as d:
|
||||
root=Path(d);result=root/'result.json'
|
||||
code="import json,resource,sys;json.dump(dict(status='COMPLETE',peak_rss_bytes=resource.getrusage(resource.RUSAGE_SELF).ru_maxrss*1024,logical_knn_queries=18,tie_radius_queries=18),open(sys.argv[1],'w'))"
|
||||
receipt=supervise([sys.executable,'-c',code,str(result)],root/'success',result,wall_limit=3,memory_limit=1342177280)
|
||||
self.assertEqual(receipt['status'],'PASS');self.assertEqual(receipt['logical_knn_queries'],18)
|
||||
self.assertTrue((root/'success.supervisor.json').exists())
|
||||
|
||||
def test_supervisor_wall_limit_preserves_receipt(self):
|
||||
with tempfile.TemporaryDirectory(prefix='s1-supervisor-') as d:
|
||||
root=Path(d);r=supervise([sys.executable,'-c','import time;time.sleep(10)'],root/'wall',root/'result.json',wall_limit=.12)
|
||||
self.assertEqual(r['status'],'FAIL');self.assertEqual(r['stop_reason'],'wall_budget_exceeded')
|
||||
self.assertIsNone(r['logical_knn_queries']);self.assertLess(r['wall_seconds'],3)
|
||||
self.assertTrue((root/'wall.monitor.jsonl').exists())
|
||||
|
||||
def test_supervisor_memory_limit_preserves_receipt(self):
|
||||
with tempfile.TemporaryDirectory(prefix='s1-supervisor-') as d:
|
||||
root=Path(d);r=supervise([sys.executable,'-c','import time;x=bytearray(80*1024*1024);time.sleep(10)'],root/'memory',root/'result.json',wall_limit=3,memory_limit=32*1024*1024)
|
||||
self.assertEqual(r['status'],'FAIL');self.assertEqual(r['stop_reason'],'memory_budget_exceeded')
|
||||
self.assertGreater(r['peak_rss_bytes'],32*1024*1024);self.assertIsNotNone(r['trigger'])
|
||||
|
||||
|
||||
if __name__=='__main__':unittest.main(verbosity=2)
|
||||
Reference in new issue
Block a user