Skip to content

Commit

Permalink
data_refresh script adds publishing to Reddit
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper-Guo committed Dec 1, 2024
1 parent 3f121c4 commit a8959e4
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Automation/data-refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ handle_failure() {
then
# failure in preprocessing, bad data might have been written to file
git restore .
aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Data Refresh Failure - $error_line: $error_command"
elif [[ "$error_command" == *readme_machine.py* ]]
then
# failure in making README graphics, withhold all graph updates only
git restore Docs/visuals/*
git add .
git commit -m "Partial data refresh (no visualizations)" || true # ignore non-zero exit status when there's no diff on main
./Automation/auto-push.exp -d 2>./Automation/auto-push.log
aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Data Refresh Failure - $error_line: $error_command"
elif [[ "$error_command" == *reddit_machine.py* ]]
then
# failure in Reddit publishing, release all other data and emit warning
./Automation/auto-push.exp -d 2>./Automation/auto-push.log
aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Reddit Publication Warning"
fi

# relaunch server
./Automation/start-server.sh

aws sns publish --topic-arn arn:aws:sns:us-east-2:637423600104:Armchair-Strategist --message file://./Automation/data-refresh.log --subject "Data Refresh Failure - $error_line: $error_command"
}
trap handle_failure ERR
trap handle_failure SIGTERM
Expand All @@ -40,6 +45,13 @@ python3 f1_visualization/preprocess.py
python3 f1_visualization/readme_machine.py --update-readme >/dev/null
git add .
git commit -m "Automatic data refresh" || true # ignore non-zero exit status when there's no diff on main

# post to Reddit when there is new graphics available
# -uno is not three separate options, rather it is really -u no which removes untracked files from output
if git status -uno | grep -q "Your branch is ahead"; then
python3 reddit_machine.py
fi

./Automation/auto-push.exp -d 2>./Automation/auto-push.log

# relaunch dash app
Expand Down

0 comments on commit a8959e4

Please sign in to comment.