An API to provide carbon emission estimates for flights, events and other activities.
Assuming pyenv is used to manage virtual environments:
pyenv virtualenv 3.10 310-discarbon-emission-api
pyenv shell 310-discarbon-emission-api
pip install -r requirements.txt
uvicorn app.main:emission_api --reload
docker build -t discarbon-emission-api .
docker run -it --init -p 8000:8000 -e PORT=8000 discarbon-emission-api
Read the doc; http://127.0.0.1:8000/docs
Try an endpoint: http://127.0.0.1:8000/emissions/travel/planeByIATA/ZRH/ABZ/economy
The pre-commit
framework has been configured for this repo with the following checks (hooks) for linting, import sorting and code auto-formatting:
Use of pre-commit
is not a strict requirement, but is highly recommended as these checks are ran as part of Github actions. If pre-commit
is enabled, these checks must pass before git commit
runs successfully. Run the following to use pre-commit
:
pip install -r requirements_dev.txt
pre-commit install
The commit hooks can be ran without running git commit
via:
pre-commit run --all-files
Upon git push
pytest additionally runs some smoke tests to ensure the app can be started:
pre-commit run --all-files --hook-stage=push
The VS Code settings for these tools in .vscode/settings.json
should help the pre-commit hooks pass.
Run the tests locally:
pip install -r requirements_dev.txt
pip install -e .
pytest