From ebe9399398af5e1990df4e5e40f42e7a6943b026 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Mon, 30 Sep 2024 16:12:10 +0200 Subject: [PATCH 1/2] ENH: add progress bar when creating local indexes --- cropclassification/util/mosaic_util.py | 21 ++++++++++++--------- environment-dev.yml | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cropclassification/util/mosaic_util.py b/cropclassification/util/mosaic_util.py index a8dfa8a7..f81f0621 100644 --- a/cropclassification/util/mosaic_util.py +++ b/cropclassification/util/mosaic_util.py @@ -7,6 +7,8 @@ from typing import Any, Optional import pyproj +from tqdm import tqdm +from tqdm.contrib.logging import logging_redirect_tqdm from . import date_util, openeo_util, raster_index_util, raster_util @@ -256,15 +258,16 @@ def calc_periodic_mosaic( ) # Process the mosaic images to be generated locally. - for image_local in images_local: - # Prepare index output file path - raster_index_util.calc_index( - image_local["base_image_path"], - image_local["path"], - index=image_local["index_type"], - pixel_type=image_local["pixel_type"], - force=force, - ) + with logging_redirect_tqdm(): + for image_local in tqdm(images_local): + # Prepare index output file path + raster_index_util.calc_index( + image_local["base_image_path"], + image_local["path"], + index=image_local["index_type"], + pixel_type=image_local["pixel_type"], + force=force, + ) return periodic_mosaic_params diff --git a/environment-dev.yml b/environment-dev.yml index 027f9813..0f740e41 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -20,6 +20,7 @@ dependencies: - rasterio - rasterstats - rioxarray + - tqdm # Optional - qgis # testing From be45b6a4fc9c2fc9754b9df2ddb2682f60e4d0b0 Mon Sep 17 00:00:00 2001 From: Pieter Roggemans Date: Mon, 30 Sep 2024 16:26:38 +0200 Subject: [PATCH 2/2] Update tqdm deps --- ci/envs/latest.yml | 7 +++---- ci/envs/minimal.yml | 11 +++++------ environment-dev.yml | 5 ++--- setup.py | 1 + 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ci/envs/latest.yml b/ci/envs/latest.yml index e4c7da6a..51e8b4c0 100644 --- a/ci/envs/latest.yml +++ b/ci/envs/latest.yml @@ -5,20 +5,19 @@ dependencies: - python - pip # required - - fiona - geofileops - geopandas>=0.11 - h5py - - numpy + - numpy<2 - openeo - pandas - psutil - pyproj - - scikit-learn - rasterio - rasterstats - rioxarray - - numpy<2 + - scikit-learn + - tqdm # Optional - qgis # testing diff --git a/ci/envs/minimal.yml b/ci/envs/minimal.yml index bab7260f..f1ab177a 100644 --- a/ci/envs/minimal.yml +++ b/ci/envs/minimal.yml @@ -3,22 +3,21 @@ channels: - conda-forge dependencies: - python + - pip # required - - fiona - geofileops - - geopandas>=0.11 + - geopandas-base>=0.11 - h5py - - numpy + - numpy<2 - openeo - pandas - psutil - pyproj - - scikit-learn - rasterio - rasterstats - rioxarray - - numpy<2 - - pip + - scikit-learn + - tqdm # Optional # - qgis # testing diff --git a/environment-dev.yml b/environment-dev.yml index 0f740e41..f9f010af 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -5,9 +5,8 @@ dependencies: - python=3.10 - pip # required - - fiona - geofileops - - geopandas>=0.11 + - geopandas-base>=0.11 - h5py - numpy<2 # Openeo >=0.14 +- doesn't work on windows. @@ -16,10 +15,10 @@ dependencies: - pandas - psutil - pyproj - - scikit-learn - rasterio - rasterstats - rioxarray + - scikit-learn - tqdm # Optional - qgis diff --git a/setup.py b/setup.py index e0a3e19c..ef4a9b6c 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,7 @@ "tensorflow", "numpy<2", "exactextract", + "tqdm", ], entry_points=""" [console_scripts]