Skip to content

Commit

Permalink
Merge pull request #53 from flyconnectome/fix/manc_get
Browse files Browse the repository at this point in the history
manc_get supports new Clio API
  • Loading branch information
jefferis authored Nov 9, 2022
2 parents 1737f20 + e1bfc38 commit 2dfed54
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 7 additions & 3 deletions R/annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ list2df <- function(x, points=c('collapse', 'expand', 'list'),
#' default is to return the current active (unlocked) node being used through
#' neutu.
#' @param cache Whether to cache the result of this call for 5 minutes.
#' @param columns_show Whether to show all columns, or just with '_user', or '_time'
#' suffix. Accepted options are: 'user', 'time', 'all'.
#'
#' @return A \code{tibble} containing with columns including \itemize{
#'
Expand Down Expand Up @@ -146,6 +148,7 @@ list2df <- function(x, points=c('collapse', 'expand', 'list'),
#' }
manc_dvid_annotations <- function(ids=NULL, node='neutu',
rval=c("data.frame", "list"),
columns_show = NULL,
cache=FALSE) {
rval=match.arg(rval)
if(!is.null(ids)) {
Expand All @@ -155,7 +158,7 @@ manc_dvid_annotations <- function(ids=NULL, node='neutu',
}
node=manc_nodespec(node, several.ok = F)
mda <- if(cache) manc_dvid_annotations_memo(node=node, rval=rval)
else .manc_dvid_annotations(node=node, rval=rval)
else .manc_dvid_annotations(node=node, rval=rval, show = columns_show)
if(is.null(ids)) mda
else {
mda=mda[match(ids,mda$bodyid),,drop=F]
Expand All @@ -165,9 +168,10 @@ manc_dvid_annotations <- function(ids=NULL, node='neutu',
}
}

.manc_dvid_annotations <- function(node, rval) {
.manc_dvid_annotations <- function(node, rval, show = NULL) {
path="api/node/%s/segmentation_annotations/keyrangevalues/0/Z?json=true"
d=manc_get(path, urlargs = list(node), as = 'parsed', simplifyVector = F)
d=manc_get(path, urlargs = list(node), show = show,
as = 'parsed', simplifyVector = F)
df=list2df(d)
df$bodyid=as.numeric(names(d))
df[['body ID']]=NULL
Expand Down
6 changes: 5 additions & 1 deletion R/fetch.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# simple get request
manc_get <- function(path, urlargs=list(), as='parsed', ..., body=NULL) {
manc_get <- function(path, urlargs=list(), as='parsed', ..., show=NULL, body=NULL) {
u=manc_serverurl(path, urlargs=urlargs)
if(!is.null(body))
return(manc_get_body(u, body, as=as, ...))
if(!is.null(show)) {
show=match.arg(show, choices = c('all', 'time', 'user'))
u = paste0(u, "&show=", show)
}
r=httr::GET(u)
res=httr::stop_for_status(r)
res2=httr::content(res, as=as, type='application/json', ...)
Expand Down
4 changes: 4 additions & 0 deletions man/manc_dvid_annotations.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2dfed54

Please sign in to comment.