Skip to content

Latest commit

 

History

History
104 lines (73 loc) · 2.55 KB

File metadata and controls

104 lines (73 loc) · 2.55 KB

Development

Running Locally:

Requirements

  • Python version 3.12
  • Docker
  • npm

Backend

Inside the backend directory:

  1. Make a copy of .env.template and rename it to .env

  2. Start a postgres instance with docker using:

$ docker run -d \
  --name postgres \
  -e POSTGRES_PASSWORD=app \
  -p 5432:5432 \
  postgres:16
  1. Create a python virtual environment:
$ python3.12 -m venv .venv
$ source .venv/bin/activate
  1. Install the requirements:
$ pip install -r requirements.txt && pip install -r requirements-dev.txt 
  1. Run migrations:
$ alembic upgrade head
  1. Start the server:
$ PYTHONPATH=. fastapi dev app.py

Frontend

Inside the frontend directory:

  1. Make a copy of .env.template and rename it to .env

  2. Install dependencies:

$ npm ci
  1. Start the app:
$ npm run dev

The UI should now be running on http://localhost:1573

Testing Locally:

Non-Data Tests

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-dependencies

Here's a breakdown:

  • PYTHONPATH=. -- The gods alone know why, but this is necessary for fastapi
  • SETTINGS_FILE=test-settings.ini -- directs the program to use test settings, which for the moment simply point it to the test database
  • pytest -- the base command at the root of all of this: run the tests
  • -m "not data" -- selects all tests that are not marked with data. 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.

Data Tests

To run the data tests, run the following command:

$ pytest -m data