From 5906d0d9124f3baa18435076f90ba7a3cd2e3656 Mon Sep 17 00:00:00 2001 From: henrykironde Date: Wed, 8 May 2024 00:38:17 -0400 Subject: [PATCH] Copy PredictedBirds.zip to everglades-forecast-web repo --- .gitignore | 2 +- combine_bird_predictions.py | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 5c84efd..1278647 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ .vscode/launch.json App/Zooniverse/* lightning_logs -logs/** \ No newline at end of file +logs/** diff --git a/combine_bird_predictions.py b/combine_bird_predictions.py index 1ac13be..62037cc 100644 --- a/combine_bird_predictions.py +++ b/combine_bird_predictions.py @@ -19,7 +19,8 @@ def combine(paths): if __name__ == "__main__": working_dir = tools.get_working_dir() predictions_path = f"{working_dir}/predictions/" - output_path = f"{working_dir}/everwatch-workflow/App/Zooniverse/data" + output_path = f"{working_dir}/EvergladesTools/App/Zooniverse/data" + output_zip = os.path.join(output_path, "PredictedBirds.zip") predictions = sys.argv[1:] # write output to zooniverse app @@ -27,9 +28,21 @@ def combine(paths): df.to_file(os.path.join(output_path, "PredictedBirds.shp")) # Zip the shapefile for storage efficiency - with ZipFile(os.path.join(output_path, "PredictedBirds.zip"), 'w', ZIP_DEFLATED) as zip: + with ZipFile(output_zip, 'w', ZIP_DEFLATED) as zip: for ext in ['cpg', 'dbf', 'prj', 'shp', 'shx']: focal_file = os.path.join(output_path, f"PredictedBirds.{ext}") file_name = os.path.basename(focal_file) zip.write(focal_file, arcname=file_name) os.remove(focal_file) + + # Copy PredictedBirds.zip to everglades-forecast-web repo + dest_path = "/blue/ewhite/everglades/everglades-forecast-web/data" + if not os.path.exists(dest_path): + os.makedirs(dest_path) + dest_file = os.path.join(dest_path, "PredictedBirds.zip") + + if os.path.exists(output_zip): + shutil.copy(output_zip, dest_file) + print(f"{output_zip} copied to {dest_file}.") + else: + print("{output_zip} file does not exist.")