Download scripts/verify_remote.py from pranay5255/agent-trajectory-study-20260930: direct link, hf CLI and curl.
- Browser
- Download file 3.45 kB
-
https://huggingface.co/datasets/pranay5255/agent-trajectory-study-20260930/resolve/main/scripts/verify_remote.py
- Command line
-
hf download hf://datasets/pranay5255/agent-trajectory-study-20260930/scripts/verify_remote.py
-
curl -L -o verify_remote.py https://huggingface.co/datasets/pranay5255/agent-trajectory-study-20260930/resolve/main/scripts/verify_remote.py
3.45 kB
| """Verify anonymous repository access, configurations, and all artifact hashes.""" | |
| import hashlib | |
| import json | |
| import os | |
| from pathlib import Path | |
| import subprocess | |
| import sys | |
| os.environ["HF_HUB_DISABLE_IMPLICIT_TOKEN"] = "1" | |
| os.environ["HF_HOME"] = "/tmp/trajectory_remote_verify_hf" | |
| os.environ.pop("HF_TOKEN", None) | |
| import pandas as pd | |
| from huggingface_hub import HfApi | |
| from datasets import get_dataset_config_names, load_dataset | |
| def main(): | |
| root = Path(__file__).resolve().parents[1] | |
| repo = "pranay5255/agent-trajectory-study-20260930" | |
| api = HfApi(token=False) | |
| info = api.dataset_info(repo) | |
| assert info.private is False and not info.gated | |
| revision = info.sha | |
| files = {f.path:f for f in api.list_repo_tree(repo, repo_type="dataset", revision=revision, recursive=True) if hasattr(f,"size")} | |
| manifest = json.loads((root / "provenance/publication_manifest.json").read_text()) | |
| checked = 0 | |
| for artifact in manifest["files"]: | |
| remote = files[artifact["path"]] | |
| assert remote.size == artifact["bytes"], artifact["path"] | |
| if remote.lfs: | |
| assert remote.lfs.sha256 == artifact["sha256"], artifact["path"] | |
| else: | |
| data = (root / artifact["path"]).read_bytes() | |
| git_hash = hashlib.sha1(f"blob {len(data)}\0".encode()+data).hexdigest() | |
| assert remote.blob_id == git_hash, artifact["path"] | |
| checked += 1 | |
| configs = get_dataset_config_names(repo, revision=revision, token=False) | |
| expected = {"olmo","qwen","forest","olmo_events","qwen_events","forest_events","annotations","examples","example_summary","sources","coverage","forest_joins","token_diagnostics","redactions","q09_transitions","qwen27b_summary_only","usage_events"} | |
| assert set(configs) == expected, configs | |
| splits = {} | |
| for config in sorted(configs): | |
| dataset = load_dataset(repo, config, revision=revision, token=False, streaming=True) | |
| splits[config] = list(dataset) | |
| for name, split in dataset.items(): | |
| first = next(iter(split)) | |
| assert isinstance(first,dict) and first | |
| print(f"Anonymous configuration verified: {config}", flush=True) | |
| target = Path("/tmp/trajectory_anonymous_downloads") | |
| downloads = ["trajectory_eda_colab.ipynb","data/olmo.parquet","data/qwen.parquet","data/forest.parquet"] | |
| sample = pd.read_parquet(root / "data/qwen.parquet").sort_values("events").iloc[-1] | |
| downloads.append(sample.detail_path) | |
| subprocess.run([sys.executable,"-m","huggingface_hub.cli.hf","download",repo,*downloads, | |
| "--repo-type","dataset","--revision",revision,"--local-dir",str(target),"--quiet"], check=True) | |
| lookup = {a["path"]:a for a in manifest["files"]} | |
| for name in downloads: | |
| assert hashlib.sha256((target/name).read_bytes()).hexdigest() == lookup[name]["sha256"] | |
| counts = {c:len(pd.read_parquet(target/f"data/{c}.parquet")) for c in ["olmo","qwen","forest"]} | |
| assert counts == {"olmo":570,"qwen":510,"forest":371} | |
| report = {"status":"passed","repository":repo,"verified_revision":revision,"public":True,"anonymous":True, | |
| "artifact_hashes_verified":checked,"configurations":splits,"episode_counts":counts, | |
| "anonymous_cli_downloads":downloads} | |
| (root / "provenance/remote_verification.json").write_text(json.dumps(report,indent=2)+"\n") | |
| print(json.dumps(report,indent=2)) | |
| if __name__ == "__main__": | |
| main() | |