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

Sqlite direct download #37

Merged
merged 29 commits into from
Oct 22, 2019
Merged

Sqlite direct download #37

merged 29 commits into from
Oct 22, 2019

Conversation

ateucher
Copy link
Contributor

This PR does two major things:

  1. Provides the historic sqlite database as a direct download from a rems release. This means that download_historic_data() does not involve reading the csv from the BCDC and iteratively loading it into sqlite. That process is now done by the package maintainer and download_historic_data() simply downloads the sqlite file and stores it in the rems data dir.

  2. Allow a user to specify/customize the location of the sqlite database via an option rems.historic.path - (getOption("rems.historic.path", default = rems_data_dir()))

@ateucher
Copy link
Contributor Author

ateucher commented Oct 16, 2019

To test:

remotes::install_github("bcgov/rems@sqlite-path")
rems:::burn_it_down()

### Restart R session before proceeding ###

library(rems)
download_historic_data()
read_historic_data(emsid = "0400203", from_date = as.Date("1984-11-20"),
                   to_date = as.Date("1991-05-11"))

@ateucher
Copy link
Contributor Author

@sebdalgarno
Copy link
Contributor

this is a great idea @ateucher ! I have followed the instructions above. I am able to initiate downloading the data but have now failed on 5 attempts (all at different stages of completion). I do feel that my poor Haida Gwaii may be the culprit. Hopefully someone else can test as well to confirm.

Copy link

@HeatherGranger HeatherGranger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto, great idea. I got a couple function errors when I ran it. Am I missing something?

` > download_historic_data()
Error in .remsCache$exists("cache_dates") :
attempt to apply non-function

read_historic_data(emsid = "0400203", from_date = as.Date("1984-11-20"),
to_date = as.Date("1991-05-11"))
Error in .remsCache$exists("cache_dates") :
attempt to apply non-function`

@sebdalgarno
Copy link
Contributor

@HeatherGranger can you try restarting your R session prior to running library(rems) and all that follows?

@ateucher
Copy link
Contributor Author

Ah yes, I forgot to mention that. Instructions updated

@HeatherGranger
Copy link

That worked. It's currently downloading. I'll report back on it's success!

@HeatherGranger
Copy link

Success! downloaded, stored and read in the data.

@ateucher
Copy link
Contributor Author

Thanks for testing @HeatherGranger - that's great!

@ateucher
Copy link
Contributor Author

@sebdalgarno I've just pushed a commit to allow passing httr::GET configurations. Can you try with a really long timeout threshold (timeout() value is in seconds)? eg.

download_historic_data(ask = FALSE, force = TRUE, httr_config = timeout(5000))

@sebdalgarno
Copy link
Contributor

@ateucher I'm trying now with timeout(5000) as suggested. Will report back soon!

@boshek
Copy link

boshek commented Oct 16, 2019

Similar success over here 🎉

@ateucher
Copy link
Contributor Author

Thanks @boshek - that's great!

@sebdalgarno
Copy link
Contributor

Well I set up a better cell signal booster in my tree this morning and can now say I have successfuly downloaded the historic dataset! thanks @ateucher for the changes.

@ateucher
Copy link
Contributor Author

Excellent! I have a bit more cleanup to do then I will merge this to master

@ateucher
Copy link
Contributor Author

One thing I haven't tested is updating if you had an old version without using burn_it_down(). @j-krogh can you please try the above without using burn_it_down()? i.e.:

remotes::install_github("bcgov/rems@sqlite-path")
library(rems)
download_historic_data()
read_historic_data(emsid = "0400203", from_date = as.Date("1984-11-20"),
                   to_date = as.Date("1991-05-11"))

@j-krogh
Copy link

j-krogh commented Oct 17, 2019

@ateucher done, all seems to be working!

@ateucher ateucher merged commit 967e2fb into master Oct 22, 2019
@ateucher ateucher deleted the sqlite-path branch October 22, 2019 00:00
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.

5 participants