Make batches of AJAX style concurrent requests. Used to run multiple asynchronous tasks in parallel and wait for them all to complete before further batch-wise processing.

neuromorpho_async_req(
  urls,
  FUN = neuromorphr:::neuromorpho_parse_json,
  batch.size = 10,
  progress = NULL,
  message = NULL,
  ...
)

Arguments

urls

URLs to be queried

FUN

a function to run on the responses to requests made using urls. If NULL, the response is returned without any processing. The default is to parse returned JSON format.

batch.size

the number of requests sent at once to the neuromorpho.org, using multi_run. Requests are sent to neuromorpho.org in parallel to speed up the process of reading neurons. Batches of queries are processed serially. Increasing the value of batch.size may reduce read time.

progress

if TRUE or a numeric value, a progress bar is shown. The bar progresses when each batch is completed. If TRUE, or 100, the bar completes where all batches are done.

message

a message to be given alongside progress bar

...

methods passed to FUN

Value

a list of data retrieved from the requests defined by urls, and processed by FUN

Details

Speed querying neuromorpho.org by making batches of AJAX style concurrent requests, using using multi_run, and running a custom function on the responses to these requests.

Examples

if (FALSE) { 
# Let's just grab metadata for all neurons in neuromorpho
all.species = neuromorpho_field_entries(field="species")
urls = paste0("http://neuromorpho.org/api/neuron/select?q=species:", 
              all.species) 
res = neuromorpho_async_req(urls = urls, 
                            batch.size = 10, 
                            progress = TRUE, 
                            message = "having a look")
}