ropensci / traits

R package for accessing species trait data from multiple databases
Other
41 stars 13 forks source link

no access to BETYdb api #18

Closed dlebauer closed 9 years ago

dlebauer commented 9 years ago

What I want to do:

To evaluate the new bety functions, I started with the examples in the bety_traits function and in the README:

out <- bety_traits(genus = 'Miscanthus', species = "giganteus")

Error: Supply either api key, or user name/password combo

So I try the key and user/pwd options:

out <- bety_traits(genus = 'Miscanthus', species = "giganteus", key = "ReDacTEd")
out <- bety_traits(genus = 'Miscanthus', species = "giganteus", user = "guestuser", pwd  = "guestuser")
# guestuser / guestuser should work

Error in function (type, msg, asError = TRUE)  :
  server certificate verification failed. CAfile: /usr/local/lib/R/site-library/httr/cacert.pem CRLfile: none

What I tried:

debugonce(bety_traits)
debugonce(betydb_GET)
debugonce(betydb_http)
## recreate the objects
url <-  "https://www.betydb.org/traits.json"
args <- list(genus = "Miscanthus", species = "giganteus"),

# Browse[6]>
GET(url, query = args, authenticate("guestuser", "guestuser"), ...)

Error in function (type, msg, asError = TRUE)  :
  server certificate verification failed. CAfile: /usr/local/lib/R/site-library/httr/cacert.pem CRLfile: none

Now that I've gotten into the httr package, which I have very little experience with - I see the GET and authenticate functions, but I can't tell at this point if the issue is on the server end or how these functions are used.

Next steps

## the first lines of the betydb_GET and betydb_GET2 functions:
  if(is.null(c(key, user, pwd)){
    user <- 'ropensci-traits'
    pwd <- 'ropensci'
  }
sckott commented 9 years ago

@karthik @cboettig Maybe you already know how to deal with the problem above with the cert file? If not, can you try a few examples so we can see if problems @dlebauer has is general:

Try as an example (after installing latest via install_github("ropensci/traits")):

bety_traits(genus = 'Miscanthus', species = "giganteus", user = "guestuser", pwd  = "guestuser")
Source: local data frame [5,454 x 28]

   access_level checked citation_id created_at cultivar_id                      date date_day date_month
1             4       1          42         NA           3 1995-06-05T19:00:00-05:00        5          6
2             4       1          42         NA           3 1995-04-02T19:00:00-05:00        2          4
3             4       1          42         NA           3 1995-04-10T19:00:00-05:00       10          4
4             4       1          42         NA           3 1995-04-26T19:00:00-05:00       26          4
5             4       1          42         NA           3 1995-06-02T19:00:00-05:00        2          6
6             4       1          42         NA           3 1995-06-19T19:00:00-05:00       19          6
7             4       1          42         NA           3 1995-07-08T19:00:00-05:00        8          7
8             4       1          42         NA           3 1995-09-18T19:00:00-05:00       18          9
9             4       1          42         NA           3 1997-04-29T19:00:00-05:00       29          4
10            4       1          42         NA           3 1996-05-26T19:00:00-05:00       26          5
..          ...     ...         ...        ...         ...                       ...      ...        ...
Variables not shown: date_year (int), dateloc (chr), entity_id (int), id (int), mean (chr), method_id
  (int), n (int), notes (chr), site_id (int), specie_id (int), stat (chr), statname (chr), time (chr),
  time_hour (int), time_minute (int), timeloc (chr), treatment_id (int), updated_at (chr), user_id
  (int), variable_id (int)

there's more egs in the readme https://github.com/ropensci/traits#traits-1

sckott commented 9 years ago

@dlebauer I think it's something wrong with the cert file needed for httr, see eg. , http://stackoverflow.com/questions/26753746/rcurl-or-httr-specifying-cert-info

just tried on a linux docker image runing carl's rocker/hadleyverse, and the example works fine, so i think it is just that cert file

sckott commented 9 years ago

@dlebauer this still not working for you?

dlebauer commented 9 years ago

The example works on both a RHEL server and a Windows desktop.

The original bug on my Ubuntu desktop still holds. I didn't find the stackoverflow post very informative - it is unanswered and I don't understand authentication or curl well enough to translate the example (and that would only allow me to reproduce the error, not fix it). So I still don't know what the problem is or how to debug it.

Since this is not related to the traits package, and it isn't blocking my progress at this point, feel free to close this. Though it would be useful to figure out why the error is occuring.

sckott commented 9 years ago

@dlebauer can we do a screen share at some point, so I can see what's going on your ubuntu desktop? I tried on ubuntu and it worked good, so i think we need to fix a curl problem for you

dlebauer commented 9 years ago

Thanks @sckott and @cboettig for your help. The fix was installing libcurl4-openssl-dev and updating the Rcurl package

$ sudo apt-get install libcurl4-openssl-dev
$ R
> install.packages("RCurl")
sckott commented 9 years ago

@dlebauer thanks for the confirmation on what worked