Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse committed Dec 10, 2024
1 parent d904123 commit 386f680
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/submit-rsv-forecasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- name: Create required directories
run: |
mkdir -p rsv/submissions
mkdir -p rsv/submissions-diagnostics
- name: Run rsv forecasting script
run: python rsv/run-rsv-forecasts.py
Expand All @@ -42,11 +43,20 @@ jobs:
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Add all generated files before pulling
git add rsv/submissions/ rsv/submissions-diagnostics/
# Stash any changes if they exist
git stash || true
# Pull latest changes
git pull origin main --rebase
# Add and commit the new forecasts
git add rsv/submissions/
# Pop stashed changes if they exist
git stash pop || true
# Add all generated files again
git add rsv/submissions/ rsv/submissions-diagnostics/
# Only commit if there are changes
if git diff --staged --quiet; then
Expand Down
5 changes: 2 additions & 3 deletions rsv/run-rsv-forecasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
response = requests.get(url).json()

# origin date is the first date of the week for that week's forecast (i.e. the Sunday before the submission due date).
today = datetime.now().date() - timedelta(
days=1
) # this is the submission due date, a Tuesday
today = datetime.now().date()
days_until_sunday = (6 - today.weekday()) % 7 # 6 is Sunday
origin_date = today + timedelta(days=days_until_sunday) - timedelta(days=7)

Expand Down Expand Up @@ -129,3 +127,4 @@

forecasts_df_full = forecasts_df_full.drop(columns=["target_end_date"])
forecasts_df_full.to_csv(f"rsv/submissions/{origin_date}-Metaculus-cp.csv", index=False)

0 comments on commit 386f680

Please sign in to comment.