Skip to content

Consolidate ActivityParser's canonical column handling - #7

Merged
tabishm52 merged 1 commit into
mainfrom
default-columns-consolidation
Jul 6, 2026
Merged

tabishm52 merged 1 commit into
mainfrom
default-columns-consolidation

Conversation

@tabishm52

@tabishm52 tabishm52 commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Moves FIT's column renaming and enhanced-column coalescing down into parse_fit_file.py (mirroring parse_tcx_gpx.py), so all three low-level parsers return canonically-named columns.
  • Replaces ActivityParser's six duplicated per-format selector/mapper attributes with a single default_columns.py (DEFAULT_RECORD_COLUMNS/DEFAULT_LAP_COLUMNS), exposed as mutable record_columns/lap_columns instance attributes.
  • Adds an include_all_columns flag to keep non-canonical columns (FIT unknown_*, namespace-qualified TCX/GPX extension columns) instead of dropping them.
  • Drops non-fitness metadata/provenance fields from the defaults (sensor, cadence_sensor, sensor_state, event, event_type, lap_trigger, sport, sub_sport, intensity, notes) and unifies TCX's total_strides under GPX's steps name.

Test plan

  • uv run pytest — all tests pass
  • uv run pre-commit run --all-files — ruff, pyright, pytest all pass

ActivityParser's canonical schema was scattered across six per-format
selector/mapper attributes built in __init__, all kept in sync by hand, and
FIT was the odd one out: unlike parse_tcx_gpx.py, which already renames raw
XML fields to canonical names before returning, parse_fit_file.py returned raw
FIT SDK field names untouched, pushing FIT-specific renaming and enhanced-
column coalescing into ActivityParser itself.

Moves FIT's renaming and enhanced-column coalescing down into parse_fit_file.py
(mirroring parse_tcx_gpx.py), so all three low-level parsers return
canonically-named columns. ActivityParser now selects/reorders against a
single default column list per output (records, laps) defined once in
default_columns.py, instead of six duplicated per-format attributes. Columns
are exposed as mutable record_columns/lap_columns instance attributes so
callers can customize selection, and a new include_all_columns flag keeps
non-canonical columns instead of dropping them.

Also drops metadata/provenance fields that aren't fitness data (sensor,
cadence_sensor, sensor_state, event, event_type, lap_trigger, sport,
sub_sport, intensity, notes) from the defaults, and unifies TCX's
total_strides field under GPX's steps name.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@tabishm52
tabishm52 merged commit b6b9204 into main Jul 6, 2026
4 checks passed
@tabishm52
tabishm52 deleted the default-columns-consolidation branch July 6, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant