From 2276aa492bcac922f02063d859dd84f20a0d8752 Mon Sep 17 00:00:00 2001 From: simpleshell Date: Sat, 4 May 2024 03:33:08 +0100 Subject: [PATCH 1/2] fixed dependency issues Signed-off-by: simpleshell --- README.md | 4 ++-- environment.yml | 3 ++- setup.py | 2 +- src/taswira/scripts/ingestion.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ce47f72..d73f95c 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ Requires [Git] and [Miniconda] (or Anaconda) with Python 3.6 or newer. 1. Clone the repository and `cd` into it: ```sh -git clone https://github.com/moja-global/GCBM.Visualisation_Tool -cd GCBM.Visualisation_Tool +git clone https://github.com/moja-global/taswira +cd taswira ``` 2. Create a conda environment and activate it: diff --git a/environment.yml b/environment.yml index 92a8ec2..efbf698 100644 --- a/environment.yml +++ b/environment.yml @@ -4,7 +4,7 @@ channels: - nodefaults dependencies: - python>=3.6 - - numpy + - numpy=1.19.5 - rasterio>=1.0 - shapely - crick @@ -15,3 +15,4 @@ dependencies: - pylint>=2.5.2 - dash==1.13.3 - dash-leaflet==0.0.19 + - MarkupSafe==2.0.1 diff --git a/setup.py b/setup.py index 4f046d7..442d7c6 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def _get_version(rel_path): description="An interactive visualization tool for GCBM", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/moja-global/GCBM.Visualisation_Tool", + url="https://github.com/moja-global/taswira", author="moja global", classifiers=[ 'Development Status :: 3 - Alpha', diff --git a/src/taswira/scripts/ingestion.py b/src/taswira/scripts/ingestion.py index c853e64..771b258 100644 --- a/src/taswira/scripts/ingestion.py +++ b/src/taswira/scripts/ingestion.py @@ -12,7 +12,7 @@ from .metadata import get_metadata DB_NAME = 'terracotta.sqlite' -GCBM_RASTER_NAME_PATTERN = r'.*_(?P\d{4}).tiff' +GCBM_RASTER_NAME_PATTERN = r'.*_(?P\d{4}).tif{1,2}' GCBM_RASTER_KEYS = ('title', 'year') GCBM_RASTER_KEYS_DESCRIPTION = { 'title': 'Name of indicator', From 2f484503d03b3212da5e617f5de3bd332f5acd6e Mon Sep 17 00:00:00 2001 From: simpleshell Date: Sun, 6 Oct 2024 09:44:45 +0100 Subject: [PATCH 2/2] catch exception of missing years Signed-off-by: simpleshell --- src/taswira/__init__.py | 2 +- src/taswira/scripts/ingestion.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/taswira/__init__.py b/src/taswira/__init__.py index 69f0109..225e288 100644 --- a/src/taswira/__init__.py +++ b/src/taswira/__init__.py @@ -1,7 +1,7 @@ """A command-line tool for visualizing GCBM output.""" from .scripts.console import console -__version__ = "0.1.0" +__version__ = "0.1.1" def main(): diff --git a/src/taswira/scripts/ingestion.py b/src/taswira/scripts/ingestion.py index 771b258..96a2597 100644 --- a/src/taswira/scripts/ingestion.py +++ b/src/taswira/scripts/ingestion.py @@ -2,6 +2,7 @@ import glob import os import re +import logging import tqdm from terracotta import get_driver @@ -64,10 +65,16 @@ def ingest(rasterdir, db_results, outputdir, allow_unoptimized=False): title = raster.get('title', raster['database_indicator']) year = _find_raster_year(raster['path']) unit = find_units(raster.get('graph_units')) + try: + indicator_value = str(metadata[title][year]) + except KeyError: + # Handle missing metadata gracefully + logging.warning(f"Metadata for year {year} and title {title} is missing.") + indicator_value = "N/A" computed_metadata = driver.compute_metadata( raster['path'], extra_metadata={ - 'indicator_value': str(metadata[title][year]), + 'indicator_value': indicator_value, 'colormap': raster.get('palette').lower(), 'unit': unit.value[2] })