bcgov / bcdata

An R package for searching & retrieving data from the B.C. Data Catalogue
https://bcgov.github.io/bcdata
Apache License 2.0
81 stars 12 forks source link

Extract download limits directly from WFS #256

Closed boshek closed 3 years ago

boshek commented 3 years ago

This PR:

Not yet implemented: ~- A test that makes sure one can reset that option.~

boshek commented 3 years ago

@ateucher any thoughts on how to test to see if one can change an option if it is set by package load?

I tried this: https://github.com/bcgov/bcdata/blob/919333c705d7b2ab102475f1f6fd7bacf68b56fe/tests/testthat/test-options.R#L37-L41

But that doesn't seem to stick.

ateucher commented 3 years ago

Sorry, I didn't look closely enough at your approach...

What if we did this:

  1. In .onLoad, we set ._bcdata_env$bcdata_dl_limit <- bcdc_single_download_limit()
  2. When we need that value (e.g., here, here), we call getOption("bcdata.single_download_limit", default = ._bcdata_env$bcdata_dl_limit)

This allows a user to set the option, but if they don't we have a safe default - and someone couldn't inadvertently unset it (e.g., with options(bcdata.single_download_limit = NULL), which would leave everything in a broken state.

This would also allow us to check a user's set option against the catalogue's hard cap and throw an error if it's higher...