- Python version 3.12
- Docker
- npm
Inside the backend directory:
-
Make a copy of
.env.templateand rename it to.env -
Start a postgres instance with docker using:
$ docker run -d \
--name postgres \
-e POSTGRES_PASSWORD=app \
-p 5432:5432 \
postgres:16- Create a python virtual environment:
$ python3.12 -m venv .venv
$ source .venv/bin/activate- Install the requirements:
$ pip install -r requirements.txt && pip install -r requirements-dev.txt - Run migrations:
$ alembic upgrade head- Start the server:
$ PYTHONPATH=. fastapi dev app.pyInside the frontend directory:
-
Make a copy of
.env.templateand rename it to.env -
Install dependencies:
$ npm ci- Start the app:
$ npm run devThe UI should now be running on http://localhost:1573
To run all non-data tests, run the following command:
$ PYTHONPATH=. SETTINGS_FILE=test-settings.ini pytest -m "not data"You can run just a specific test using:
$ PYTHONPATH=. SETTINGS_FILE=test-settings.ini pytest tests/test_query/<FILE_NAME>::<TEST_NAME>To check test coverage when running tests:
$ PYTHONPATH=. SETTINGS_FILE=test-settings.ini pytest -m "not data" --cov=. --cov-report html:cov_html --order-dependenciesHere's a breakdown:
PYTHONPATH=.-- The gods alone know why, but this is necessary for fastapiSETTINGS_FILE=test-settings.ini-- directs the program to use test settings, which for the moment simply point it to the test databasepytest-- the base command at the root of all of this: run the tests-m "not data"-- selects all tests that are not marked withdata. There are many other markers for the tests; see pytest.ini for a complete list.--cov=.-- enable coverage checking; the coverage configuration can be found at .coveragerc--cov-report html:cov_html-- generates a report of coverage in HTML, which can be accessed in the generated cov_html directory. Link will not work if you have not run the tests at least once.--order-dependencies-- test dependency will be taken into account when determining running order for tests. In our case, we use the data from testing observation creation to test our query structures and aggregation math.
To run the data tests, run the following command:
$ pytest -m data