isciences / exactextract

Fast and accurate raster zonal statistics
Apache License 2.0
258 stars 33 forks source link

Processor: Allow client to specify progress callback function #128

Closed dbaston closed 2 months ago

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 86.56716% with 18 lines in your changes missing coverage. Please review.

Project coverage is 90.73%. Comparing base (5cfeff2) to head (6b4dde4). Report is 3 commits behind head on master.

Files Patch % Lines
python/src/exactextract/exact_extract.py 55.00% 9 Missing :warning:
src/utils_cli.cpp 0.00% 3 Missing :warning:
src/feature_sequential_processor.cpp 89.47% 2 Missing :warning:
src/processor.h 77.77% 2 Missing :warning:
python/src/exactextract/feature.py 87.50% 1 Missing :warning:
src/exactextract.cpp 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #128 +/- ## ========================================== + Coverage 90.52% 90.73% +0.20% ========================================== Files 85 85 Lines 6082 6176 +94 Branches 611 611 ========================================== + Hits 5506 5604 +98 + Misses 544 540 -4 Partials 32 32 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

JakubCha commented 2 months ago

Hello Dan. I don't know if it's the correct place to ask. I can move it to issues if preferred. Do you plan to expose this functionality to Python API? I'd make use of this in the QGIS plugin as right now I have no way of reporting to user progress of calculating stats.

dbaston commented 2 months ago

Yes, I would expose it to Python. I am wondering if I should also extend it to directly provide a progress percentage.

JakubCha commented 2 months ago

It would be nice to have that as well. I wonder how it would work in Python API.

Am I thinking about it correctly?

dbaston commented 2 months ago

@JakubCha Currently yes, the progress callback is invoked either once per feature or once per raster chunk. In the per-chunk case, the caller has no simple way to know how many chunks there will be, so I've updated the progress bar to take two arguments: the fraction completed, and an informational message. This would also allow providing more frequent progress updates when a feature needs to subdivided to limit memory usage, or when a raster chunk has many intersecting features.