StreamingOmniDatasets / builder /53_finalize_v042.py
skyzhou06's picture
Add files using upload-large-folder tool
165ed2c verified
Raw History Blame Contribute Delete
11.1 kB
#!/usr/bin/env python3
from __future__ import annotations
import hashlib
import json
import shutil
from collections import Counter
from pathlib import Path
import pyarrow.parquet as pq
ROOT = Path("/home/XuWenqi/ZhouZhifan/StreamingOmniDatasetsWork")
RC = ROOT / "release_candidates/v0.4.2-comprehensive-local-rc1"
REPORTS = ROOT / "reports"
ALIGN = ROOT / "alignment_candidates/external_api_deferred"
CONFIGS = ["single_turn_streaming", "context_multiturn_qa", "single_tool_calling"]
SPLITS = ["train", "eval"]
def sha(path: Path) -> str:
h = hashlib.sha256()
with path.open("rb") as f:
for block in iter(lambda: f.read(4 * 1024 * 1024), b""):
h.update(block)
return h.hexdigest()
def sha_text(value: str) -> str:
return hashlib.sha256(value.encode()).hexdigest()
def rewrite_checksums() -> None:
target = RC / "SHA256SUMS.txt"
entries = []
for path in sorted(RC.rglob("*")):
if path.is_file() and path != target:
entries.append(f"{sha(path)} {path.relative_to(RC)}")
target.write_text("\n".join(entries) + "\n")
def main() -> None:
acceptance = json.loads((REPORTS / "local_acceptance_v042.json").read_text())
dryrun = json.loads((REPORTS / "hf_publish_dry_run_v042.json").read_text())
if acceptance["result"] != "PASS" or dryrun["result"] != "PASS":
raise RuntimeError("Cannot finalize a failed acceptance or dry-run")
rows = []
counts = {}
for config in CONFIGS:
for split in SPLITS:
path = RC / f"data/{config}/{split}-00000-of-00001.parquet"
table = pq.read_table(path)
counts[f"{config}/{split}"] = table.num_rows
for row in table.to_pylist():
row["_config"] = config
rows.append(row)
manifest = json.loads((RC / "RELEASE_MANIFEST.json").read_text())
build = json.loads((REPORTS / "build_stats_v042.json").read_text())
opportunities = sum(1 for line in (ALIGN / "alignment_opportunities.jsonl").read_text().splitlines() if line.strip())
tool_rows = [r for r in rows if r["_config"] == "single_tool_calling"]
tool_verified = sum(r["tool_validation_status"] in {
"execution_verified", "replay_verified", "deterministic_replay_verified",
"fixture_replay_verified",
} for r in tool_rows)
synthetic = sum(
"synthetic" in r["data_origin"].lower()
or r["data_origin"].startswith("project_created")
or r["source_dataset"] in {"StreamingOmniDatasetsProjectScreens", "StreamingOmniDeterministicToolFixtures"}
for r in rows
)
real_or_transformed = len(rows) - synthetic
capabilities = Counter()
for row in rows:
capabilities.update(row["capabilities"])
multi_dependency = Counter(
r["context_dependency"] or "unspecified" for r in rows if r["_config"] == "context_multiturn_qa"
)
human_reviewed = sum(r["quality"]["human_reviewed"] for r in rows)
grade_a = sum(r["quality"]["grade"] == "A" for r in rows)
final_lines = [
"# Final v0.4.2 comprehensive report",
"",
"LOCAL COMPREHENSIVE RELEASE CANDIDATE: **PASS**",
"",
"HF PUBLICATION: **DISABLED / NOT EXECUTED**",
"",
"EXTERNAL API ALIGNMENT: **DEFERRED WITH MANIFEST**",
"",
"HUMAN REVIEW: **PENDING_HUMAN**",
"",
"FULL DUPLEX: **DEFERRED**",
"",
"## Release totals",
"",
f"- Accepted rows: {len(rows)} (v0.4.1: 11,635; net +{len(rows) - 11635})",
f"- Alignment-ready candidates: {opportunities}",
f"- Rejected/quarantine: {manifest['rejected_count']}",
f"- Media files: {manifest['media_count']}",
f"- Human-reviewed rows: {human_reviewed}",
f"- Grade A rows: {grade_a}",
"",
"## Config and split counts",
"",
*[f"- {key}: {value}" for key, value in sorted(counts.items())],
"",
"## Task distribution",
"",
*[f"- {key}: {value}" for key, value in manifest["task_distribution"].items()],
"",
"## Capability distribution",
"",
*[f"- {key}: {value}" for key, value in sorted(capabilities.items())],
"",
"## Language distribution",
"",
*[f"- {key}: {value}" for key, value in manifest["language_distribution"].items()],
"",
"## Streaming type distribution",
"",
*[f"- {key}: {value}" for key, value in manifest["streaming_type_distribution"].items()],
"",
"## Quality distribution",
"",
*[f"- {key}: {value}" for key, value in manifest["quality_distribution"].items()],
"",
"## Source and license distribution",
"",
*[f"- source `{key}`: {value}" for key, value in manifest.get("source_distribution", build["distributions"]["source"]).items()],
"",
*[f"- license `{key}`: {value}" for key, value in manifest["license_distribution"].items()],
"",
"## Real and synthetic",
"",
f"- Real/public or transformed-source rows: {real_or_transformed}",
f"- Project-created deterministic synthetic rows: {synthetic}",
f"- Synthetic proportion: {synthetic / len(rows):.2%}",
"",
"## Strong multi-turn dependency",
"",
*[f"- {key}: {value}" for key, value in sorted(multi_dependency.items())],
"",
"## Tool verification",
"",
f"- Execution/replay verified: {tool_verified}/{len(tool_rows)} ({tool_verified / len(tool_rows):.2%})",
"- Zero or one tool call only; no multi-tool agent loop was introduced.",
"",
"## Alignment",
"",
*[f"- accepted {key}: {value}" for key, value in manifest.get("alignment_tier_distribution", build["distributions"]["alignment_tier"]).items()],
f"- External-API opportunities: {opportunities}",
"- Opportunity types: proactive decision/grounded target and low-confidence speech word alignment.",
"- External requests, text sent, media sent, and fees incurred: 0.",
"",
"## Proactive and deferred work",
"",
"- 482 proactive records remain outside accepted Parquet pending reliable alignment or human confirmation.",
"- No proactive target, respond/silence decision, native-streaming label, A grade, or human approval was fabricated.",
"- Full duplex, barge-in, overlap policy, and assistant interruption remain explicitly deferred.",
"",
"## Acceptance evidence",
"",
f"- Full checks: {len(acceptance['checks'])}; blocking failures: {len(acceptance['blockers'])}",
f"- Stratified media decode: {acceptance['media_decode']['sampled']} decoded, {len(acceptance['media_decode']['failures'])} failures",
"- Confirmed benchmark leakage: 0",
"- Exact cross-split duplicate: 0",
"- Group/media leakage: 0",
"- Six split fresh-cache load: PASS",
"- Copy-to-fresh-directory load: PASS",
"- Five training recipe dry-runs: PASS",
"- HF packaging dry-run: PASS",
"- HF mutation count: 0",
"",
"## Remaining work",
"",
"- Human review of the new eval package remains pending; eval is not labeled gold.",
"- Deferred external alignment jobs require separate future authorization and license review.",
"- Native streaming remains 0; near-native source-timestamp supervision is present and reconstructed rows retain their original label.",
]
final_report = "\n".join(final_lines) + "\n"
(REPORTS / "FINAL_V042_COMPREHENSIVE_REPORT.md").write_text(final_report)
(REPORTS / "TOOL_EXECUTION_VALIDATION_V042.md").write_text(
"# Tool execution validation v0.4.2\n\n"
f"Execution/replay verified: {tool_verified}/{len(tool_rows)} "
f"({tool_verified / len(tool_rows):.2%}). Raw/normalized I/O, executor/fixture versions, "
"error states, and final-answer grounding outcomes are retained.\n"
)
reports_dir = RC / "reports"
reports_dir.mkdir(parents=True, exist_ok=True)
required = [
"V041_RC1_BASELINE_REAUDIT.md", "V042_GAP_ANALYSIS.md", "DATA_POOL_ACCOUNTING_V042.md",
"ALIGNMENT_DECISION_REPORT_V042.md", "TRANSLATION_EXPANSION_V042.md",
"TRANSLATION_LANGUAGE_BALANCE_V042.md", "MULTITURN_EXPANSION_V042.md",
"MULTITURN_DEPENDENCY_VALIDATION_V042.md", "RARE_CAPABILITY_EXPANSION_V042.md",
"PROACTIVE_CANDIDATE_STATUS_V042.md", "NATIVE_STREAMING_SOURCE_AUDIT_V042.md",
"STREAMING_TYPE_DISTRIBUTION_V042.md", "TOOL_EXPANSION_V042.md",
"TOOL_EXECUTION_VALIDATION_V042.md", "QUALITY_UPGRADE_V042.md", "LICENSE_AUDIT_V042.md",
"LICENSE_RECIPE_IMPACT_V042.md", "EVAL_REBUILD_V042.md", "BENCHMARK_LEAKAGE_V042.md",
"DEDUP_V042.md", "LOCAL_ACCEPTANCE_V042.md", "HF_PUBLISH_DRY_RUN_V042.md",
"FINAL_V042_COMPREHENSIVE_REPORT.md", "V042_HF_PUBLICATION_LOCK_AUDIT.md",
]
missing = [name for name in required if not (REPORTS / name).exists()]
if missing:
raise RuntimeError(f"Missing required reports: {missing}")
for name in required:
shutil.copy2(REPORTS / name, reports_dir / name)
for name in ["build_stats_v042.json", "alignment_tier_stats_v042.json", "local_acceptance_v042.json", "hf_publish_dry_run_v042.json"]:
shutil.copy2(REPORTS / name, reports_dir / name)
builder_dir = RC / "builder"
builder_dir.mkdir(parents=True, exist_ok=True)
for name in ["40_build_v042_comprehensive.py", "51_validate_v042_rc.py", "52_publish_dry_run_v042.py", "53_finalize_v042.py"]:
shutil.copy2(ROOT / "pipelines" / name, builder_dir / name)
content_entries = []
for path in sorted(RC.rglob("*")):
if path.is_file() and path.name not in {"RELEASE_MANIFEST.json", "SHA256SUMS.txt"}:
content_entries.append(f"{sha(path)} {path.relative_to(RC)}")
content_checksum = sha_text("\n".join(content_entries))
manifest["stable_rc_content_checksum"] = content_checksum
manifest["local_acceptance_status"] = "PASS"
manifest["publication_status"] = "local_only"
manifest["publish_allowed"] = False
manifest["hf_mutation_count"] = 0
manifest["human_review_status"] = "PENDING_HUMAN"
manifest["human_reviewed_rows"] = human_reviewed
manifest["external_api_alignment_status"] = "DEFERRED_WITH_MANIFEST"
manifest["full_duplex_status"] = "DEFERRED"
manifest["alignment_tier_distribution"] = build["distributions"]["alignment_tier"]
manifest["source_distribution"] = build["distributions"]["source"]
(RC / "RELEASE_MANIFEST.json").write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n")
rewrite_checksums()
print(json.dumps({
"status": "FINALIZED", "accepted_rows": len(rows), "alignment_ready": opportunities,
"checksum": content_checksum, "reports": len(required), "hf_mutations": 0,
}, sort_keys=True))
if __name__ == "__main__":
main()