bio-oracle / biooracler

R package to access Bio-Oracle data via ERDDAP
Other
8 stars 2 forks source link

Change default cache dir? #4

Closed salvafern closed 1 year ago

salvafern commented 2 years ago

Now the dataset is downloaded to the working directory. We should consider to change to a temporal directory instead:

# Test variables
url = "https://erddap-test.emodnet.eu/erddap/"
datasetid = "biooracle_dmo_ds"
time = c('2001-01-01T00:00:00Z', '2010-01-01T00:00:00Z')
latitude = c(10, 20)
longitude = c(120, 130)
variables = c("o2_mean")
constraints = list(time, latitude, longitude)
names(constraints) = c("time", "latitude", "longitude")

# Test call
test <- download_griddap_dataset(url, datasetid, variables, constraints)
test$summary$filename
#> [1] ".//d5fdcdcee90dae608f624e73935473f7.nc"
vinisalazar commented 2 years ago

Hi @salvafern, thank you for organising the issues here.

The default of rerddap is to download the files to a cache/temporary directory in the R folder, but I changed it to the current directory. What do you think would be the best default directory? Note that the destination directory can be changed by the directory argument of the function.

salvafern commented 2 years ago

Good question. I actually don't know if there is any preference for the best default directory. Seems like rerddap reads the env var RERDDAP_CACHE_PATH.

Some options:

  1. Use temporal directories by default as in sdmpredictors. But actually I'm just thinking that the default behavior any user may want is that the data is cached.
  2. Continue using rerddap approach, less stress.
  3. Copy the approach from https://github.com/OlivierBinette/cache and work more oriented to projects: e.g. cache by default in a directory created on the root of the project as ./cache-R (and add this path to gitignore if exists).

I kind of like more the last option, but I'm not an expert in this topic. What do you think @vinisalazar ?

Of course I would always leave the option to cache in any given directory. And I would read the default cache dir from the environment as rerddap and many other packages.

salvafern commented 2 years ago

@vinisalazar and I had a chat: we will look into how rerddap handles the cache directory. We will either just explain the user how to do it or add a simple wrapper for bioracler