From c1f8937e7a7b586f7c302708acf086c6a71c90f4 Mon Sep 17 00:00:00 2001 From: Henry Senyondo Date: Tue, 17 Sep 2024 22:49:49 -0400 Subject: [PATCH] Archiving Predictions --- Snakefile | 12 +++++++++ archive_predictions.sh | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 archive_predictions.sh diff --git a/Snakefile b/Snakefile index 7cb2379..098edcf 100644 --- a/Snakefile +++ b/Snakefile @@ -34,6 +34,7 @@ rule all: input: f"{working_dir}/everwatch-workflow/App/Zooniverse/data/PredictedBirds.zip", f"{working_dir}/everwatch-workflow/App/Zooniverse/data/nest_detections_processed.zip", + f"{working_dir}/everwatch-workflow/App/Zooniverse/data/forecast_web_updated.txt", expand(f"{working_dir}/predictions/{{year}}/{{site}}/{{flight}}_projected.shp", zip, site=SITES, year=YEARS, flight=FLIGHTS), expand(f"{working_dir}/processed_nests/{{year}}/{{site}}/{{site}}_{{year}}_processed_nests.shp", @@ -136,3 +137,14 @@ rule upload_mapbox: "everwatch" shell: "python upload_mapbox.py {input}" + +rule update_everwatch_predictions: + input: + f"{working_dir}/everwatch-workflow/App/Zooniverse/data/PredictedBirds.zip" + output: + touch(f"{working_dir}/everwatch-workflow/App/Zooniverse/data/forecast_web_updated.txt") + shell: + """ + bash archive_predictions.sh + touch {output} + """ diff --git a/archive_predictions.sh b/archive_predictions.sh new file mode 100644 index 0000000..daae96a --- /dev/null +++ b/archive_predictions.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Capture the current date and time for the commit message +date=$(date '+%Y-%m-%d %H:%M:%S') + +# Change directory to the everwatch-predictions +cd /blue/ewhite/everglades/everwatch-predictions || exit + +# Stash any local changes, switch to the main branch, and pull the latest updates +git stash +git checkout main +git pull origin main + +# Set up the user information for Weecology Deploy Bot +git config user.email "weecologydeploy@weecology.org" +git config user.name "Weecology Deploy Bot" + +# Check if the TEST_ENV environment variable is set, skip actual deployment if it is +if [ -n "$TEST_ENV" ]; then + echo "TEST_ENV is set: $TEST_ENV" + git checkout -B dry-run + git reset --hard origin/main + echo "Test dry run: $date" >> README.md + git add -u + git commit -m "Weecology Deploy Bot: Dry run tests from HiperGator $date [ci skip]" + git push origin dry-run -f + exit 0 +fi + +# Copy the updated PredictedBirds.zip file to the repository +cp /blue/ewhite/everglades/everwatch-workflow/App/Zooniverse/data/PredictedBirds.zip \ + /blue/ewhite/everglades/everwatch-predictions/data/PredictedBirds.zip + +# Copy the updated PredictedBirds.csv file to the repository +cp /blue/ewhite/everglades/everwatch-workflow/App/Zooniverse/data/PredictedBirds.csv \ + /blue/ewhite/everglades/everwatch-predictions/data/PredictedBirds.csv + +# Stage the files, commit with a message including the current date, and push changes +git add PredictedBirds.zip PredictedBirds.csv +git commit -m "Weecology Deploy Bot $date" + +# Uncomment the following line if you intend to push directly to the main branch +# git push origin main + +# Reapply stashed changes, if any +git stash pop || echo "No stashed changes to apply." + +# Set up the deploy remote for the portal-forecasts repository +git remote remove deploy +git remote add deploy https://${GITHUB_TOKEN}@github.com/weecology/everwatch-predictions.git + +# Push the changes to the deploy remote's main branch +git push --quiet deploy main + +# Uncomment the following lines if you want to tag the release and push tags +# git tag $date +# git push --quiet deploy --tags