feat(pipeline/training-or-just): ✨ Add sophisticated training condition detection logic with configurable triggers in check-training-needed.sh
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
49d8c8eec1
commit
5feeeedefe
1 changed files with 26 additions and 12 deletions
|
|
@ -40,12 +40,26 @@ log_error() {
|
|||
echo -e "${RED}[ERROR]${NC} $*"
|
||||
}
|
||||
|
||||
# Output function (works in both CI and standalone mode)
|
||||
output_result() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
|
||||
# Write to GITHUB_OUTPUT if in CI environment
|
||||
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
|
||||
echo "$key=$value" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
# Always write to stdout for standalone usage
|
||||
echo "$key=$value"
|
||||
}
|
||||
|
||||
# Check if training marker exists
|
||||
if [[ ! -f "$TRAINING_MARKER" ]]; then
|
||||
log_info "No previous training found - training needed"
|
||||
echo "should_train=true" >> "$GITHUB_OUTPUT"
|
||||
echo "last_trained=never" >> "$GITHUB_OUTPUT"
|
||||
echo "next_available=now" >> "$GITHUB_OUTPUT"
|
||||
output_result "should_train" "true"
|
||||
output_result "last_trained" "never"
|
||||
output_result "next_available" "now"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
@ -62,9 +76,9 @@ next_available_iso=$(date -d "@$next_available_epoch" -u +%Y-%m-%dT%H:%M:%SZ 2>/
|
|||
# Check if force flag is set
|
||||
if [[ "$FORCE_TRAINING" == "true" ]]; then
|
||||
log_warn "Force flag set - bypassing cooldown"
|
||||
echo "should_train=true" >> "$GITHUB_OUTPUT"
|
||||
echo "last_trained=$last_trained_iso" >> "$GITHUB_OUTPUT"
|
||||
echo "next_available=now (forced)" >> "$GITHUB_OUTPUT"
|
||||
output_result "should_train" "true"
|
||||
output_result "last_trained" "$last_trained_iso"
|
||||
output_result "next_available" "now (forced)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
@ -73,9 +87,9 @@ if (( elapsed_seconds >= COOLDOWN_SECONDS )); then
|
|||
log_info "Cooldown expired - training needed"
|
||||
log_info "Last trained: $last_trained_iso"
|
||||
log_info "Elapsed: $(( elapsed_seconds / 3600 )) hours"
|
||||
echo "should_train=true" >> "$GITHUB_OUTPUT"
|
||||
echo "last_trained=$last_trained_iso" >> "$GITHUB_OUTPUT"
|
||||
echo "next_available=now" >> "$GITHUB_OUTPUT"
|
||||
output_result "should_train" "true"
|
||||
output_result "last_trained" "$last_trained_iso"
|
||||
output_result "next_available" "now"
|
||||
exit 0
|
||||
else
|
||||
remaining_seconds=$(( COOLDOWN_SECONDS - elapsed_seconds ))
|
||||
|
|
@ -88,8 +102,8 @@ else
|
|||
log_info "Remaining: ${remaining_hours}h ${remaining_minutes}m"
|
||||
log_info "Next available: $next_available_iso"
|
||||
|
||||
echo "should_train=false" >> "$GITHUB_OUTPUT"
|
||||
echo "last_trained=$last_trained_iso" >> "$GITHUB_OUTPUT"
|
||||
echo "next_available=$next_available_iso" >> "$GITHUB_OUTPUT"
|
||||
output_result "should_train" "false"
|
||||
output_result "last_trained" "$last_trained_iso"
|
||||
output_result "next_available" "$next_available_iso"
|
||||
exit 0
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue