Files

84 lines
5.0 KiB
Python

"""컷·연결·새 버전 미디어와 실제 실행 증거를 검사한다."""
import hashlib
import json
from pathlib import Path
import jsonschema
ROOT=Path(__file__).resolve().parents[3]
PROJECT=ROOT/'projects/water-hydrogen-bond-surface-tension'
def read(path):
return json.loads(path.read_text(encoding='utf-8'))
if __name__=='__main__':
a=read(PROJECT/'stages/08-scenes/r3/artifact.json')
b=read(PROJECT/'stages/09-entities/r3/artifact.json')
schema=read(ROOT/'contracts/artifact.schema.json')
jsonschema.validate(a,schema)
jsonschema.validate(b,schema)
assert a["revision"]==b["revision"]==3
assert {"stage_id":"08-scenes","revision":3} in b["inputs"]
cuts=read(PROJECT/'stages/07-cuts/r1/artifact.json')['payload']
ids=[c['id'] for c in cuts['cuts']]
assert len(ids)==31 and len(cuts['captions'])==38 and cuts['narration_duration_ms']==110560
assert cuts['cuts'][0]['start_ms']==0 and cuts['cuts'][-1]['end_ms']==110560
assert all(0<c['end_ms']-c['start_ms']<=5000 for c in cuts['cuts'])
assert all(x['end_ms']==y['start_ms'] for x,y in zip(cuts['cuts'],cuts['cuts'][1:]))
scenes=a['payload']['scenes']
connections=a['payload']['connections']
assert [s['cut_id'] for s in scenes]==ids and len(connections)==30
assert [(c['from_cut_id'],c['to_cut_id']) for c in connections]==list(zip(ids,ids[1:]))
for left,right,connection in zip(scenes,scenes[1:],connections):
if connection['mode']=='continuous':
assert left['end_state']==right['start_state']
assert left['camera']==right['camera']
else:
assert left['start_state'].split(';')[0]!=right['start_state'].split(';')[0]
assert b['payload']['characters']==[]
assert [p['cut_id'] for p in b['payload']['appearances']]==ids
bg={g['id'] for g in b['payload']['backgrounds']}
assert all(not p['character_ids'] and set(p['background_ids'])<=bg for p in b['payload']['appearances'])
preview=a['payload']['preview']
source=preview['scene_file']
assert source['verified'] and hashlib.sha256((ROOT/source['path']).read_bytes()).hexdigest()==source['sha256']
assert (ROOT/source['path']).is_relative_to(PROJECT/'stages/08-scenes/r3')
model=read(PROJECT/'stages/08-scenes/r3/model-check.json')
assert model['source_sha256']==source['sha256']
containment=model['water_containment']
assert containment['frames']==705 and containment['logical_frame_start']==2468 and containment['logical_frame_end']==3172
assert min(containment['minimum_axis_margin'])>=.03 and containment['minimum_projected_margin_px']>0
samples=preview['samples']
assert len(samples)==6 and len({s['id'] for s in samples})==6
assets=[dict(path=source['path'],sha256=source['sha256'])]
frame_reviews=[]
for sample in samples:
media=sample['media']
path=ROOT/media['path']
assert path.is_relative_to(PROJECT/'stages/08-scenes/r3') and media['verified']
evidence_path=path.parent/'evidence.json'
evidence=read(evidence_path)
assert evidence['media']==media and evidence['scene_file']==source and evidence['render_profile']==preview['render_profile']
assert (media['width'],media['height'])==(1080,1920)
if media['kind']=='video':
cut=next(c for c in cuts['cuts'] if c['id']==sample['cut_ids'][0])
assert media['duration_ms']==cut['end_ms']-cut['start_ms']
assert evidence['logical_frames']==list(range(cut['start_ms']//20,cut['end_ms']//20))
for frame in (evidence['logical_frames'][0],evidence['logical_frames'][len(evidence['logical_frames'])//2],evidence['logical_frames'][-1]):
f=path.parent/f'frame-{frame:08}.png'
frame_reviews.append(f.relative_to(ROOT).as_posix())
assets.append(dict(path=f.relative_to(ROOT).as_posix(),sha256=hashlib.sha256(f.read_bytes()).hexdigest()))
for f in (path,evidence_path):
assets.append(dict(path=f.relative_to(ROOT).as_posix(),sha256=hashlib.sha256(f.read_bytes()).hexdigest()))
result=dict(result='GREEN',cuts=31,captions=38,connections=30,total_ms=110560,fps=50,total_frames=5528,profile=preview['render_profile'],source_sha256=source['sha256'],samples=6,visual_review_frames=frame_reviews,actual_assets=assets,scenes_approval='pending',formal_10_12='not_started')
motion=read(PROJECT/'stages/08-scenes/r3/motion-check.json')
assert motion['source_sha256']==source['sha256'] and len(motion['views'])==3
for view in motion['views']:
assert all(change>0 for change in view['mean_absolute_pixel_change'])
path=ROOT/view['mobile_view_path']
assert hashlib.sha256(path.read_bytes()).hexdigest()==view['mobile_view_sha256']
assets.append(dict(path=view['mobile_view_path'],sha256=view['mobile_view_sha256']))
(PROJECT/'stages/08-scenes/r3/design-check.json').write_text(json.dumps(result,ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
print('DESIGN_GREEN: 31 cuts, 30 boundaries, 38 captions, 6 actual samples')