File size: 2,426 Bytes
8bc8906
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Fetch only public pinned sources for a fresh reproduction workspace; zero paid services."""
from pathlib import Path
import hashlib,json,shutil,urllib.request
from huggingface_hub import snapshot_download
ROOT=Path(__file__).resolve().parents[1]
INPUTS=[('Giuliocc/windtunnel-response-data','dataset','c9f07d8ffef1a26564d7b2c30f75914534dc265a'),('Giuliocc/windtunnel-ces-cross-wave','dataset','aaad117e1fdc8ff76eedf283dc1fe931dfce756c'),('Giuliocc/windtunnel-response-baseline','model','07f15115e2876e8a37de739c0574fb104b99995b'),('Giuliocc/windtunnel-response-encoder','model','29973d528b804d3c6564243b96410325f9d62b0b'),('Giuliocc/windtunnel-response-cross-wave','model','d99510bb67dbc729b48c1633cf382cc415264907')]
for repo,kind,revision in INPUTS:snapshot_download(repo,repo_type=kind,revision=revision,local_dir=ROOT/'inputs'/repo.split('/')[-1])
snapshot_download('sentence-transformers/all-MiniLM-L6-v2',revision='1110a243fdf4706b3f48f1d95db1a4f5529b4d41',allow_patterns=['config.json','model.safetensors','special_tokens_map.json','tokenizer.json','tokenizer_config.json','vocab.txt'],local_dir=ROOT/'base')
source24=json.loads((ROOT/'inputs/windtunnel-response-data/reproduction/configs/sources.json').read_text());source22=json.loads((ROOT/'inputs/windtunnel-ces-cross-wave/evaluation.json').read_text())['sources'][0]
raw=ROOT/'raw';raw.mkdir(exist_ok=True)
for tag,source in [('ces24',source24),('ces22',source22)]:
 for name,(fileid,expected) in source['files'].items():
  target=raw/('ces22-'+name if tag=='ces22' and name!='ces22.csv' else name)
  def digest(p):
   with p.open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
  if target.exists() and digest(target)==expected:continue
  part=target.with_suffix(target.suffix+'.part');request=urllib.request.Request(f'https://dataverse.harvard.edu/api/access/datafile/{fileid}',headers={'User-Agent':'Windtunnel research reproducibility/0.2'})
  with urllib.request.urlopen(request,timeout=60) as stream,part.open('wb') as out:shutil.copyfileobj(stream,out,1024*1024)
  if digest(part)!=expected:part.unlink();raise ValueError('Official source checksum mismatch: '+name)
  part.replace(target)
if not (ROOT/'input_inventory.json').exists():
 (ROOT/'input_inventory.json').write_text(json.dumps([{'repo':r,'repo_type':k,'revision':v} for r,k,v in INPUTS],indent=2)+'\n')
print('Public inputs verified. Raw respondent records must remain local.')