fix: INSIGHTFACE_HOME path, entrypoint, caching default, CRON_SCHEDULE opt-in
- Dockerfile: ENV INSIGHTFACE_HOME=/models → /models/.insightface to match compose.yml and .env.example; the old value caused InsightFace to store models at /models/models/buffalo_l (double-appended subdir) - entrypoint.sh: use /app/.venv/bin/winnow (installed entry point) instead of python -m winnow.cli - config.py: ENABLE_CACHE default false → true; embedding cache is always beneficial in practice; users can opt out with ENABLE_CACHE=false - compose.yml: comment out CRON_SCHEDULE so scheduling is opt-in; flip ENABLE_CACHE to commented opt-out to reflect new default - README.md: update ENABLE_CACHE default documentation to true - tests/test_config.py: update default assertion to match Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ RUN groupadd -g 568 apps && useradd -u 568 -g apps -m -s /bin/bash appuser \
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
USER appuser
|
USER appuser
|
||||||
ENV HF_HOME=/models/huggingface INSIGHTFACE_HOME=/models
|
ENV HF_HOME=/models/huggingface INSIGHTFACE_HOME=/models/.insightface
|
||||||
|
|
||||||
HEALTHCHECK CMD test -f /app/entrypoint.sh || exit 1
|
HEALTHCHECK CMD test -f /app/entrypoint.sh || exit 1
|
||||||
ENTRYPOINT ["tini", "--", "/app/entrypoint.sh"]
|
ENTRYPOINT ["tini", "--", "/app/entrypoint.sh"]
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ The first run after a fresh install downloads the embedding models (~1-2 GB). Su
|
|||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- | :--- |
|
||||||
| `FORCE_CPU` | `false` | Disable GPU — fall back to CPU for embedding computation |
|
| `FORCE_CPU` | `false` | Disable GPU — fall back to CPU for embedding computation |
|
||||||
| `ENABLE_CACHE` | `false` | Cache computed embeddings to disk (speeds up re-runs on the same library) |
|
| `ENABLE_CACHE` | `true` | Cache computed embeddings to disk (speeds up re-runs on the same library) |
|
||||||
| `CACHE_DIR` | `.if_cache` | Path for embedding cache and upload tracker files |
|
| `CACHE_DIR` | `.if_cache` | Path for embedding cache and upload tracker files |
|
||||||
| `HF_HOME` | *(system)* | HuggingFace model cache location (SigLIP) |
|
| `HF_HOME` | *(system)* | HuggingFace model cache location (SigLIP) |
|
||||||
| `INSIGHTFACE_HOME` | *(system)* | InsightFace model cache location (Buffalo_L) |
|
| `INSIGHTFACE_HOME` | *(system)* | InsightFace model cache location (Buffalo_L) |
|
||||||
|
|||||||
+4
-5
@@ -35,7 +35,7 @@ services:
|
|||||||
|
|
||||||
# ── Caching & Models ──────────────────────────────────────────────────
|
# ── Caching & Models ──────────────────────────────────────────────────
|
||||||
- FORCE_CPU=false
|
- FORCE_CPU=false
|
||||||
- ENABLE_CACHE=true
|
# - ENABLE_CACHE=false # Disable embedding cache (default: true)
|
||||||
- CACHE_DIR=/app/.if_cache
|
- CACHE_DIR=/app/.if_cache
|
||||||
- HF_HOME=/models/huggingface
|
- HF_HOME=/models/huggingface
|
||||||
- INSIGHTFACE_HOME=/models/.insightface
|
- INSIGHTFACE_HOME=/models/.insightface
|
||||||
@@ -47,10 +47,9 @@ services:
|
|||||||
|
|
||||||
# ── Scheduling ────────────────────────────────────────────────────────
|
# ── Scheduling ────────────────────────────────────────────────────────
|
||||||
# Cron expression (unset = run once and exit)
|
# Cron expression (unset = run once and exit)
|
||||||
# Every Sunday at 3 AM:
|
# - CRON_SCHEDULE=0 3 * * 0 # Every Sunday at 3 AM
|
||||||
- CRON_SCHEDULE=0 3 * * 0
|
# - CRON_SCHEDULE=0 3 1 * * # First of every month
|
||||||
# - CRON_SCHEDULE=0 3 1 * *
|
# - CRON_SCHEDULE=*/30 * * * * # Every 30 minutes
|
||||||
# - CRON_SCHEDULE=*/30 * * * *
|
|
||||||
volumes:
|
volumes:
|
||||||
# Replace with absolute paths on your host, e.g. /opt/winnow/models
|
# Replace with absolute paths on your host, e.g. /opt/winnow/models
|
||||||
- /path/to/winnow/models:/models
|
- /path/to/winnow/models:/models
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ export PYTHONUNBUFFERED=1
|
|||||||
|
|
||||||
# 1. Run the job immediately on startup
|
# 1. Run the job immediately on startup
|
||||||
echo "▶ Running on startup..."
|
echo "▶ Running on startup..."
|
||||||
/app/.venv/bin/python -m winnow.cli
|
/app/.venv/bin/winnow
|
||||||
|
|
||||||
# 2. If a schedule exists, start the scheduler
|
# 2. If a schedule exists, start the scheduler
|
||||||
if [ -n "${CRON_SCHEDULE:-}" ]; then
|
if [ -n "${CRON_SCHEDULE:-}" ]; then
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def test_config_loads_defaults(monkeypatch):
|
|||||||
assert cfg.FACE_MARGIN == 0.15
|
assert cfg.FACE_MARGIN == 0.15
|
||||||
assert cfg.USE_FULL_RESOLUTION is True
|
assert cfg.USE_FULL_RESOLUTION is True
|
||||||
assert cfg.ENABLE_FACE_ALIGNMENT is True
|
assert cfg.ENABLE_FACE_ALIGNMENT is True
|
||||||
assert cfg.ENABLE_CACHE is False
|
assert cfg.ENABLE_CACHE is True
|
||||||
|
|
||||||
_Config.reset()
|
_Config.reset()
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -39,8 +39,7 @@ class _Config:
|
|||||||
USE_FULL_RESOLUTION: bool = True
|
USE_FULL_RESOLUTION: bool = True
|
||||||
ENABLE_FACE_ALIGNMENT: bool = True
|
ENABLE_FACE_ALIGNMENT: bool = True
|
||||||
|
|
||||||
# Caching (opt-in to avoid unexpected files)
|
ENABLE_CACHE: bool = True
|
||||||
ENABLE_CACHE: bool = False
|
|
||||||
CACHE_DIR: str = ".if_cache"
|
CACHE_DIR: str = ".if_cache"
|
||||||
|
|
||||||
def __new__(cls) -> "_Config":
|
def __new__(cls) -> "_Config":
|
||||||
@@ -64,7 +63,7 @@ class _Config:
|
|||||||
self.FACE_MARGIN = float(os.getenv("FACE_MARGIN", "0.15"))
|
self.FACE_MARGIN = float(os.getenv("FACE_MARGIN", "0.15"))
|
||||||
self.USE_FULL_RESOLUTION = os.getenv("USE_FULL_RESOLUTION", "true").lower() in ("true", "1", "yes")
|
self.USE_FULL_RESOLUTION = os.getenv("USE_FULL_RESOLUTION", "true").lower() in ("true", "1", "yes")
|
||||||
self.ENABLE_FACE_ALIGNMENT = os.getenv("ENABLE_FACE_ALIGNMENT", "true").lower() in ("true", "1", "yes")
|
self.ENABLE_FACE_ALIGNMENT = os.getenv("ENABLE_FACE_ALIGNMENT", "true").lower() in ("true", "1", "yes")
|
||||||
self.ENABLE_CACHE = os.getenv("ENABLE_CACHE", "false").lower() in ("true", "1", "yes")
|
self.ENABLE_CACHE = os.getenv("ENABLE_CACHE", "true").lower() in ("true", "1", "yes")
|
||||||
self.CACHE_DIR = os.getenv("CACHE_DIR", ".if_cache")
|
self.CACHE_DIR = os.getenv("CACHE_DIR", ".if_cache")
|
||||||
|
|
||||||
# Fall back to config file for non-sensitive values (API_KEY not stored here)
|
# Fall back to config file for non-sensitive values (API_KEY not stored here)
|
||||||
|
|||||||
Reference in New Issue
Block a user