Add Control v2 incremental experiment results (evidence, visuals, 42 fixed samples)
a64600b verified Download method_v2/evidence/code/packaging/package_method_v2.py from CharlesZhang-USTC/snf_experiments: direct link, hf CLI and curl.
- Browser
- Download file 2.43 kB
-
https://huggingface.co/CharlesZhang-USTC/snf_experiments/resolve/main/method_v2/evidence/code/packaging/package_method_v2.py
- Command line
-
hf download hf://CharlesZhang-USTC/snf_experiments/method_v2/evidence/code/packaging/package_method_v2.py
-
curl -L -o package_method_v2.py https://huggingface.co/CharlesZhang-USTC/snf_experiments/resolve/main/method_v2/evidence/code/packaging/package_method_v2.py
2.43 kB
| """Package the method-v2 overlay; reuse the original image and model weights.""" | |
| import hashlib | |
| import json | |
| import zipfile | |
| from pathlib import Path | |
| def main(): | |
| root = Path(__file__).resolve().parents[1] | |
| destination = root / 'artifacts/snf-method-v2-addon.zip' | |
| paths = list((root / 'suite').rglob('*')) | |
| paths += list((root / 'packaging').glob('*')) | |
| paths += [root / 'AGENT_RUNBOOK_METHOD_V2.md', | |
| root / 'docs/METHOD_V2_补方法与实验说明.md', | |
| root / 'experiments/replay_calibration_v2.py', | |
| root / 'artifacts/method_v2_local/validation.json'] | |
| for folder in ('null', 'retrospective'): | |
| paths += list((root / 'artifacts/method_v2_local' / folder).rglob('*')) | |
| paths = sorted({p for p in paths if p.is_file() | |
| and '__pycache__' not in p.parts and p.suffix != '.pyc'}) | |
| manifest = {} | |
| destination.parent.mkdir(parents=True, exist_ok=True) | |
| with zipfile.ZipFile(destination, 'w', zipfile.ZIP_DEFLATED, compresslevel=6) as archive: | |
| for path in paths: | |
| name = 'snf-method-v2/' + path.relative_to(root).as_posix() | |
| payload = path.read_bytes() | |
| manifest[name] = hashlib.sha256(payload).hexdigest() | |
| archive.writestr(name, payload) | |
| archive.writestr('snf-method-v2/MANIFEST.json', json.dumps({ | |
| 'type': 'overlay_for_existing_snf_cuda128_image', | |
| 'includes_weights': False, | |
| 'includes_vendor_or_runtime': False, | |
| 'new_gpu_method_validation': 'pending', | |
| 'files_sha256': manifest, | |
| }, ensure_ascii=False, indent=2)) | |
| with zipfile.ZipFile(destination) as archive: | |
| bad = archive.testzip() | |
| if bad: | |
| raise RuntimeError(f'Archive integrity failure: {bad}') | |
| for name, digest in manifest.items(): | |
| if hashlib.sha256(archive.read(name)).hexdigest() != digest: | |
| raise RuntimeError(f'Content hash mismatch: {name}') | |
| digest = hashlib.sha256(destination.read_bytes()).hexdigest() | |
| destination.with_suffix('.zip.sha256').write_text( | |
| digest + ' ' + destination.name + '\n', encoding='utf8') | |
| print(json.dumps({'archive': str(destination), 'files': len(manifest), | |
| 'size_mib': destination.stat().st_size / 2**20, | |
| 'sha256': digest}, ensure_ascii=False, indent=2)) | |
| if __name__ == '__main__': | |
| main() | |