Files
andrew 4bcd242dd3 feat(services,weight): split count/weight services, day-0 cycle handling, disable step-function GBM
- services: separate 08:00 counting and 06:00 weighing systemd units/timers,
  run_daily_counting.sh / run_daily_weighing.sh, install_service.sh update
- dashboard: guard /api/weight/coops against rows without weight data
- sim/day-0: CYCLE_START_DATE 2026-10-01 (day 0 = DOC arrival, counts only);
  consolidation skips cycle_day 0 artifacts (storage.py guard)
- weight: predict_chicken_weight(use_gbm=False) default. Retrained joblib
  (LGBM, 14:26) predicts a step function of cycle_day only (108.1 g days 1-5,
  140.1 g days 6-8, zero sensitivity to camera area); fallback Gompertz +
  allometric blend restored, varies per camera/day (37.2-115.7 g over days 1-7).
  Re-enable only after model retrained on early-day morphometry with
  features_dict/volumetric wired (see ponytail comment in growth_model.py).
  Covered by new tests/test_growth_model_gbm.py
- models/scripts: retraining tooling (train_weight_model.py,
  train_c23_focused_model.py), retrained joblib, historical_weights_avg.csv
- configs/template/requirements: cycle7 batch yamls, index.html, deps
- data: db/chicken_counts.db + reports refreshed from 2026-10-01..08 rerun

Tests: PYTHONPATH=src python3 -m unittest discover -s tests -p "test_*.py"
-> Ran 51, 49 pass. 2 pre-existing failures unchanged from baseline
(61ca7c2): fusion n_valid_samples 59!=98, consolidate fixture (day-0 date
conflicts with day-0 skip).
2026-10-08 17:02:21 +07:00

42 lines
2.0 KiB
Bash

#!/bin/bash
# Shared SIM date-mapping helper. Source it; do not execute.
# Maps "$DATE" (or today) onto source videos from FULL_Cycle_Kandang_Atas_Test
# (2026-05-22 .. 2026-07-09, 49 days, loops back after end date) and symlinks
# them into FULL_CYCLE_1_FLOOR_SIM/<DATE>.
# Exports: SIM_SRC_DATE, SIM_ROOT, SIM_VIDEOS (array), SIM_VIDS_EMPTY (0/1),
# SIM_GPU_OK (0/1), SIM_CYCLE_START_DATE
# ponytail: single-date mapping only; historical backfill stays in simulate_daily_cycle.sh
SIM_EPOCH="2026-10-01" # sim day 1 maps to SRC_START
SIM_SRC_START="2026-05-22"
SIM_CYCLE_DAYS=49 # 2026-05-22 .. 2026-07-09 inclusive
SIM_CYCLE_START_DATE="2026-10-01" # 2026-10-01 = Cycle Day 0 (DOC arrival, no weight); weight from day 1 (2026-10-02)
SIM_DATE="${DATE:-$(date +%F)}"
SIM_ROOT="$(realpath -m "$SCRIPT_DIR/../VIDEOS/cycle7/FULL_CYCLE_1_FLOOR_SIM")"
SIM_SRC_ROOT="$SCRIPT_DIR/../VIDEOS/cycle7/FULL_Cycle_Kandang_Atas_Test"
offset=$(( ( $(date -d "$SIM_DATE" +%s) - $(date -d "$SIM_EPOCH" +%s) ) / 86400 ))
idx=$(( (offset % SIM_CYCLE_DAYS + SIM_CYCLE_DAYS) % SIM_CYCLE_DAYS ))
SIM_SRC_DATE="$(date -d "$SIM_SRC_START + $idx days" +%F)"
mapfile -t SIM_VIDEOS < <(ls -1 "$SIM_SRC_ROOT/$SIM_SRC_DATE"/*.mp4 2>/dev/null || true)
SIM_VIDS_EMPTY=0
if [ "${#SIM_VIDEOS[@]}" -eq 0 ]; then
SIM_VIDS_EMPTY=1
echo "[sim] no source videos in $SIM_SRC_ROOT/$SIM_SRC_DATE — skipping $SIM_DATE" >&2
else
# Skip loudly when another job is holding VRAM (needs ~6 GB for 4 workers).
free_mb="$(nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits 2>/dev/null | head -1)"
SIM_GPU_OK=1
if [ -z "$free_mb" ] || [ "$free_mb" -lt 6000 ]; then
SIM_GPU_OK=0
echo "[sim] SKIP: ${free_mb:-driver-lost} MiB free (need 6000) — GPU busy" >&2
fi
mkdir -p "$SIM_ROOT/$SIM_DATE"
for f in "${SIM_VIDEOS[@]}"; do
ln -sf "$(realpath "$f")" "$SIM_ROOT/$SIM_DATE/"
done
echo "[sim] $SIM_DATE <- $SIM_SRC_DATE (${#SIM_VIDEOS[@]} videos)"
fi