From bf1bcb9d2a69be737338596b2242a3ffcc8bb19e Mon Sep 17 00:00:00 2001 From: David Walker Date: Sun, 4 May 2025 21:36:06 +0100 Subject: [PATCH] Added report execution scripts --- .../annual_category_location_heatmap.ipynb | 4 +-- reports/category_life_list.ipynb | 4 +-- reports/location_richness_map.ipynb | 4 +-- reports/requirements.txt | 7 +++++ reports/run_all.sh | 31 +++++++++++++++++++ reports/run_notebook.sh | 13 ++++++++ reports/sql/species_location.sql | 7 +++++ 7 files changed, 64 insertions(+), 6 deletions(-) create mode 100755 reports/run_all.sh create mode 100755 reports/run_notebook.sh create mode 100644 reports/sql/species_location.sql diff --git a/reports/annual_category_location_heatmap.ipynb b/reports/annual_category_location_heatmap.ipynb index 2c94d01..27b8ae3 100644 --- a/reports/annual_category_location_heatmap.ipynb +++ b/reports/annual_category_location_heatmap.ipynb @@ -162,7 +162,7 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -180,7 +180,7 @@ }, "vscode": { "interpreter": { - "hash": "f085c86085609b1ab2f295d8cd5b519618e19fd591a6919f4ec2f9290a6745f6" + "hash": "7a792fcb311f9eb9f3c1b942a8c87ada8484712b89b670347c16a1088e0a1f69" } } }, diff --git a/reports/category_life_list.ipynb b/reports/category_life_list.ipynb index ae2fb34..cc75363 100644 --- a/reports/category_life_list.ipynb +++ b/reports/category_life_list.ipynb @@ -115,7 +115,7 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -133,7 +133,7 @@ }, "vscode": { "interpreter": { - "hash": "f085c86085609b1ab2f295d8cd5b519618e19fd591a6919f4ec2f9290a6745f6" + "hash": "7a792fcb311f9eb9f3c1b942a8c87ada8484712b89b670347c16a1088e0a1f69" } } }, diff --git a/reports/location_richness_map.ipynb b/reports/location_richness_map.ipynb index 6f43e86..39b0fe0 100644 --- a/reports/location_richness_map.ipynb +++ b/reports/location_richness_map.ipynb @@ -170,7 +170,7 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -189,7 +189,7 @@ "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "f085c86085609b1ab2f295d8cd5b519618e19fd591a6919f4ec2f9290a6745f6" + "hash": "7a792fcb311f9eb9f3c1b942a8c87ada8484712b89b670347c16a1088e0a1f69" } } }, diff --git a/reports/requirements.txt b/reports/requirements.txt index a82707f..efe6980 100644 --- a/reports/requirements.txt +++ b/reports/requirements.txt @@ -1,3 +1,4 @@ +ansicolors==1.1.8 anyio==4.9.0 appnope==0.1.4 argon2-cffi==23.1.0 @@ -13,12 +14,14 @@ branca==0.8.1 certifi==2025.1.31 cffi==1.17.1 charset-normalizer==3.4.1 +click==8.1.8 comm==0.2.2 contourpy==1.3.2 cycler==0.12.1 debugpy==1.8.14 decorator==5.2.1 defusedxml==0.7.1 +entrypoints==0.4 et_xmlfile==2.0.0 executing==2.2.0 fastjsonschema==2.21.1 @@ -69,6 +72,7 @@ overrides==7.7.0 packaging==24.2 pandas==2.2.3 pandocfilters==1.5.1 +papermill==2.6.0 parso==0.8.4 pexpect==4.9.0 pillow==11.2.1 @@ -94,14 +98,17 @@ rpds-py==0.24.0 scipy==1.15.2 seaborn==0.13.2 Send2Trash==1.8.3 +setuptools==80.3.1 six==1.17.0 sniffio==1.3.1 soupsieve==2.6 sqlparse==0.5.3 stack-data==0.6.3 +tenacity==9.1.2 terminado==0.18.1 tinycss2==1.4.0 tornado==6.4.2 +tqdm==4.67.1 traitlets==5.14.3 types-python-dateutil==2.9.0.20241206 typing_extensions==4.13.2 diff --git a/reports/run_all.sh b/reports/run_all.sh new file mode 100755 index 0000000..b8b5aed --- /dev/null +++ b/reports/run_all.sh @@ -0,0 +1,31 @@ +#!/bin/bash -f + +# Activate the virtual environment +export REPORTS_ROOT=$( cd "$( dirname "$0" )" && pwd ) +. $REPORTS_ROOT/venv/bin/activate + +# Suppress warnings about the output file extension +export PYTHONWARNINGS="ignore" + +# Define a list of notebooks to skip +declare -a exclusions=( +) + +# Get a list of Jupyter Notebooks and iterate over them +files=$(find `pwd` -name '*.ipynb') +while IFS= read -r file; do + # Get the notebook file name and extension without the path + filename=$(basename -- "$file") + + # See if the notebook is in the exclusions list + found=0 + if [[ " ${exclusions[@]} " =~ " $filename " ]]; then + found=1 + fi + + # If this notebook isn't in the exclusions list, run it + if [[ found -eq 0 ]]; then + echo $file + papermill "$file" /dev/null + fi +done <<< "$files" diff --git a/reports/run_notebook.sh b/reports/run_notebook.sh new file mode 100755 index 0000000..53ea353 --- /dev/null +++ b/reports/run_notebook.sh @@ -0,0 +1,13 @@ +#!/bin/bash -f + +if [[ $# -ne 1 ]]; then + echo Usage: run_notebook.sh NOTEBOOK + exit 1 +fi + +# Activate the virtual environment +export REPORTS_ROOT=$( cd "$( dirname "$0" )" && pwd ) +. $REPORTS_ROOT/venv/bin/activate + +export PYTHONWARNINGS="ignore" +papermill "$1" /dev/null diff --git a/reports/sql/species_location.sql b/reports/sql/species_location.sql new file mode 100644 index 0000000..eb0fc9f --- /dev/null +++ b/reports/sql/species_location.sql @@ -0,0 +1,7 @@ +SELECT l.Name AS 'Location', sp.Name AS 'Species', c.Name AS 'Category', DATE( s.Date ) AS 'Date', IFNULL( s.Number, 1 ) AS 'Count' +FROM SIGHTINGS s +INNER JOIN SPECIES sp ON sp.Id = s.SpeciesId +INNER JOIN CATEGORIES c ON c.Id = sp.CategoryId +INNER JOIN LOCATIONS l ON l.Id = s.LocationId +WHERE l.Name IN ( $LOCATIONS ) +AND sp.Name = "$SPECIES";