File size: 1,966 Bytes
1ef5660
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Check downloaded release artifacts using only Python's standard library."""
from pathlib import Path
from html.parser import HTMLParser
from urllib.parse import urlsplit,unquote
import hashlib,json
ROOT=Path(__file__).resolve().parents[1]
def local(path):
 p=(ROOT/path).resolve()
 if not p.is_relative_to(ROOT):raise ValueError('Path outside release: '+path)
 return p
manifest=json.loads((ROOT/'release_manifest.json').read_text())
for item in manifest['files']:
 p=local(item['path']);assert p.is_file(),item['path']
 assert p.stat().st_size==item['bytes'],item['path']
 with p.open('rb') as f:
  digest=hashlib.file_digest(f,'sha256').hexdigest() if hasattr(hashlib,'file_digest') else hashlib.sha256(f.read()).hexdigest()
 assert digest==item['sha256'],item['path']
record=json.loads((ROOT/'examples/baseball_swing.json').read_text())
assert record['split']=='case-study'
assert record['timing']['frame_count']==52 and record['timing']['fps']==30
for path in record['artifacts'].values():assert local(path).is_file(),path
with local(record['artifacts']['animated_fbx']).open('rb') as f:assert f.read(23)==b'Kaydara FBX Binary  \x00\x1a\x00'
class Links(HTMLParser):
 def __init__(self):super().__init__();self.paths=[];self.ids=[];self.fragments=[]
 def handle_starttag(self,tag,attrs):
  d=dict(attrs)
  if 'id' in d:self.ids.append(d['id'])
  for name in ['href','src','poster']:
   u=urlsplit(d.get(name,''))
   if u.scheme or u.netloc:continue
   if u.path:self.paths.append(unquote(u.path))
   elif u.fragment:self.fragments.append(u.fragment)
p=Links();p.feed((ROOT/'whitepaper/index.html').read_text())
for path in p.paths:assert local('whitepaper/'+path).is_file(),path
assert len(p.ids)==len(set(p.ids))
assert all(x in p.ids for x in p.fragments)
print(f"Verified {len(manifest['files'])} release files, the FBX header, example record and local paper links.")
print('Integrity check only; this does not execute reconstruction or model inference.')