Fix AI cash reporting and require email failures to surface#77
Merged
Conversation
…ation, and harden Cerebrium preflight ### Motivation - Prevent unintended Sunday scheduled executions and ensure scheduled runs only occur Tuesday through Saturday in UTC. - Fail early when AI report email configuration is incomplete to avoid silent AI report failures. - Make the Cerebrium predict preflight more resilient to transient network/server errors. ### Description - Changed the scheduled cron from `0 0 * * 2-7` to `0 0 * * 2-6` to run Tue–Sat only and added an `Enforce schedule day guard (Tue-Sat only)` step that checks UTC weekday and aborts non-permitted scheduled runs. - Added `Validate SMTP configuration for AI reports` step to fail fast if any of `SMTP_SERVER`, `SMTP_PORT`, `SENDER_EMAIL`, `SENDER_PASSWORD`, or `RECIPIENT_EMAIL` secrets are missing when AI trading is expected to run. - Normalized and tightened many workflow `if:` conditions to use `((github.event_name != 'workflow_dispatch') || !inputs.disable_ai_trading)` so AI-path expectations and gating are consistent across steps. - Updated `AI_EXPECTED` expressions used by `Ensure Daily Email Coverage` and `Evaluate Scheduled/Runner Run Status` to reflect the `disable_ai_trading` input instead of a static `false` value. - Hardened `run_ai_daily_cerebrium.py` by adding `time` import and rewriting `_preflight_predict` to perform up to 3 attempts with exponential-ish backoff, treat common transient statuses (`429, 500, 502, 503, 504`) as retryable, and return joined attempt details for diagnostics. ### Testing - Validated Python syntax for the modified file by running `python -m compileall` which completed successfully. - Linted/checked the workflow YAML with a YAML linter to ensure no obvious syntax errors which completed successfully. - No additional automated unit tests were added or modified in this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the root cause of negative AI cash reports by making cash calculations side-aware for short positions, and removes the direct Cerebrium runner email bypass so AI email failures are not hidden. Includes py_compile and side-aware cash smoke validation.