| #!/usr/bin/env python3 | |
| """Merge code-tier download receipts (logs/code/downloads.jsonl) into sources.yaml under `code_sources:` | |
| (the hub part written by scripts/make_manifest.py is preserved). Records whether each raw file is still on disk.""" | |
| import json, os, yaml, datetime, collections | |
| ROOT = "/workspace/security-dataset"; IST = datetime.timezone(datetime.timedelta(hours=5, minutes=30)) | |
| Y = yaml.safe_load(open(f"{ROOT}/sources.yaml")) | |
| META = { | |
| "juliet_c": dict(name="NIST SARD Juliet Test Suite C/C++ 1.3 (#112)", license="Public domain (17 USC 105)", published="code (public)"), | |
| "crossvul": dict(name="CrossVul 2.0 (Zenodo 4734050)", license="CC-BY-4.0", published="code (public)"), | |
| "cvefixes": dict(name="CVEfixes v1.0.8 (Zenodo 13118970)", license="CC-BY-4.0 data / MIT code", published="code (public)"), | |
| "morefixes": dict(name="MoreFixes PostgreSQL dump 2026-06-20 (Zenodo 20776007)", license="CC-BY-4.0 (Zenodo record); tool MIT/Apache-2.0", published="code (public)"), | |
| "primevul": dict(name="PrimeVul paper release (Google Drive folder 19iLaNDS0z99N8kB_jBRTmDLehwZBolMY)", license="MIT", published="code (public)"), | |
| "bigvul": dict(name="Big-Vul / MSR'20 cleaned functions (Google Drive)", license="MIT", published="code (public)"), | |
| "draper_vdisc": dict(name="Draper VDISC (HF mirror claudios/Draper)", license="CC-BY-4.0", published="code (public)"), | |
| "diversevul": dict(name="DiverseVul 2023-07-02 (Google Drive)", license="none (no license file)", published="IDs/hashes/labels only"), | |
| "reposvul": dict(name="ReposVul (Google Drive, single JSONL)", license="none (no license file)", published="IDs/hashes/labels only"), | |
| "cleanvul": dict(name="CleanVul (HF yikun-li/CleanVul)", license="none (no license file)", published="IDs/hashes/labels only"), | |
| "devign": dict(name="Devign / CodeXGLUE defect detection (HF google/code_x_glue_cc_defect_detection)", license="C-UDA", published="IDs/hashes/labels only"), | |
| "megavul": dict(name="MegaVul 2024-04 release (OneDrive share https://1drv.ms/f/s!AtzrzuojQf5sgeISZ9zN_4owVnUn9g, manual browser download)", | |
| license="GPL-3.0", release="2024-04", published="code (public, GPL-3.0 folder code/gpl/megavul/ only; MegaVul-unique rows + overlap_map)"), | |
| } | |
| recs = collections.OrderedDict() | |
| for l in open(f"{ROOT}/logs/code/downloads.jsonl"): | |
| r = json.loads(l); recs[(r["dataset"], r.get("path") or r["url"])] = r # last record wins | |
| ok_ds = {ds for (ds, _), r in recs.items() if r.get("status") in ("ok", "truncated")} | |
| recs = collections.OrderedDict((k, r) for k, r in recs.items() if not (r.get("status") == "failed" and k[0] in ok_ds)) # superseded failures | |
| out = {} | |
| for (ds, _), r in recs.items(): | |
| e = out.setdefault(ds, dict(META.get(ds, {"name": ds}), files=[])) | |
| f = {k: r.get(k) for k in ("path", "version", "url", "gdrive_id", "hf_repo", "hf_revision", "size_bytes", "sha256", "md5_upstream", | |
| "md5_verified", "release", "downloaded_ist", "status", "error", "note") if r.get(k) is not None} | |
| if r.get("path"): f["on_disk"] = os.path.exists(f"{ROOT}/{r['path']}"); f["deleted_after_processing"] = not f["on_disk"] | |
| e["files"].append(f) | |
| for e in out.values(): e["total_bytes"] = sum(f.get("size_bytes", 0) for f in e["files"]) | |
| Y["code_sources"] = out; Y["code_manifest_generated_ist"] = datetime.datetime.now(IST).strftime("%Y-%m-%d %H:%M IST") | |
| yaml.safe_dump(Y, open(f"{ROOT}/sources.yaml", "w"), sort_keys=False, width=200, allow_unicode=True) | |
| print({k: (len(v["files"]), v["files"][0].get("status")) for k, v in out.items()}) | |
Xet Storage Details
- Size:
- 3.56 kB
- Xet hash:
- 9d5d5e22ab13910eccb4f01417a61e7bdc4c043b8af3c71e98b984fd1cfea2e7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.