54 lines
2.3 KiB
Bash
54 lines
2.3 KiB
Bash
#!/bin/bash
|
|
# ModelGrid Example Script
|
|
# This is a placeholder for custom automation scripts
|
|
#
|
|
# ModelGrid can execute custom scripts in response to various events
|
|
# such as model loading, container start/stop, GPU status changes, etc.
|
|
|
|
# ==============================================================================
|
|
# ENVIRONMENT VARIABLES (set by ModelGrid when executing scripts)
|
|
# ==============================================================================
|
|
# MODELGRID_EVENT - Event type that triggered this script
|
|
# MODELGRID_CONTAINER_ID - Container ID (if applicable)
|
|
# MODELGRID_GPU_ID - GPU ID (if applicable)
|
|
# MODELGRID_MODEL_NAME - Model name (if applicable)
|
|
# MODELGRID_TIMESTAMP - Unix timestamp (milliseconds since epoch)
|
|
|
|
# ==============================================================================
|
|
# EXAMPLE: Log the event
|
|
# ==============================================================================
|
|
LOG_FILE="/var/log/modelgrid-actions.log"
|
|
|
|
echo "========================================" >> "$LOG_FILE"
|
|
echo "ModelGrid Action Triggered: $(date)" >> "$LOG_FILE"
|
|
echo "----------------------------------------" >> "$LOG_FILE"
|
|
echo "Event: ${MODELGRID_EVENT:-unknown}" >> "$LOG_FILE"
|
|
echo "Container: ${MODELGRID_CONTAINER_ID:-N/A}" >> "$LOG_FILE"
|
|
echo "GPU: ${MODELGRID_GPU_ID:-N/A}" >> "$LOG_FILE"
|
|
echo "Model: ${MODELGRID_MODEL_NAME:-N/A}" >> "$LOG_FILE"
|
|
echo "========================================" >> "$LOG_FILE"
|
|
|
|
# ==============================================================================
|
|
# EXAMPLE: Send notification on model load
|
|
# ==============================================================================
|
|
# if [ "$MODELGRID_EVENT" = "model_loaded" ]; then
|
|
# echo "Model $MODELGRID_MODEL_NAME loaded successfully" | \
|
|
# mail -s "ModelGrid: Model Loaded" admin@example.com
|
|
# fi
|
|
|
|
# ==============================================================================
|
|
# EXAMPLE: Alert on GPU error
|
|
# ==============================================================================
|
|
# if [ "$MODELGRID_EVENT" = "gpu_error" ]; then
|
|
# curl -X POST https://monitoring.example.com/alert \
|
|
# -H "Content-Type: application/json" \
|
|
# -d "{
|
|
# \"event\": \"gpu_error\",
|
|
# \"gpuId\": \"$MODELGRID_GPU_ID\",
|
|
# \"timestamp\": $MODELGRID_TIMESTAMP
|
|
# }"
|
|
# fi
|
|
|
|
# Exit with success
|
|
exit 0
|