-
Notifications
You must be signed in to change notification settings - Fork 13
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
Betydb changes? #25
Comments
We are working on it in https://github.com/dlebauer/traits ... mostly to support development of this package, so if anything the current API should work better. I'll review the recent changes and submit a pull request with our recent updates shortly. |
@dlebauer great! sounds good |
@sckott ... I've been reviewing some or the recent changes to the R functions by @phenolphtalein ... but they are broken ... so it may take a few more days. If you want to take a look, I am getting stuck on the way ... the code I've been working on with new (broken!) tests are in my |
what part exactly? in general, |
…betydb functions pending further revisions to work with BETYdb 4.0 version API; refs ropensci#25, closes #3, refs PecanProject/bety#270
@sckott I added some tests, and thought they were passing - so I have two questions:
I want to search for Willow Vcmax data: debugonce(betydb_http)
betydb_search("Salix Vcmax") ultimately I get to GET(url = "https://www.betydb.org/search.json",
args = list(search = "Salix+Vcmax"),
authenticate(user = 'ropensci-traits', password = 'ropensci')) Which does not restrict the query to either the species ('Salix') or the trait ('Vcmax'). Perhaps the url is not being formed correctly (I am looking for https://www.betydb.org/search.json?Salix+Vcmax) |
hi @dlebauer
|
GET(url = "https://www.betydb.org/search.json",
args = list(search = "Salix Vcmax"),
authenticate(user = 'ropensci-traits', password = 'ropensci')) works as expected ... I'll send a pull request later with my updates |
@sckott Let me know if I should post this on stackoverflow ... I am unfamilar with the httr package and a bit overwhelmed by I can start pasting strings together but also recognize that it is easier to let httr deal with special characters, etc., if it is able. So, I want to paste together some
I am assuming that I am passing the fields I want to parse in as a list, and they are in the format I want to get the singular version of the tablename and construct the url This is what I have so far ... any assistance would be appreciated! get_includes <- function(args) {
ans <- list(`include[]=` = ifelse(any(grepl('species', names(args))), "specie", NULL),
`include[]=` = ifelse(any(grepl('variables', names(args))), 'variable'))
return(ans)
}
args <- list(species.genus = "Acer", variables.name = "leafN")
includes <- get_includes(args)
GET(url = "https://www.betydb.org/search.json",
args = args,,
## where can I put the includes statement?
authenticate(user = 'ropensci-traits', password = 'ropensci')) |
@dlebauer hmmm, just trying URLs in a browser, I can get other endpoints to work, e.g https://www.betydb.org/traits.json , but I don't think it's an httr problem to pass parameters, use the |
when you say the trouble I am having is in the named list, e.g. is this what should work? args <- list(species.genus = 'Acer', `include[]=` = "specie", `include[]=` = "variable") |
Ah, okay, maybe it just was taking a long time. Yeah, I can't get those |
@gsrohde, @phenolphtalein is there an alternative to using the |
@dlebauer The short answer is that you can program any API you want if one is willing to do the work. The advantage of the include[]= syntax is that that is the built-in way of representing an array of values connected with a single key. For example, if you had a form with a group of checkboxes or a multi-select box, the portion of the query string constructed from this would look like "key[]=value1&key[]=value2&key[]=value3 ", where "key" is the name of the variable associated with the checkbox group or the multi-select box and values 1, 2, and 3 are the values you selected. That said, it's actually true that in general you don't need the square brackets if you only have one include in your query string, and this was working in BETYdb until I added some code to restore the output of included entities after the updgrade to Rails 3.2. In writing that code, I neglected to accommodate this use case, but it shouldn't be hard to do so if desired. Looking back over the previous comments in this issue, I see that you are trying to use the "include[]=" syntax on the traits_and_yields_view. I don't think this will work at all without some additional work since we haven't told Rails to associate this table (view) with any other table. |
Ok. It's not implemented for the search.json endpoint. that's okay. I'll
|
@gsrohde thanks for the feedback.
thanks, now that makes more sense |
@dlebauer I'm removing trait related functions from let's try to wrap up any betydb stuff soon for the v0.1 push to CRAN |
When do you want to push to CRAN? |
@dlebauer in the next week or two would be good |
@sckott this issue can be closed ... I'll make new ones as needed |
okay, thanks |
hey @dlebauer anything we need to change here regarding https://zenodo.org/record/17128 ?
The text was updated successfully, but these errors were encountered: