Implement the frozen F3 protocol, nested LOWO, posterior label banks, ablations, diagnostics, checkpoint validation and full-volume inference. Record the negative G-C result: improvement at 1/4 wells, coverage80 52.38% and coverage90 60.91%, with unchanged thresholds and historical P2 results. Add native Windows logging, the RTX 3060 environment lock, detached runs, and an audited dashboard-lock recovery that preserves frozen scientific code. Update report.html, the plan and agent guidance with completed P3 status. Archive thesis sources under code_thesis with identical Git blobs and record the original-output audit without committing large data or model artifacts. Validation: 129 tests passed, 13 skipped; CUDA end-to-end smoke passed; completion audit verified 1,320 checkpoint/prediction pairs, 28 registration bundles and all 649 interior volume inlines. Scripts 04 and 09 were not rerun. Co-authored-by: Codex <codex@openai.com>
86 lines
3.5 KiB
Python
86 lines
3.5 KiB
Python
"""Write a SHA-256 manifest for a dataset and check it against the committed manifest.
|
|
|
|
python scripts/00_data_manifest.py # create/update the F3 manifest
|
|
python scripts/00_data_manifest.py --check # check only; exit 1 on mismatch
|
|
python scripts/00_data_manifest.py --dataset volve # same for data/Volve
|
|
python scripts/00_data_manifest.py --dataset nlog # same for data/NLOG
|
|
python scripts/00_data_manifest.py --dataset thesis # same for outputs_thesis
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
import sys
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
|
|
from ml_porosity.paths import REPO_ROOT, f3_root, nlog_root, volve_root
|
|
|
|
DATASETS = {
|
|
"f3": (f3_root, "f3_demo_2023.json", "F3 Demo 2023 (dGB Earth Sciences / TerraNubis), CC BY-SA 3.0"),
|
|
"volve": (volve_root, "volve.json", "Volve data village (Equinor), HRS licence / CC BY-NC-SA 4.0"),
|
|
"nlog": (nlog_root, "nlog.json", "NLOG (TNO), public LAS and TD data for the F3 wells; URLs in docs/research/f3-nlog-inventory.xlsx"),
|
|
"thesis": (lambda: REPO_ROOT / "outputs_thesis", "thesis_outputs.json", "Thesis outputs archived in outputs_thesis; source code in code_thesis"),
|
|
}
|
|
|
|
|
|
def sha256(path: Path, chunk: int = 1 << 22) -> str:
|
|
h = hashlib.sha256()
|
|
with path.open("rb") as f:
|
|
while block := f.read(chunk):
|
|
h.update(block)
|
|
return h.hexdigest()
|
|
|
|
|
|
def scan(root: Path) -> dict[str, dict]:
|
|
files = sorted(p for p in root.rglob("*") if p.is_file())
|
|
with ThreadPoolExecutor(max_workers=8) as ex:
|
|
digests = list(ex.map(sha256, files))
|
|
return {
|
|
p.relative_to(root).as_posix(): {"size_bytes": p.stat().st_size, "sha256": d}
|
|
for p, d in zip(files, digests)
|
|
}
|
|
|
|
|
|
def main() -> int:
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--check", action="store_true")
|
|
ap.add_argument("--dataset", choices=sorted(DATASETS), default="f3")
|
|
args = ap.parse_args()
|
|
|
|
root_fn, manifest_name, description = DATASETS[args.dataset]
|
|
manifest = REPO_ROOT / "data_manifest" / manifest_name
|
|
root = root_fn()
|
|
current = scan(root)
|
|
|
|
if args.check:
|
|
ref = json.loads(manifest.read_text(encoding="utf-8"))["files"]
|
|
missing = sorted(set(ref) - set(current))
|
|
changed = sorted(k for k in set(ref) & set(current) if ref[k]["sha256"] != current[k]["sha256"])
|
|
extra = sorted(set(current) - set(ref))
|
|
for name, items in (("missing", missing), ("hash mismatch", changed), ("extra", extra)):
|
|
for k in items:
|
|
print(f"{name}: {k}")
|
|
print(f"{len(current)} files, {len(missing)} missing, {len(changed)} hash mismatch, {len(extra)} extra")
|
|
return 1 if (missing or changed) else 0
|
|
|
|
out = {
|
|
"dataset": description,
|
|
"root": root.relative_to(REPO_ROOT).as_posix() if root.is_relative_to(REPO_ROOT) else str(root),
|
|
"created_utc": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
|
"n_files": len(current),
|
|
"total_bytes": sum(v["size_bytes"] for v in current.values()),
|
|
"files": current,
|
|
}
|
|
manifest.parent.mkdir(parents=True, exist_ok=True)
|
|
manifest.write_text(json.dumps(out, indent=1, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
print(f"{out['n_files']} file, {out['total_bytes'] / 1e9:.2f} GB -> {manifest.relative_to(REPO_ROOT)}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|