Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract download limits directly from WFS #256

Merged
merged 14 commits into from
Mar 26, 2021
Merged

Extract download limits directly from WFS #256

merged 14 commits into from
Mar 26, 2021

Conversation

boshek
Copy link
Collaborator

@boshek boshek commented Mar 25, 2021

This PR:

  • Create a bcdc_single_download_limit function
  • Tests that function
  • Uses that function to set the "bcdata.single_download_limit" on package load
  • Directly access that option is a few functions

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

@boshek boshek marked this pull request as ready for review March 25, 2021 22:58
@boshek
Copy link
Collaborator Author

boshek commented Mar 25, 2021

@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:

test_that("bcdata.single_download_limit can be changes",{
lt <- withr::local_options(list(bcdata.single_download_limit = 13),
getOption("bcdata.single_download_limit"))
expect_equal(lt$bcdata.single_download_limit, 13)
})

But that doesn't seem to stick.

Co-authored-by: Andy Teucher <andy.teucher@gov.bc.ca>
@ateucher
Copy link
Collaborator

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...

R/bcdc_options.R Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants