app
AI Flow
Public Made by Adomby adom
Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board.
main
John Lauer
Publish 0.2.19
81ffca7
#!/usr/bin/env bash
# adom-aiflow-etch: the MPN laser mark, placed by construction (see SKILL: Marking checklist).
# adom-aiflow-etch --in part.step --mpn MPN --out part-etched.step [--footprint part.kicad_mod]
# adom-aiflow-etch plan part.step [--footprint fp.kicad_mod] [--mpn MPN] [--face top|side|auto] [--json out.json]
# adom-aiflow-etch check part-etched.step [--outline name.svg] [--footprint fp.kicad_mod] [--plan x.mark-plan.json]
# adom-aiflow-etch outline part.step [--etched part-etched.step] [--mode auto|etched|composed] [--lines "A|B"] [--plan x.mark-plan.json] [--footprint fp.kicad_mod] [--mpn MPN] [--out-dir DIR]
# (etched: the name is the etched model's own mark edges; composed: the service's font on the planned band; auto: etched when it reads and passes)
# adom-aiflow-etch test --step part.step --footprint fp.kicad_mod --mpn MPN --out-dir DIR (gate self-test)
# The planner, the etch, the gate and the outline run on the shared STEP service (service-step2glb) with
# plain python3: no OpenCascade, no install. `--legacy` runs the previous OpenCascade etch (etch_part_occ.py),
# which needs the lightweight cadquery-ocp-novtk venv (about 0.4 GB, asks first: AIFLOW_ALLOW_LOCAL_OCC=1).
set -euo pipefail
HERE="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)"
PY="${AIFLOW_PYTHON:-python3}"
case "${1:-}" in
plan) shift; exec "$PY" "$HERE/mark_plan.py" "$@" ;;
check) shift; exec "$PY" "$HERE/mark_check.py" "$@" ;;
outline) shift; exec "$PY" "$HERE/mark_outline.py" "$@" ;;
test) shift; exec "$PY" "$HERE/test_mark_gate.py" "$@" ;;
version|--version) echo "adom-aiflow-etch (adom-aiflow $(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' "$HERE/../../package.json" | head -1))"; exit 0 ;;
-h|--help|help|"")
sed -n '2,11p' "$0" | sed 's/^# \{0,1\}//'
echo
"$PY" "$HERE/mark_etch.py" --help
exit 0 ;;
esac
for a in "$@"; do
if [ "$a" = "--legacy" ]; then
args=(); for b in "$@"; do [ "$b" = "--legacy" ] || args+=("$b"); done
VENV="${AIFLOW_OCC_VENV:-$HOME/.local/share/adom-aiflow/occ}"
if [ ! -x "$VENV/bin/python" ] || ! "$VENV/bin/python" -c "import OCP" 2>/dev/null; then
if [ "${AIFLOW_ALLOW_LOCAL_OCC:-}" != "1" ]; then
echo "ERROR: --legacy needs OpenCascade (OCP) locally, the lightweight cadquery-ocp-novtk build (about 0.4 GB)." >&2
echo "Hint: drop --legacy: the default etch runs on the shared service and needs nothing installed. With the user's OK: AIFLOW_ALLOW_LOCAL_OCC=1 adom-aiflow-etch --legacy ... (venv at $VENV)." >&2
exit 2
fi
echo "adom-aiflow-etch: setting up OCP (cadquery-ocp-novtk, about 0.4 GB) in $VENV once; delete the folder to remove it" >&2
python3 -m venv "$VENV" && "$VENV/bin/pip" -q install cadquery-ocp-novtk >&2
fi
exec "$VENV/bin/python" "$HERE/etch_part_occ.py" "${args[@]}"
fi
done
exec "$PY" "$HERE/mark_etch.py" "$@"