Files
cdsl-cad/cadfs_to_cdsl/run_full_rebuild.sh
T
likang 738934416e feat(cadfs): 扩展重建引擎能力并固化代表性模型回归
- 扩展 CDSL engine 的 shell、sweep、loft、reference plane、pattern 等运行时能力,
  支持新的实体结果模式、双向拉伸、曲线扫掠、镜像/圆周阵列及相关 selector 解析。
- 完善 Build123d 适配层的拓扑快照、Compound/ShapeList 兼容处理和旋转曲面识别,
  兼容 Python 3.12 / 当前 Build123d 缺少 axis_of_rotation 的合法曲面场景。
- 扩展 CDSL schema、profile schema、capability analysis、semantic validation 和
  sketch solver,使新增建模操作能够被校验、执行并保留可诊断的部分结果。
- 完善 CADFS FeatureScript lowering:
  支持 shell、sweep、surface/实体 loft、圆周阵列副本、镜像副本、删除阵列实例、
  新 body 操作、更多拉伸终止条件和 reference plane 变体。
- 补齐椭圆、B-spline、环形区域、imprint、SWEPT_FACE、CAP_FACE、OFFSET_FACE 等
  草图和拓扑引用的转换逻辑,改善后续特征的工作平面、轴线和 profile 定位精度。
- 改进 selector binding:支持 pattern 前缀复合 B-rep 快照、交集顶点引用、
  多面 match_mode=all、圆柱轴线/半径和面积下限等稳定匹配条件。
- 修复 MID_PLANE 法向统一后交线方向未同步的问题,恢复 00287955 基准面的正确位置;
  修复 00542223 sweep 路径反转后的切线契约和 00423838 的拓扑面数不稳定测试假设。
- 修正 CADFS 比较模块 import 路径,补充重建报告、批量重建脚本、目标文档和 README。
- 新增并扩展 engine、lowering、parser、selector binding、reports、integration 和
  Onshape pipeline 回归测试,覆盖代表性 CADFS 特征链及运行时兼容性。
2026-09-08 11:47:10 +08:00

136 lines
4.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run the complete CADFS corpus while retaining a snapshot of the prior run.
set -Eeuo pipefail
ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
INPUT_DIR="${ROOT_DIR}/data/cadfs-sample/CADFS_test"
OUTPUT_DIR="${ROOT_DIR}/cadfs_to_cdsl/output"
HISTORY_DIR="${ROOT_DIR}/cadfs_to_cdsl/output-history"
WORKERS=4
TIMEOUT_SECONDS=60
COMPARE_MODE=rp
FORCE=true
usage() {
cat <<'EOF'
Usage: ./cadfs_to_cdsl/run_full_rebuild.sh [options]
Runs conversion, CDSL rebuild, STEP comparison, and the Markdown report for
every sample in data/cadfs-sample/CADFS_test.
By default the existing cadfs_to_cdsl/output directory is moved to
cadfs_to_cdsl/output-history/<timestamp>/ before a forced full rerun.
Options:
--resume Reuse cached results in output; do not archive or force rerun.
--workers N Concurrent samples (1-8, default: 4).
--timeout-seconds N Per-model rebuild timeout in seconds (default: 60).
--compare-mode rp|strict Comparison acceptance mode (default: rp).
-h, --help Show this help message.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--resume)
FORCE=false
shift
;;
--workers)
[[ $# -ge 2 ]] || { echo "--workers requires a value" >&2; exit 2; }
WORKERS="$2"
shift 2
;;
--timeout-seconds)
[[ $# -ge 2 ]] || { echo "--timeout-seconds requires a value" >&2; exit 2; }
TIMEOUT_SECONDS="$2"
shift 2
;;
--compare-mode)
[[ $# -ge 2 ]] || { echo "--compare-mode requires a value" >&2; exit 2; }
COMPARE_MODE="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 2
;;
esac
done
[[ "$WORKERS" =~ ^[1-8]$ ]] || { echo "--workers must be an integer between 1 and 8" >&2; exit 2; }
[[ "$TIMEOUT_SECONDS" =~ ^[0-9]+([.][0-9]+)?$ ]] && (( $(awk "BEGIN { print (${TIMEOUT_SECONDS} > 0) }") )) || {
echo "--timeout-seconds must be positive" >&2
exit 2
}
[[ "$COMPARE_MODE" == "rp" || "$COMPARE_MODE" == "strict" ]] || {
echo "--compare-mode must be rp or strict" >&2
exit 2
}
[[ -d "$INPUT_DIR" ]] || { echo "CADFS input directory not found: $INPUT_DIR" >&2; exit 1; }
[[ -f "$INPUT_DIR/CADFS_text_test.jsonl" ]] || { echo "CADFS text manifest not found: $INPUT_DIR/CADFS_text_test.jsonl" >&2; exit 1; }
if [[ -x "${ROOT_DIR}/backend/.venv/bin/python" ]]; then
PYTHON_BIN="${PYTHON_BIN:-${ROOT_DIR}/backend/.venv/bin/python}"
else
PYTHON_BIN="${PYTHON_BIN:-python3}"
fi
command -v "$PYTHON_BIN" >/dev/null 2>&1 || { echo "Python executable not found: $PYTHON_BIN" >&2; exit 1; }
archive_output() {
[[ -d "$OUTPUT_DIR" ]] || return
[[ -n "$(find "$OUTPUT_DIR" -mindepth 1 -maxdepth 1 -print -quit)" ]] || return
mkdir -p "$HISTORY_DIR"
local timestamp archive_dir suffix=1
timestamp="$(date +%Y%m%d-%H%M%S)"
archive_dir="${HISTORY_DIR}/${timestamp}"
while [[ -e "$archive_dir" ]]; do
archive_dir="${HISTORY_DIR}/${timestamp}-${suffix}"
((suffix += 1))
done
mv "$OUTPUT_DIR" "$archive_dir"
echo "Previous output archived at: $archive_dir"
}
on_error() {
local code=$?
echo "Run stopped with exit code ${code}. Partial artifacts remain in: $OUTPUT_DIR" >&2
exit "$code"
}
trap on_error ERR
if [[ "$FORCE" == true ]]; then
archive_output
echo "Starting forced full corpus rebuild."
else
echo "Resuming existing full corpus rebuild without archiving output."
fi
mkdir -p "$OUTPUT_DIR"
cd "$ROOT_DIR"
pipeline_args=(
pipeline
--input "$INPUT_DIR"
--output "$OUTPUT_DIR"
--workers "$WORKERS"
--timeout-seconds "$TIMEOUT_SECONDS"
--compare-mode "$COMPARE_MODE"
)
if [[ "$FORCE" == true ]]; then
pipeline_args+=(--force)
fi
PYTHONPATH="${ROOT_DIR}/backend:${ROOT_DIR}${PYTHONPATH:+:${PYTHONPATH}}" \
"$PYTHON_BIN" -m cadfs_to_cdsl "${pipeline_args[@]}"
PYTHONPATH="${ROOT_DIR}/backend:${ROOT_DIR}${PYTHONPATH:+:${PYTHONPATH}}" \
"$PYTHON_BIN" -m cadfs_to_cdsl report --input "$INPUT_DIR" --output "$OUTPUT_DIR" --markdown
echo "Current results: $OUTPUT_DIR"
echo "Full report: $OUTPUT_DIR/full_run_report.md"