| """Assemble the reproduction bundle and register it as a Trackio artifact.""" |
| from __future__ import annotations |
|
|
| import argparse |
| import json |
| import os |
| import shutil |
|
|
| EXCLUDE_DIRS = {"__pycache__", ".venv", ".cache", ".git", "node_modules"} |
| EXCLUDE_FILES = {".env", "ICML_token.txt"} |
|
|
|
|
| def copy_tree(src, dst): |
| os.makedirs(dst, exist_ok=True) |
| n = 0 |
| for root, dirs, files in os.walk(src): |
| dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS] |
| rel = os.path.relpath(root, src) |
| target = os.path.join(dst, rel) if rel != "." else dst |
| os.makedirs(target, exist_ok=True) |
| for f in files: |
| if f in EXCLUDE_FILES or f.endswith((".pyc", ".pt")): |
| continue |
| shutil.copy2(os.path.join(root, f), os.path.join(target, f)) |
| n += 1 |
| return n |
|
|
|
|
| def prune_dashboard_page(root, project): |
| import shutil as sh |
| pages = os.path.join(root, ".trackio", "logbook", "pages") |
| page_dir = os.path.join(pages, project) |
| if os.path.isdir(page_dir): |
| sh.rmtree(page_dir) |
| print(f"removed stray sidebar page '{project}'") |
| |
| |
| for page in ("executive-summary", "conclusion"): |
| page_md = os.path.join(pages, page, "page.md") |
| if os.path.isfile(page_md): |
| import re as _re |
| with open(page_md, encoding="utf-8") as f: |
| text = f.read() |
| chunks = _re.split(r"(?=\n---\n<!-- trackio-cell)", text) |
| kept_chunks = [c for c in chunks if '"type": "dashboard"' not in c] |
| if len(kept_chunks) != len(chunks): |
| with open(page_md, "w", encoding="utf-8") as f: |
| f.write("".join(kept_chunks).rstrip() + "\n") |
| print(f"removed stray dashboard cell from '{page}'") |
|
|
| index = os.path.join(pages, "index.md") |
| if os.path.isfile(index): |
| with open(index, encoding="utf-8") as f: |
| lines = f.readlines() |
| kept = [l for l in lines if f"(#/{project})" not in l] |
| if len(kept) != len(lines): |
| with open(index, "w", encoding="utf-8") as f: |
| f.writelines(kept) |
| print("removed its row from the index Pages table") |
|
|
|
|
| if __name__ == "__main__": |
| ap = argparse.ArgumentParser() |
| ap.add_argument("--root", default=os.path.expanduser("~/repro_spectral_flow_matching")) |
| ap.add_argument("--bundle", default=None) |
| ap.add_argument("--project", default="repro-spectral-flow-matching-stabilizing-stochastic-gflownets-via-frequency-domain-regularizatio") |
| args = ap.parse_args() |
| bundle = args.bundle or os.path.join(args.root, "repro_bundle") |
|
|
| if os.path.exists(bundle): |
| shutil.rmtree(bundle) |
| total = 0 |
| for sub in ["src", "outputs", "figures", "poster"]: |
| s = os.path.join(args.root, sub) |
| if os.path.isdir(s): |
| total += copy_tree(s, os.path.join(bundle, sub)) |
| for f in ["paper.md", "README_code.md"]: |
| p = os.path.join(args.root, f) |
| if os.path.exists(p): |
| shutil.copy2(p, os.path.join(bundle, f)) |
| total += 1 |
|
|
| manifest = { |
| "paper": "Spectral Flow Matching: Stabilizing Stochastic GFlowNets via Frequency-Domain Regularization", |
| "openreview_id": "QQRCqb2PDj", |
| "contents": { |
| "src/": "reimplementation: envs, ST-GFN + 10 baselines, analysis, diagnostics", |
| "outputs/": "raw per-run JSON (metrics + training curves), summary tables, diagnostics", |
| "figures/": "Plotly HTML figures with their raw CSV data", |
| "poster/": "posterly poster source, rendered PNG/PDF, poster_embed.html", |
| "paper.md": "OCR transcript of the paper used for the reimplementation", |
| }, |
| "n_files": total, |
| } |
| with open(os.path.join(bundle, "MANIFEST.json"), "w") as f: |
| json.dump(manifest, f, indent=2) |
| print(f"bundle at {bundle} with {total} files") |
|
|
| try: |
| import trackio |
| trackio.init(project=args.project, name="repro-bundle", resume="allow") |
| trackio.log_artifact(bundle, name="repro-bundle", type="dataset") |
| trackio.finish() |
| print("registered trackio artifact 'repro-bundle'") |
| except Exception as exc: |
| print(f"trackio artifact registration skipped/failed: {type(exc).__name__}: {exc}") |
|
|
| |
| |
| |
| prune_dashboard_page(args.root, args.project) |
|
|
|
|