The project is contained in three repos:
ccm
: The core model.
The Cross-Cause Cost-Effectiveness Model is a Python program that provides functions for computing distributions of outcome effectiveness under several models of intervention efficacy -- notably, existential risk and animal welfare.
ccm_api
: The web server.
The project includes a web app for visualizing these distributions. The functions of ccm
are served through an openapi framework built in ccm_api
.
ccm_react
: The front-end web app. This talks with theccm_api
server and displays results in html.
You should have:
- Python 3.10
- Poetry
- node 18
- npm
From the top-level project directory, run:
poetry install
cd ccm_react; npm install
You don't need to re-run these commands unless the project dependencies change.
Running poetry shell
will spawn a new shell within the virtual environment. You can run exit
to exit the virtual environment.
You can also configure your editor to use this virtual environment. You can find the relevant path by running poetry env info -p
.
- To start the API server, run
uvicorn ccm_api.main:app --reload
ornpm run uv
from the top-level directory. - To see the API documentation, navigate to
http://localhost:8000/docs
in your browser.
Note Web functionality requires the API being running locally.
- Install the dependencies by running
npm install
in theccm_react
directory. - Run
npm run dev
to start the development server. - Navigate to
http://localhost:5173/
. - To see the UnoCSS inspector, navigate to
http://localhost:5173/__unocss/
in your browser.
- The react app automatically configures some utilities to the structures returned by the webserver.
After making changes to the API, you need to regenerate the client in
ccm_react
:- Start up the API. If it was already running, top it and restart it.
- While the API is running, from
ccm_react
, runnpm run generate-client
.
- To run all Python tests:
pytest
- Add
-s
argument to run all tests verbosely showing all stdout - Add
-m "not slow"
to skip slow tests
- Add
- You can also run individual test cases by providing the name:
pytest tests/test_population.py::test_get_life_years_affected
- To run JavaScript tests:
npm run test
from theccm_react
directory - To run Cypress E2E tests:
npm run test-cypress
from theccm_react
directory
- To validate Python code, run
ruff check .
andpyright
. - To format Python code, run
black
. - To format JavaScript code,
cd ccm_react
and runnpm run format
. - To validate JavaScript code,
cd ccm_react
and runnpm run lint
.