feat(metrics): ✨ TRIMP #36#94
Draft
dvorka wants to merge 21 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands MyTraL’s training analytics by introducing a power-based 3D impulse-response model (IRM3D) and a “TRIMP_ROCKS” Banister fitness–fatigue–performance revamp, including new pages, charts, caching, background warmup, and extended athlete metrics (CP / W′ / Pmax). It also updates docs and adds test coverage for the new models and routes.
Changes:
- Add IRM3D computation, caching (file cache + background warmup task), and UI pages including a 3D activity classification chart.
- Add Banister model entities/insights/impact analysis, a settings page for parameters, and enhanced TRIMP UI (KPIs + insight cards).
- Extend athlete metrics persistence/derivation with critical power, W′, and Pmax + accompanying tests and documentation updates.
Reviewed changes
Copilot reviewed 66 out of 66 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_settings_athlete_metrics.py | Adds assertions for new persisted athlete metrics fields. |
| tests/test_irm3d.py | New unit tests for IRM3D math + pipeline + chart smoke. |
| tests/test_irm3d_route.py | New route-level tests for IRM3D pages and helpers. |
| tests/test_irm3d_cache.py | New tests for IRM3D file cache hashing/roundtrip/legacy handling. |
| tests/test_athlete_metrics.py | Extends athlete metrics tests for CP/W′/Pmax estimation paths. |
| tests/conftest.py | Ensures env vars are set before importing mytral. |
| mytral/templates/settings-banister.html | New Banister parameter configuration page. |
| mytral/templates/macros/trimp-kpi-card.html | New reusable KPI card macro for TRIMP/Banister pages. |
| mytral/templates/macros/trimp-insight-card.html | New reusable “insight card” macro (gauges/boxplot markers). |
| mytral/templates/layout.html | Updates Progress menu (adds IRM3D entry) and supports extra Bokeh scripts. |
| mytral/templates/insight-trimp.html | Revamps TRIMP page with Banister mode, KPIs, insights, extra charts, and About section. |
| mytral/templates/insight-irm3d.html | New IRM3D timeline page with cache-warming UX and explanatory footer. |
| mytral/templates/insight-irm3d-activities-3d-chart.html | New Plotly-based 3D activity classification chart page. |
| mytral/templates/activity-get.html | Adds TRIMP analysis shortcut button (and disabled state) on activity details. |
| mytral/templates/activity-analysis.html | Reframes “classic” analysis and adds navigation to IRM3D/TRIMP analyses. |
| mytral/templates/activity-analysis-trimp.html | New per-activity Banister/TRIMP impact analysis page. |
| mytral/templates/activity-analysis-irm3d.html | New per-activity IRM3D per-second breakdown page with recording selector. |
| mytral/tasks/do/irm3d_cache_warmup.py | New background task to warm IRM3D cache on first access. |
| mytral/static/documentation/sharing.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/normalization.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/metrics.html | Adds Banister section/link and TOC entry in generated static metrics docs. |
| mytral/static/documentation/licenses.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/license.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/index.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/feature_metrics.html | Adds Banister docs link + IRM3D bullet to metrics feature page. |
| mytral/static/documentation/feature_gpx_2d.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/feature_datasets.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/feature_3d_irm_metric_suite.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/digitalization.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/credits.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/changelog.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/architecture.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/analysis_tasks.html | Adds Banister docs link to static docs navigation. |
| mytral/static/documentation/about.html | Adds Banister docs link + minor wording update. |
| mytral/static/documentation/.feature_template.html | Adds Banister docs link to the feature template nav. |
| mytral/settings.py | Extends AthleteMetrics with CP/W′/Pmax + persists Banister params in UserProfile. |
| mytral/run.py | Registers the new IRM3D blueprint. |
| mytral/run_desktop.py | Registers the new IRM3D blueprint in desktop entry point. |
| mytral/routes.py | Adds per-activity IRM3D analysis route. |
| mytral/releng.py | Adds IRM3D + TRIMP_ROCKS feature flags and env vars. |
| mytral/metrics/irm3d_cache.py | New IRM3D file cache implementation (hashing + JSON date handling). |
| mytral/metrics/banister/_insights.py | New Banister insight-card generation logic. |
| mytral/metrics/banister/_impact.py | New per-activity Banister impact analysis logic. |
| mytral/metrics/banister/_entities.py | New Banister dataclasses (params/rows/annotations/insights/impact). |
| mytral/metrics/banister/init.py | New Banister model runner/projector/annotator and re-exports. |
| mytral/metrics/init.py | Introduces mytral.metrics package init. |
| mytral/forms.py | Adds WTForms form for Banister parameter editing. |
| mytral/commons.py | Adds shared Banister/TRIMP thresholds/constants. |
| mytral/blueprints/trimp_uri_space.py | Adds Banister rows caching, TRIMP_ROCKS rendering path, per-activity TRIMP analysis, and Banister settings route. |
| mytral/blueprints/irm3d_uri_space.py | New IRM3D blueprint: timeline, caching, warmup, and 3D chart page. |
| mytral/backends/dataset.py | Exposes dataset cache via property (incl. setter for tests). |
| mytral/backends/caches/_cache_passthrough.py | Adds Banister rows cache accessors (passthrough behavior). |
| mytral/backends/caches/_cache_inmemory.py | Adds in-memory storage/eviction/memory sizing for Banister rows. |
| mytral/backends/cache.py | Extends cache interface with Banister rows getter/setter. |
| mytral/athlete_metrics.py | Adds Pmax estimator and derives CP/W′/Pmax estimated fields. |
| Makefile | Enables IRM3D/TRIMP_ROCKS in dev/demo targets and updates “vibe” helper targets. |
| docs/METRICS.md | Adds link/section for Banister model docs. |
| docs/METRICS.banister.md | New Banister model documentation. |
| docs/FEATURE_METRICS.md | Adds IRM3D bullet to metrics feature docs. |
| docs/FEATURE_ANALYSIS_METRICS_SET_OR_ESTIMATE.md | Adjusts wording in the analysis/metrics planning doc. |
| docs/ABOUT.md | Minor wording update to About doc. |
| docs/_SITEMAP.md | Adds Banister model docs to sitemap. |
Comment on lines
+200
to
+203
| <script> | ||
| (function() { | ||
| var chartData = {{ chart_data_json|safe }}; | ||
|
|
| overflow: visible !important; | ||
| } | ||
| </style> | ||
| <script src="https://cdn.plot.ly/plotly-2.35.2.min.js"></script> |
Comment on lines
+39
to
+40
| from mytral.tasks import _entities as task_entities_mod | ||
| from mytral.tasks.do import irm3d_cache_warmup as cache_warmup_task # noqa: F401 |
Comment on lines
+532
to
+535
| # invalidate cached Banister rows so they recompute with new params | ||
| user_cache = ds.cache.user(user_id) | ||
| user_cache.set_banister_rows(None) | ||
|
|
Comment on lines
+449
to
+452
| </div></div><div id="overview" class="card mb-3"><div class="card-body"><h2 id="banister-fitness-fatigue-performance-model">Banister Fitness-Fatigue-Performance Model</h2> | ||
| <p>MyTraL implements the Banister systems model for predicting performance from | ||
| training load. See the dedicated <a href="METRICS.banister.md">Banister Model documentation</a> | ||
| for the full mathematical model, performance zones, and per-activity analysis.</p> |
Comment on lines
+448
to
+451
| .PHONY: vibe-qwen | ||
| vibe-qwen-openrouter: | ||
| @cp -vf ./.github/copilot-instructions.md ./AGENT.md | ||
| qwen |
| CTRIMP (Chronic TRIMP, 42-day exponential moving average) and | ||
| TRIMPB (TRIMP balance CTRIMP - ATRIMP) | ||
| shows balance between short-term load, long-term load i.e. delta between fitness and fatigue. | ||
| <a href="https://journals.physiology.org/doi/full/10.1152/advan.00078.2011" class="link-primary" target="_blank">TRIMP (Training Impulse)</a> |
| # features to enable / disable | ||
| ACOACHES = "ACOACHES" # AI coaches | ||
| GSHEETS_DVORKA_IMPORT = "GSHEETS_DVORKA_IMPORT" # Dvorka's own GSheets import | ||
| IRM3D = "IRM3D" # 3D inpulse response model |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR brings:
Related:
Plan TRIMP:
Recalculatebutton to get update TRIMP