"""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}'") # trackio.init() also drops an empty dashboard cell on whichever page was # last active; the bundle run logs no metrics, so it renders as noise. 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