Implement bounded S2 preparation and sealed pilot execution
This commit is contained in:
1 parent
fb827178ec
commit
f8a6ed3f81
35 files changed
+2626
No files matched your search
@@ -0,0 +1,52 @@
|
||||
"""Pilot label access is limited to an immutable non-test role manifest."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
from xml.etree import ElementTree as ET
|
||||
from zipfile import ZipFile
|
||||
import numpy as np
|
||||
from audit_samples import decode_array
|
||||
|
||||
|
||||
def permitted_role(manifest, case):
|
||||
if case in manifest['sealed_test_parts']:
|
||||
raise PermissionError('Outer test labels are sealed')
|
||||
if case in manifest['learning_parts']:return 'learning'
|
||||
if case in manifest['validation_parts']:return 'validation'
|
||||
raise PermissionError('Case absent from frozen non-test manifest')
|
||||
|
||||
|
||||
def read_non_test_fill_time(archive, case, raw_ids, manifest):
|
||||
# Must reject forbidden cases before opening the archive or any member.
|
||||
role=permitted_role(manifest,case)
|
||||
raw_ids=np.asarray(raw_ids)
|
||||
if raw_ids.ndim!=1 or raw_ids.dtype.kind not in 'iu' or len(raw_ids)==0 or np.any(np.diff(raw_ids)<=0):
|
||||
raise ValueError('Ascending original raw IDs required')
|
||||
stack=[];count=None;header=None
|
||||
with ZipFile(archive) as z,z.open(case+'_sim.vtu') as stream:
|
||||
for event,e in ET.iterparse(stream,events=('start','end')):
|
||||
if event=='start':
|
||||
stack.append(e.tag)
|
||||
if e.tag=='VTKFile':
|
||||
if e.get('byte_order')!='LittleEndian' or e.get('compressor')!='vtkZLibDataCompressor':raise ValueError('Unsupported encoding')
|
||||
header=e.get('header_type','UInt32')
|
||||
elif e.tag=='Piece':
|
||||
if count is not None:raise ValueError('Multiple VTU pieces')
|
||||
count=int(e.get('NumberOfPoints'))
|
||||
else:
|
||||
if e.tag=='DataArray':
|
||||
if stack[-2]=='PointData' and e.get('Name')=='Fill_time':
|
||||
values=decode_array(e,header)
|
||||
if values.shape!=(count,) or raw_ids[0]<0 or raw_ids[-1]>=count:raise ValueError('Fill_time size/original IDs mismatch')
|
||||
return values[raw_ids].copy(),dict(role=role,array_name='Fill_time',association='PointData',decoded_label_arrays=['Fill_time'],
|
||||
other_field_arrays_decoded=[],archive_member=case+'_sim.vtu',all_raw_nodes=count,retained_tet_nodes=len(raw_ids))
|
||||
e.clear()
|
||||
stack.pop()
|
||||
raise ValueError('PointData Fill_time missing')
|
||||
|
||||
|
||||
def validate_query_targets(fill_time, ids, eligible, t_set):
|
||||
selected=np.asarray(fill_time)[np.asarray(ids)[np.asarray(eligible,dtype=bool)]]
|
||||
if not len(selected):raise ValueError('No eligible common queries')
|
||||
if not np.isfinite(selected).all() or np.any(selected<0):raise ValueError('Invalid Fill_time on eligible common queries')
|
||||
if not np.isfinite(t_set) or t_set<=0:raise ValueError('Missing process setting')
|
||||
return selected/t_set
|
||||
Reference in new issue
Block a user