A Django REST Framework backend for accessing climate datasets from the UK MetOffice.
- Create Virtual Environment
python3 -m venv .venv- Activate Virtual Environment
source .venv/bin/activate- Install Required Dependencies
pip install -r requirements.txt- Apply Migrations
python3 manage.py migrate- Create
.envfile and add required environment variables
MANAGE_PY_PATH=manage.py
SECRET_KEY="<django-secret-key>"
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost
CORS_ALLOWED_ORIGINS=http://127.0.0.1:5173,http://localhost:5173- Load climate data from UK MetOffice
python3 manage.py load_datasets- Run server
python3 manage.py runserver- Test Coverage
-
Run tests with coverage
coverage run manage.py test -
See coverage report on terminal
coverage report
-
Generate HTML report
coverage html
- Run mypy type checking
mypy .- Fix formatting using black
black .- Sort imports using isort
isort --profile black --check-only .- Run pylint for code quality checks
pylint **/*.py- Pre Commit Hook
-
Install pre commit dependencies
pre-commit install
-
Run pre-commit hooks manually
pre-commit run --all-files
- Setup pre push hook
cp .githooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push- Install recommended VS Code extensions
-
Open the extensions sidebar in VS Code
ctrl+shift+xorcmd+shift+x -
Type @recommended in the search bar
-
Install the recommended extensions
- Setup VS Code test runner
-
Add manage.py path variable in
.envfileMANAGE_PY_PATH=manage.py
- Load climate data from UK MetOffice
python3 manage.py load_datasets- Generating OpenAPI Schema
python3 manage.py spectacular --validate --color --file schema.yml- Setup required environment variables for github workflow
- Create super user
python manage.py createsuperuser- Build and start containers
docker-compose -f docker-compose.dev.yml up --build- Start in detached mode
docker-compose -f docker-compose.dev.yml up -d- Stop containers
docker-compose -f docker-compose.dev.yml down- Open a shell inside backend service container
docker-compose -f docker-compose.dev.yml exec backend bash- Note: Run any Django command inside the container
python manage.py <command>- Shortcut without opening shell
docker-compose -f docker-compose.dev.yml exec backend python manage.py <command>- See backend service container logs
docker-compose -f docker-compose.dev.yml logs -f backend- Restart backend service
docker-compose -f docker-compose.dev.yml restart backend🔗 Web App: Weather Frontend Repository