Download explore/PhaseLatch/scripts/pull_pl01_artifacts.py from Travor278/RheoBench: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/datasets/Travor278/RheoBench/resolve/main/explore/PhaseLatch/scripts/pull_pl01_artifacts.py
- Command line
-
hf download hf://datasets/Travor278/RheoBench/explore/PhaseLatch/scripts/pull_pl01_artifacts.py
-
curl -L -o pull_pl01_artifacts.py https://huggingface.co/datasets/Travor278/RheoBench/resolve/main/explore/PhaseLatch/scripts/pull_pl01_artifacts.py
2.85 kB
| """Read-only, checksum-verified transfer using legacy SCP for this Tailscale SSH gateway.""" | |
| import argparse | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| import shlex | |
| import subprocess | |
| import time | |
| FILES={ | |
| "runtime_pins.json":"runtime_pins.json", | |
| "results/validation_v0/summary.json":"validation_summary.json", | |
| "results/final_reference/report.json":"reference_report.json", | |
| "results/final_reference/start.png":"start.png", | |
| "results/final_reference/final.png":"final.png", | |
| "results/final_reference/episode.mp4":"episode.mp4", | |
| } | |
| REMOTE_ROOT="/home/travor/rpent-data/runs/phaselatch" | |
| def digest(path): | |
| return hashlib.sha256(path.read_bytes()).hexdigest() | |
| def main(): | |
| parser=argparse.ArgumentParser() | |
| parser.add_argument("--host",default="travor@<TAILNET_IP>") | |
| args=parser.parse_args() | |
| output=Path(__file__).resolve().parents[1]/"results/pl01" | |
| output.mkdir(parents=True,exist_ok=True) | |
| remote=("import json,hashlib; from pathlib import Path; root=Path("+repr(REMOTE_ROOT)+ | |
| "); files="+repr(FILES)+"; print(json.dumps({n:{'bytes':(root/n).stat().st_size,'sha256':hashlib.sha256((root/n).read_bytes()).hexdigest()} for n in files}))") | |
| command="python3 -c "+shlex.quote(remote) | |
| for attempt in range(3): | |
| try: | |
| details=json.loads(subprocess.check_output(["ssh","-o","BatchMode=yes","-o","ConnectTimeout=20",args.host,command],timeout=90)) | |
| break | |
| except (subprocess.CalledProcessError,subprocess.TimeoutExpired): | |
| if attempt==2: | |
| raise | |
| time.sleep(1) | |
| saved={} | |
| for source,name in FILES.items(): | |
| target=output/name | |
| expected=details[source] | |
| if not target.exists() or digest(target)!=expected['sha256']: | |
| temporary=target.with_suffix(target.suffix+'.part') | |
| print('Receiving',name,expected['bytes'],'bytes',flush=True) | |
| for attempt in range(3): | |
| try: | |
| subprocess.run(["scp","-O","-o","BatchMode=yes","-o","ConnectTimeout=20", | |
| f"{args.host}:{REMOTE_ROOT}/{source}",str(temporary)],check=True,timeout=300) | |
| if temporary.stat().st_size!=expected['bytes'] or digest(temporary)!=expected['sha256']: | |
| raise ValueError('Artifact checksum mismatch') | |
| temporary.replace(target) | |
| break | |
| except (subprocess.CalledProcessError,subprocess.TimeoutExpired): | |
| if attempt==2: | |
| raise | |
| time.sleep(1) | |
| saved[name]={**expected,'remote_path':source} | |
| print('Verified',name,flush=True) | |
| (output/'artifact_manifest.json').write_text(json.dumps(saved,indent=2)+'\n',encoding='utf-8') | |
| if __name__=='__main__': | |
| main() | |