mapme-initiative / mapme.biodiversity

Efficient analysis of spatial biodiversity datasets for global portfolios
https://mapme-initiative.github.io/mapme.biodiversity/dev
GNU General Public License v3.0
33 stars 7 forks source link

Progress bar not working with chirps #193

Closed fBedecarrats closed 1 year ago

fBedecarrats commented 1 year ago

Hello, in the following reprex, the progess bar is not working:


# Load librairies
library(aws.s3)
library(tidyverse) # toolkit for data manipulation
library(geodata) # to get municipalities
library(sf) # to handle spatial data (vectors)
library(terra) # to handle patial data (rasters)
library(mapme.biodiversity) # to compute spatial indicators
library(future) # to parallelize computations
library(exactextractr) # engine for mapme.biodiversity
library(SPEI) # to compute rainfall  
library(progressr) # for progress bars

# Download Senegal municipalities as areas of interest
aoi <- gadm("SEN", level  = 3, path = "data") %>%
  st_as_sf()  %>%
  st_cast("POLYGON")

aoi <- init_portfolio(aoi, years = 1990:2020,
                      outdir = "data", add_resources = TRUE) 

# we use parallel computing to reduce processing time
plan(multisession, workers = 8)

aoi <- aoi %>%
  get_resources("chirps")

# Compute precipitation indicators
with_progress({ # to have a progress bar 
  aoi <- aoi %>%
    calc_indicators("precipitation_chirps",
                    engine = "exactextract",
                    scales_spi = 3,
                    spi_prev_years = 8)
}) # progress bar does not seem to work
```r
Is this somblem with my sintak or is it due to the package?
goergen95 commented 1 year ago

Hmm, issues with the progress bar should not be related to a specific indicator. Does this code return successfully without error or is it maybe stuck with downloading the resources?

goergen95 commented 1 year ago

It is however possible that updates to the progress bar are delayed a bit when parallel processing is enabled.

goergen95 commented 1 year ago

The reason a progress bar is not shown is that CHIRPS is processed in portfolio mode. In this mode we currently have no sensible progress reporting implemented.

fBedecarrats commented 1 year ago

Thanks for the feedback @goergen95 !