Download scripts/verify_release.py from Eurus132/ExtFoamBench: direct link, hf CLI and curl.
- Browser
- Download file 4.08 kB
-
https://huggingface.co/datasets/Eurus132/ExtFoamBench/resolve/main/scripts/verify_release.py
- Command line
-
hf download hf://datasets/Eurus132/ExtFoamBench/scripts/verify_release.py
-
curl -L -o verify_release.py https://huggingface.co/datasets/Eurus132/ExtFoamBench/resolve/main/scripts/verify_release.py
4.08 kB
| """Verify integrity, task projection, references and geometry; no solver runs.""" | |
| import argparse | |
| import hashlib | |
| import json | |
| import zipfile | |
| from pathlib import Path | |
| ROOT=Path(__file__).resolve().parents[1] | |
| def read(p):return json.loads(p.read_text(encoding='utf-8')) | |
| def require(ok,message): | |
| if not ok:raise ValueError(message) | |
| def verify(root): | |
| bundle=zipfile.ZipFile(root/'tools/evaluation-tools.zip') | |
| require(bundle.testzip() is None, 'Corrupt optional tool archive') | |
| def content(rel): | |
| local=root/rel | |
| return local.read_bytes() if local.is_file() else bundle.read(rel) | |
| def document(rel): | |
| return json.loads(content(rel).decode('utf-8-sig')) | |
| paths=set() | |
| for line in (root/'SHA256SUMS').read_text(encoding='utf-8').splitlines(): | |
| digest,rel=line.split(' ',1);p=(root/rel).resolve() | |
| require(p.is_relative_to(root.resolve()),f'Unsafe checksum path: {rel}') | |
| require(p.is_file(),f'Missing file: {rel}') | |
| require(hashlib.sha256(p.read_bytes()).hexdigest()==digest,f'Checksum mismatch: {rel}') | |
| require(rel not in paths,f'Duplicate checksum path: {rel}');paths.add(rel) | |
| source=read(root/'metadata/source_manifest.json') | |
| for row in source['files']: | |
| require(hashlib.sha256(content(row['path'])).hexdigest()==row['sha256'],f'Source drift: {row["path"]}') | |
| coverage=read(root/'metadata/coverage.json');all_ids=set() | |
| for track,expected in [('extended',100),('basic',110),('advanced',16)]: | |
| profile=document(f'benchmarks/evaluation/profiles/{track}.json') | |
| tasks=read(root/profile['benchmark_path']);refs=read(root/profile['reference_qois_path'])['cases'];stats=read(root/f'benchmarks/reference_statistics/{track}.json')['cases'] | |
| rows=[json.loads(line) for line in (root/f'data/{track}.jsonl').read_text(encoding='utf-8').splitlines()] | |
| require(len(rows)==len(tasks)==expected,f'Count mismatch: {track}') | |
| require(set(tasks)==set(refs)==set(stats)=={r['case_id'] for r in rows},f'Membership mismatch: {track}') | |
| for row in rows: | |
| cid=row['case_id'];require(row['task_id']==f'{track}:{cid}' and row['task_id'] not in all_ids,'Task ID collision');all_ids.add(row['task_id']) | |
| require(row['usr_requirement']==tasks[cid]['usr_requirement'],f'Prompt drift: {cid}') | |
| require(row['track']==track and row['family']==cid.split('/')[0],f'Metadata mismatch: {cid}') | |
| origin='ExtFoamBench (EasyFoam authors)' if track=='extended' else 'FoamBench (upstream; adapted for OpenFOAM 13)' | |
| require(row['task_origin']==origin,f'Attribution mismatch: {cid}') | |
| require(row['external_asset_ids']==[a['asset_id'] for a in tasks[cid].get('_external_assets',[])],f'Asset ID drift: {cid}') | |
| for metric in refs[cid].get('principal_metrics',[]): | |
| require(metric in refs[cid].get('qois',{}) and metric in refs[cid].get('tolerances',{}),f'Missing metric contract: {cid}/{metric}') | |
| require(sorted(k for k,v in stats.items() if not v)==coverage[track]['missing_numerical_statistics_case_ids'],f'Coverage drift: {track}') | |
| specs=read(root/'benchmarks/extended_measurement_specs.json') | |
| require(set(specs['cases'])==set(read(root/'benchmarks/extended_cases.json')),'Measurement membership drift') | |
| assets=read(root/'benchmarks/assets/manifest.json')['assets'] | |
| for asset_id,row in assets.items(): | |
| require(hashlib.sha256(content(row['path'])).hexdigest()==row['sha256'],f'Geometry mismatch: {asset_id}') | |
| return {'status':'pass','tasks':len(all_ids),'copied_source_files':len(source['files']),'checksum_files':len(paths),'geometry_assets':len(assets)} | |
| def main(): | |
| parser=argparse.ArgumentParser(description=__doc__);parser.add_argument('--root',type=Path,default=ROOT);args=parser.parse_args() | |
| try:print(json.dumps(verify(args.root.resolve()),indent=2)) | |
| except (OSError,ValueError,KeyError) as exc:parser.exit(1,f'Verification failed: {exc}\n') | |
| if __name__=='__main__':main() | |