Phase 1 of the modernization plan: freeze the currently-working environment so later refactors have a measured reference point. - Pin python-coreml-stable-diffusion to commit e5d960c4 (the one already installed in the maintainer's apple_env), plus torch==2.0.1, coremltools==8.2 and numpy<1.25 to match the only env that loads ComfyUI successfully (Comfy's checkpoint-safe-loading branch in utils.py is gated on torch>=2.4, so newer torch + numpy 1.23 breaks at import). - Mirror the same pins in requirements.txt and commit uv.lock for reproducible installs. - Add requires-comfyui pinning ComfyUI to ab541335 (the validated commit). - Fix tests/unit/test_chunks.py fixture: get_model_config() now takes a ModelVersion argument; pass ModelVersion.SD15 (the previously-broken test was the only Phase 1 production-code change required). - Add the Phase 1 baseline harness: bench/run.py (direct Core ML UNet latency, deterministic), bench/scripts/convert_sd15.py (one-command conversion bypassing the node graph), bench/scripts/smoke_image.py (POSTs the existing e2e workflow to a local ComfyUI server and saves the Core ML image), bench/env/capture.sh (env snapshot), bench/prompts.json (fixed prompt set). - Ignore apple_env/, comfy_env/, and bench/scripts/*.log. Tests: 20/20 unit pass (test_chunks + test_controlnet).
101 lines
3.5 KiB
Bash
Executable File
101 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Phase 1 baseline environment capture.
|
|
#
|
|
# Default mode: query the project's .venv via `uv pip` (matches how uv builds
|
|
# the venv — without a bundled pip executable). For a non-uv setup, point
|
|
# PYTHON_BIN at the right interpreter; pip freeze then falls back to
|
|
# `python -m pip` if available, otherwise `uv pip`.
|
|
#
|
|
# Usage:
|
|
# bash bench/env/capture.sh # uses .venv (uv-managed)
|
|
# PYTHON_BIN=apple_env/bin/python bash bench/env/capture.sh
|
|
#
|
|
# Writes bench/env/baseline-<gitsha>.txt with: this repo's git sha,
|
|
# ComfyUI's git sha (override path with COMFY_DIR=...), python + macOS
|
|
# versions, the resolved git commit of python-coreml-stable-diffusion as
|
|
# installed, and the full freeze of the active venv (for fresh-venv
|
|
# reproducibility).
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$REPO_ROOT"
|
|
|
|
SHA_SHORT="$(git rev-parse --short HEAD)"
|
|
OUT_DIR="bench/env"
|
|
OUT="${OUT_DIR}/baseline-${SHA_SHORT}.txt"
|
|
mkdir -p "$OUT_DIR"
|
|
|
|
COMFY_DIR="${COMFY_DIR:-$(cd ../.. && pwd)}"
|
|
PYTHON_BIN="${PYTHON_BIN:-$REPO_ROOT/.venv/bin/python}"
|
|
|
|
if [ ! -x "$PYTHON_BIN" ]; then
|
|
echo "PYTHON_BIN not executable: $PYTHON_BIN" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Prefer `python -m pip` (works in classic venvs). Fall back to `uv pip`,
|
|
# which queries any interpreter without needing pip installed in it.
|
|
run_freeze() {
|
|
if "$PYTHON_BIN" -m pip --version >/dev/null 2>&1; then
|
|
"$PYTHON_BIN" -m pip freeze
|
|
elif command -v uv >/dev/null 2>&1; then
|
|
uv pip freeze --python "$PYTHON_BIN"
|
|
else
|
|
echo "neither pip nor uv available for freeze"
|
|
fi
|
|
}
|
|
|
|
run_show_msd() {
|
|
if "$PYTHON_BIN" -m pip --version >/dev/null 2>&1; then
|
|
"$PYTHON_BIN" -m pip show python-coreml-stable-diffusion 2>/dev/null || echo "not-installed"
|
|
elif command -v uv >/dev/null 2>&1; then
|
|
uv pip show --python "$PYTHON_BIN" python-coreml-stable-diffusion 2>/dev/null || echo "not-installed"
|
|
else
|
|
echo "neither pip nor uv available for show"
|
|
fi
|
|
}
|
|
|
|
{
|
|
echo "# Phase 1 baseline environment capture"
|
|
echo "timestamp_utc: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
echo "repo_sha: $(git rev-parse HEAD)"
|
|
echo "repo_branch: $(git rev-parse --abbrev-ref HEAD)"
|
|
echo "comfyui_dir: ${COMFY_DIR}"
|
|
echo "comfyui_sha: $(git -C "$COMFY_DIR" rev-parse HEAD 2>/dev/null || echo unknown)"
|
|
echo "python_bin: ${PYTHON_BIN}"
|
|
echo "python_version: $("$PYTHON_BIN" --version 2>&1)"
|
|
echo "platform_machine: $(uname -m)"
|
|
echo "platform_uname: $(uname -a)"
|
|
if command -v sw_vers >/dev/null 2>&1; then
|
|
echo "macos_product: $(sw_vers -productName)"
|
|
echo "macos_version: $(sw_vers -productVersion)"
|
|
echo "macos_build: $(sw_vers -buildVersion)"
|
|
fi
|
|
echo
|
|
echo "## python-coreml-stable-diffusion (resolved)"
|
|
run_show_msd
|
|
echo
|
|
echo "## python-coreml-stable-diffusion installed git metadata"
|
|
DIST_INFO="$("$PYTHON_BIN" -c "import importlib.metadata as m; d=m.distribution('python-coreml-stable-diffusion'); print(d._path)" 2>/dev/null || true)"
|
|
if [ -n "${DIST_INFO}" ] && [ -f "${DIST_INFO}/direct_url.json" ]; then
|
|
cat "${DIST_INFO}/direct_url.json"
|
|
echo
|
|
else
|
|
echo "direct_url.json not found"
|
|
fi
|
|
echo
|
|
echo "## coremltools version"
|
|
"$PYTHON_BIN" -c "import coremltools; print('coremltools', coremltools.__version__)" 2>&1 || true
|
|
echo
|
|
echo "## torch version"
|
|
"$PYTHON_BIN" -c "import torch; print('torch', torch.__version__)" 2>&1 || true
|
|
echo
|
|
echo "## numpy version"
|
|
"$PYTHON_BIN" -c "import numpy; print('numpy', numpy.__version__)" 2>&1 || true
|
|
echo
|
|
echo "## freeze"
|
|
run_freeze
|
|
} > "$OUT"
|
|
|
|
echo "wrote $OUT"
|