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")
# run the api container with queue worker
# This pulls and runs image for current SHA. If none is pushed to registry you can build and push
# locally using ./docker/build
./docker/run_containers
# check root endpoint `GET/`
curl -s http://localhost:8001 | jq
# stop the containers
./docker/clear_containers
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.
To test the integration of this package within the entire system including the dashboard, use the daedalus-deploy tool to install and run all images locally, following the README. You should alter the common config file (daedalus.yml
) so that the API image tag value points to the feature branch of this package that you want to test, e.g.:
# daedalus.yml
api:
image:
repo: mrcide
name: daedalus.api
tag: jidea-297
Ensure that your start-up command uses the --pull
option so that the deploy tool requests the latest versions of the images. Then visit https://localhost/
in your browser to do your manual testing (ignoring warnings from your browser that the site is not secure).
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.