Skip to content

Latest commit

 

History

History
89 lines (65 loc) · 3.87 KB

development.md

File metadata and controls

89 lines (65 loc) · 3.87 KB

Development reference

Start with the README quickstart. Commands below assume the repository root and an activated virtual environment.

CSV and SQLite workflow

The activity workflow loads runs and weather, matches them by time, and can save both matches and skipped runs in SQLite. It remains available alongside the race report.

python -m runwx run
python -m runwx run --csv
python -m runwx run --csv --db runwx.db
python -m runwx query --db runwx.db --limit 10

The first command uses built-in demo data. --csv uses the sample CSV files under data/; --data-dir selects another directory containing sample_runs.csv and sample_weather.csv. The --db command creates or updates the local SQLite file.

The CSV adapters also accept caller-supplied run and weather filenames. They validate rows and convert them to domain objects before the pipeline runs.

See CSV adapters and SQLite adapters for the implementation.

Domain models

  • Run(started_at, duration_s, distance_m) describes a running activity.
  • WeatherObs(observed_at, temp_c, wind_mps, precipitation_mm, humidity_pct) describes a weather observation.
  • RunWithWeather(run, weather) holds a matched pair.

These domain dataclasses are frozen. Timestamps must be timezone-aware; duration and distance must be positive; wind speed and precipitation cannot be negative. Weather measurements must be finite; finite negative temperatures remain valid. Input schemas validate external data before conversion.

The pipeline loops through runs, aligns weather, attaches valid matches and records skipped runs with reasons. See the matching rules and domain code.

Package structure and API

The package uses these layers:

Module Responsibility
runwx.domain Domain types and core logic
runwx.services Use-case flows built on domain logic
runwx.adapters CSV, SQLite, API and other external I/O
runwx.main / runwx.__main__ CLI wiring for python -m runwx

python -m runwx is the stable CLI entrypoint. Internal code should import from runwx.domain.*, runwx.services.* and runwx.adapters.*.

Top-level runwx.* compatibility aliases remain so older imports continue to work. They are compatibility paths, not the main API for new internal code.

Contributing

Put business rules and entities in runwx.domain, use-case flows in runwx.services, and persistence/integrations in runwx.adapters. Keep runwx.main focused on CLI wiring and use the canonical imports above.

The README tests section gives the test commands. Keep ordinary tests deterministic and independent of credentials or live providers. The report tests cover repeated output, source hashes, changed settings, malformed result rows and missing weather while blocking network access.

CI checks

The workflow runs the Python tests, builds the report image and checks its CLI, and checks Terraform formatting and configuration. Terraform initialization uses the committed provider lock with no backend. The dbt job builds its locked image and parses the historical-snapshot project. Container CLI/parsing checks run with networking disabled and no credentials. Installing packages/providers and building images can require internet access.

These checks do not apply Terraform or execute warehouse SQL. Parsing detects configuration and reference errors, not every SQL error; real dbt unit/data tests remain a separate BigQuery integration check. Image dependencies have their own update procedure.

Related documentation