Files

45 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Master runner for batch mortality detection across all coops
set -u
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export PYTHONPATH="$SCRIPT_DIR/src"
if [ -f "$SCRIPT_DIR/venv/bin/python" ]; then
PYTHON="$SCRIPT_DIR/venv/bin/python"
else
PYTHON="python3"
fi
DATE_OR_COOP="${1:-}" # Optional: date (e.g. 2026-06-18) or coop (e.g. K1) or empty for all
CONFIG="${2:-configs/mortality_config.yaml}"
VIDEOS_BASE="$SCRIPT_DIR/../VIDEOS"
echo "================================================================="
echo " Starting Batch Multi-Coop Mortality Detection"
if [ -n "$DATE_OR_COOP" ]; then
echo " Target Filter: $DATE_OR_COOP"
fi
echo " Base Videos: $VIDEOS_BASE"
echo "================================================================="
if [[ "$DATE_OR_COOP" =~ ^[Kk][0-9]+$ ]] || [[ "$DATE_OR_COOP" =~ ^kandang.* ]]; then
# Run specific coop
echo ">>> Running mortality for coop: $DATE_OR_COOP <<<"
$PYTHON -m chicken_counter.cli mortality --config "$CONFIG" --coop "$DATE_OR_COOP" --videos-root "$VIDEOS_BASE"
elif [[ "$DATE_OR_COOP" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
# Run all coops for specific date
echo ">>> Running all coops for date: $DATE_OR_COOP <<<"
$PYTHON -m chicken_counter.cli mortality --config "$CONFIG" --all-coops --date "$DATE_OR_COOP" --videos-root "$VIDEOS_BASE"
else
# Run all coops for all available mortality folders
echo ">>> Running all discovered coop mortality folders <<<"
$PYTHON -m chicken_counter.cli mortality --config "$CONFIG" --all-coops --videos-root "$VIDEOS_BASE"
fi
echo ""
echo "================================================================="
echo " Batch Mortality Run Completed."
echo "================================================================="