feat(convert): add task 05 sqlite converter with variant B keys" -m "- convert: convert_sqlite.py builds tribo.db (composite PKs, enforced FKs, Q1-Q7 indexes, track_summary)
- tools: common/track_summary.py fixes the cross-engine steady-state algorithm - rules: db-sql-schema records the FK enforcement decision and track_summary definition - specs: 05 aligned with data-naming-units, simtra_profiles added - docs: FK key-schema study added under docs/research/, README updated - replace manual CSV reading with CorpusReader for better data handling - streamline argument parsing and dependency checks using common pipeline functions - enhance marker writing for task completion tracking - remove unused regex and validation error classes for cleaner code
This commit is contained in:
@@ -8,16 +8,16 @@ completion marker. Spec: docs/specs/01_lab_configuration.md.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
from common.pipeline import parse_task_args, remove_stale_marker, write_marker
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent
|
||||
TASK_ID = "01"
|
||||
|
||||
# Transcription of docs/specs/01_lab_configuration.md. This literal is the
|
||||
@@ -301,51 +301,30 @@ def write_yaml(cfg: dict, config_path: Path) -> int:
|
||||
return len(text.encode("utf-8"))
|
||||
|
||||
|
||||
def write_marker(marker_path: Path, config_path: Path, config_bytes: int, cfg: dict) -> None:
|
||||
v = cfg["volumes"]
|
||||
f = cfg["friction_assignment"]
|
||||
h = cfg["hierarchy"]
|
||||
lines = [
|
||||
f"task: '{TASK_ID}'",
|
||||
"status: ok",
|
||||
f"config_file: {config_path.as_posix()}",
|
||||
f"config_bytes: {config_bytes}",
|
||||
f"seed: {cfg['seed']}",
|
||||
f"batches: {h['batches']}",
|
||||
f"wafers: {h['batches'] * h['wafers_per_batch']}",
|
||||
f"coupons: {v['coupons_total']}",
|
||||
f"friction_coupons: {f['friction_coupons_total']}",
|
||||
f"tracks: {v['tracks_total']}",
|
||||
f"cycle_rows: {v['cycle_rows_total']}",
|
||||
f"loop_points: {v['loop_points_total']}",
|
||||
f"xrf_points: {v['xrf_points_total']}",
|
||||
]
|
||||
marker_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(marker_path, "w", encoding="utf-8", newline="\n") as fh:
|
||||
fh.write("\n".join(lines) + "\n")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Task 01: write out/config/lab_config.yaml")
|
||||
parser.add_argument("--log-level", default="INFO", choices=["DEBUG", "INFO", "WARNING", "ERROR"])
|
||||
parser.add_argument("--out-root", type=Path, default=REPO_ROOT / "out", help="artifact tree root (default: ./out)")
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(
|
||||
level=args.log_level,
|
||||
stream=sys.stderr,
|
||||
format="%(asctime)s %(levelname)-7s %(name)s: %(message)s",
|
||||
)
|
||||
|
||||
args = parse_task_args("Task 01: write out/config/lab_config.yaml")
|
||||
out_root: Path = args.out_root
|
||||
config_path = out_root / "config" / "lab_config.yaml"
|
||||
marker_path = out_root / ".done" / f"{TASK_ID}.ok"
|
||||
try:
|
||||
if marker_path.exists():
|
||||
logger.info("re-run: removing stale marker %s", marker_path)
|
||||
marker_path.unlink()
|
||||
remove_stale_marker(out_root, TASK_ID)
|
||||
validate_config(LAB_CONFIG)
|
||||
config_bytes = write_yaml(LAB_CONFIG, config_path)
|
||||
write_marker(marker_path, config_path, config_bytes, LAB_CONFIG)
|
||||
v = LAB_CONFIG["volumes"]
|
||||
f = LAB_CONFIG["friction_assignment"]
|
||||
h = LAB_CONFIG["hierarchy"]
|
||||
marker_path = write_marker(out_root, TASK_ID, {
|
||||
"config_file": config_path.as_posix(),
|
||||
"config_bytes": config_bytes,
|
||||
"seed": LAB_CONFIG["seed"],
|
||||
"batches": h["batches"],
|
||||
"wafers": h["batches"] * h["wafers_per_batch"],
|
||||
"coupons": v["coupons_total"],
|
||||
"friction_coupons": f["friction_coupons_total"],
|
||||
"tracks": v["tracks_total"],
|
||||
"cycle_rows": v["cycle_rows_total"],
|
||||
"loop_points": v["loop_points_total"],
|
||||
"xrf_points": v["xrf_points_total"],
|
||||
})
|
||||
except Exception:
|
||||
logger.critical("task %s failed", TASK_ID, exc_info=True)
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user