daedalus.api is an API package for the daedalus package and is primarily intended for internal use.
You can install the development version of daedalus.api from GitHub with:
# install.packages("devtools")
devtools::install_github("jameel-institute/daedalus.api")
# the image will be assigned the tag 'latest'
docker pull mrcide/daedalus.api:latest
# run the container
# see docker run --help for options
docker run -d --name daedalus-api --rm -p 8001:8001 mrcide/daedalus.api:latest
# check root endpoint `GET/`
curl -s http://localhost:8001 | jq
# stop the service
docker stop daedalus-api
To add an endpoint, implement a method in api.R
with @porcelain
comment, then run roxygen2::roxygenize()
to generate the porcelain code
in porcelain.R
. See the porcelain docs for more details.
Redis needs to be running for the e2e tests to pass. Use ./scripts/redis start
, and tear down with ./scripts/redis kill.
The API should be backwards compatible and support running older versions of the model.
Some endpoints support providing modelVersion
as part of the body, e.g. to run or get metadata for a particular version of the model.
Metadata is stored in the inst/json
folder, in files named metadata_[VERSION].json
where [VERSION]
is the first model version where
that metadata applied. Requesting metadata for a model version will return the metadata which applies to that version, (which may have been
first introduced in an earlier version). The metadata response includes a modelVersion
property - this value will be the modelVersion
requested in the query string, if provided. If modelVersion
was not provided in the query string, the returned
model version will be the most recent metadata's [VERSION]
.
See the daedalus package which implements the DAEDALUS integrated model of economic, social, and health costs of a pandemic.