R/fetch.R
neuromorpho_async_req.Rd
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,
...
)
URLs to be queried
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.
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.
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.
a message to be given alongside progress bar
methods passed to FUN
a list of data retrieved from the requests defined by urls
, and processed by FUN
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.
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")
}