DocsDevelopment and validation

Development and validation

requirements.txt pins the direct runtime packages used across Python 3.10-3.14. requirements-container.txt additionally locks every transitive package in the Python 3.11 production image. When dependencies change, update both and rebuild the container; CI audits the production lock.

Local setup

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

Copy config.json.sample to config.json (ignored by Git) and point pathStorage at a directory holding collector CSV files:

<pathStorage>/<station>/YYYY/MM/DD/<station>_YYYYMMDDZHH00.csv

Automated checks

python -m pip install -r requirements-dev.txt
ruff check .
ruff format --check .
mypy
python -m compileall -q main.py webapp_wsgi.py sensor_network_pwa tests
python -m unittest discover -s tests -v

pyproject.toml configures ruff (lint rules, 120-column formatting) and mypy.

tests/test_web_and_auth.py uses temporary files only; no collector, broker, InfluxDB, or SMTP server is needed. It covers configuration loading without collector settings, login redirects, anomaly and access-log access, HTML/script escaping, cross-site write rejection, cookie and response headers, password policy, single-use tokens, default-admin handling, sandboxed logo serving, download cleanup, limited row loading, non-finite values, watchdog resilience, failure notifications (disabled email, status changes, reminders, profile actions, login link), enforced password changes, rows longer than the CSV header, map popup escaping, session-secret fallback, the onboarding-only username check, email validation of account requests, hiding of restricted stations, selection of hourly files, the unchanged-poll shortcut, response compression, chart thinning, dashboard cards for interleaved device rows, the administration page actions, station page ranges, paging and CSV export, and the progressive web app assets (doctype, manifest, icons, service worker), and the static scripts and stylesheets of the pages (served, compressed, free of inline code and template syntax). It also covers Can API, Can workflows, API-token CRUD and Bearer authentication, query/download authorization, workflow CRUD and validation, station isolation, and edge-triggered workflow email execution.

The workflow editor JavaScript can be syntax-checked separately when Node.js is available:

node --check sensor_network_pwa/web/static/js/workflows.js
node --check sensor_network_pwa/web/static/js/api_tokens.js

docs/workflows-api.md is both repository documentation and the source rendered by the public /docs/workflows-api route. Update that file rather than maintaining a separate web-page copy. Production images must continue to copy docs/.

Container checks

docker build -t sensor-network-pwa:check .
docker run --rm sensor-network-pwa:check python main.py --help
docker run --rm --volume "$PWD/tests:/tests:ro" sensor-network-pwa:check \
  python -m unittest discover -s /tests -v

Modules, templates and static files inside sensor_network_pwa/, plus the canonical online documentation under docs/, are copied into the image. If adding another runtime file outside them, update both .dockerignore and the Dockerfile copy list.

This page is rendered directly from docs/development.md.
You are offline. Data shown may be out of date.