repwise 3.3.0__tar.gz → 3.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {repwise-3.3.0/src/repwise.egg-info → repwise-3.4.0}/PKG-INFO +2 -2
- {repwise-3.3.0 → repwise-3.4.0}/pyproject.toml +4 -4
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/__init__.py +1 -1
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/checking.py +1 -1
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/fetch.py +7 -5
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/report.py +2 -2
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/update.py +33 -4
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/checker.py +12 -5
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/config.py +55 -10
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/domain/models.py +59 -20
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/domain/progression.py +65 -2
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/garmin/client.py +14 -1
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/garmin/payloads.py +6 -5
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/planner.py +73 -25
- {repwise-3.3.0 → repwise-3.4.0/src/repwise.egg-info}/PKG-INFO +2 -2
- repwise-3.4.0/src/repwise.egg-info/requires.txt +2 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_checker.py +37 -16
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_client.py +11 -1
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_config.py +79 -1
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_fetch.py +2 -1
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_models.py +29 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_payloads.py +9 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_planner.py +154 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_progression.py +101 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_report.py +20 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_update.py +32 -0
- repwise-3.3.0/src/repwise.egg-info/requires.txt +0 -2
- {repwise-3.3.0 → repwise-3.4.0}/LICENSE +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/README.md +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/setup.cfg +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/__main__.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/importing.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/listing.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/app/logout.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/cli/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/cli/completion.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/cli/parser.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/domain/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/domain/effort.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/domain/matching.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/dumps.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/errors.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/garmin/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/garmin/catalog.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/importer.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/log.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise/yamlio.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise.egg-info/SOURCES.txt +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_catalog.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_checking.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_cli.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_completion.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_dumps.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_effort.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_importer.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_importing.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_listing.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_log.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_logout.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_main.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_matching.py +0 -0
- {repwise-3.3.0 → repwise-3.4.0}/tests/test_yamlio.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: repwise
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Advance Garmin strength workout targets using double progression
|
|
5
5
|
Author-email: Adam Żmuda <adam@zmuda.pro>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -21,7 +21,7 @@ Classifier: Topic :: Utilities
|
|
|
21
21
|
Requires-Python: >=3.14
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: garminconnect==0.3.
|
|
24
|
+
Requires-Dist: garminconnect==0.3.13
|
|
25
25
|
Requires-Dist: pyyaml==6.0.3
|
|
26
26
|
Dynamic: license-file
|
|
27
27
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "repwise"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.4.0"
|
|
8
8
|
description = "Advance Garmin strength workout targets using double progression"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -37,7 +37,7 @@ classifiers = [
|
|
|
37
37
|
# raises a PR per release. garminconnect in particular has broken
|
|
38
38
|
# authentication before, so the working version is recorded deliberately.
|
|
39
39
|
dependencies = [
|
|
40
|
-
"garminconnect==0.3.
|
|
40
|
+
"garminconnect==0.3.13",
|
|
41
41
|
"pyyaml==6.0.3",
|
|
42
42
|
]
|
|
43
43
|
|
|
@@ -71,8 +71,8 @@ dev = [
|
|
|
71
71
|
"mypy==2.3.1",
|
|
72
72
|
"pre-commit==4.6.2",
|
|
73
73
|
"pytest==9.1.1",
|
|
74
|
-
"ruff==0.16.
|
|
75
|
-
"types-PyYAML==6.0.12.
|
|
74
|
+
"ruff==0.16.7",
|
|
75
|
+
"types-PyYAML==6.0.12.20260906",
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
[project.scripts]
|
|
@@ -92,7 +92,7 @@ def run_check(session: GarminSession, config: Config) -> ExitCode:
|
|
|
92
92
|
)
|
|
93
93
|
)
|
|
94
94
|
else:
|
|
95
|
-
found += check_workout(workout, payload)
|
|
95
|
+
found += check_workout(workout, payload, config.watch_note_limit)
|
|
96
96
|
found += check_programming(workout, payload, bodyweight)
|
|
97
97
|
|
|
98
98
|
if not found:
|
|
@@ -73,8 +73,8 @@ def run_fetch_activities(
|
|
|
73
73
|
Ids name sessions directly, and are downloaded as given: asking for one by
|
|
74
74
|
id says more about what you want than its sport does, and an id is also the
|
|
75
75
|
only way to reach a session further back than the search limit. Without
|
|
76
|
-
them
|
|
77
|
-
|
|
76
|
+
them your most recent strength sessions are downloaded -
|
|
77
|
+
`settings.garmin.activity_search_limit` of them.
|
|
78
78
|
"""
|
|
79
79
|
ids = list(activity_ids or [])
|
|
80
80
|
if not ids:
|
|
@@ -85,10 +85,12 @@ def run_fetch_activities(
|
|
|
85
85
|
if activity_sport(activity) == STRENGTH and activity.get("activityId")
|
|
86
86
|
]
|
|
87
87
|
if not ids:
|
|
88
|
+
# Garmin's search already skips every other sport, so an empty
|
|
89
|
+
# answer means there are none at all - raising the limit would
|
|
90
|
+
# only ask for more of nothing.
|
|
88
91
|
logger.warning(
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
"back, or name an activity id."
|
|
92
|
+
"Garmin lists no strength activities for this account. Name an "
|
|
93
|
+
"activity id to download one directly."
|
|
92
94
|
)
|
|
93
95
|
return ExitCode.NOTHING_USABLE
|
|
94
96
|
|
|
@@ -15,7 +15,7 @@ import logging
|
|
|
15
15
|
from dataclasses import dataclass, fields
|
|
16
16
|
|
|
17
17
|
from ..domain.models import ExerciseSpec
|
|
18
|
-
from ..domain.progression import Target
|
|
18
|
+
from ..domain.progression import Target, frozen
|
|
19
19
|
from ..planner import (
|
|
20
20
|
Change,
|
|
21
21
|
GapChange,
|
|
@@ -119,7 +119,7 @@ def moved_to(change: Change) -> str:
|
|
|
119
119
|
the rules spend them in.
|
|
120
120
|
"""
|
|
121
121
|
if change.old == change.new:
|
|
122
|
-
return "hold"
|
|
122
|
+
return "freeze" if frozen(change.reason) else "hold"
|
|
123
123
|
was = (change.old.weight, change.old.reps, change.old.lead)
|
|
124
124
|
now = (change.new.weight, change.new.reps, change.new.lead)
|
|
125
125
|
return "advance" if now > was else "ease"
|
|
@@ -16,6 +16,7 @@ from ..domain.matching import normalise
|
|
|
16
16
|
from ..domain.models import Config, ExerciseSpec, Workout
|
|
17
17
|
from ..domain.progression import (
|
|
18
18
|
CONFIRMED_AFTER,
|
|
19
|
+
FREEZE_REVIEW_AFTER,
|
|
19
20
|
PerformedSet,
|
|
20
21
|
Session,
|
|
21
22
|
Target,
|
|
@@ -204,8 +205,23 @@ def wants_more(
|
|
|
204
205
|
all, and without the floor a single-set exercise would arrive at the top of
|
|
205
206
|
its range with no history to confirm against and hold there forever.
|
|
206
207
|
"""
|
|
208
|
+
if not logged:
|
|
209
|
+
return False
|
|
210
|
+
# A frozen exercise counts how long its target has stood, which needs one
|
|
211
|
+
# more read for as long as every session so far asked for the same thing.
|
|
212
|
+
# Compared among themselves rather than with the latest session's target,
|
|
213
|
+
# which is not known here - at worst one activity is read that the count
|
|
214
|
+
# then stops short of. Executed targets carry no load, so this is reps and
|
|
215
|
+
# ramp; `frozen_streak` checks the load off what was lifted.
|
|
216
|
+
if (
|
|
217
|
+
spec.freeze
|
|
218
|
+
and len(earlier) < FREEZE_REVIEW_AFTER - 1
|
|
219
|
+
and all(session.target == earlier[0].target for session in earlier)
|
|
220
|
+
):
|
|
221
|
+
return True
|
|
222
|
+
|
|
207
223
|
limit = max(spec.sets - 1, CONFIRMED_AFTER)
|
|
208
|
-
if
|
|
224
|
+
if len(earlier) >= limit:
|
|
209
225
|
# Not trained in the session being judged, so there is nothing for a
|
|
210
226
|
# streak to explain -- or already as deep as the rules can read.
|
|
211
227
|
return False
|
|
@@ -579,7 +595,12 @@ def run_update(
|
|
|
579
595
|
noted = counted(plans, lambda plan: (c.spec.garmin_name for c in plan.notes))
|
|
580
596
|
rested = counted(plans, lambda plan: (c.spec.garmin_name for c in plan.rests))
|
|
581
597
|
recounted = counted(plans, lambda plan: (c.spec.garmin_name for c in plan.sets))
|
|
582
|
-
unskipped = counted(
|
|
598
|
+
unskipped = counted(
|
|
599
|
+
plans, lambda plan: (c.spec.garmin_name for c in plan.skips if not c.skip)
|
|
600
|
+
)
|
|
601
|
+
skipped = counted(
|
|
602
|
+
plans, lambda plan: (c.spec.garmin_name for c in plan.skips if c.skip)
|
|
603
|
+
)
|
|
583
604
|
# One per workout however many gap steps it touched: the config says it once.
|
|
584
605
|
regaps = len({counted_as(plan.workout) for plan in plans if plan.gaps})
|
|
585
606
|
renames = len({counted_as(plan.workout) for plan in plans if plan.name})
|
|
@@ -600,7 +621,7 @@ def run_update(
|
|
|
600
621
|
f", {unskipped} step(s) would stop skipping their last rest"
|
|
601
622
|
if unskipped
|
|
602
623
|
else ""
|
|
603
|
-
)
|
|
624
|
+
) + (f", {skipped} step(s) would skip their last rest" if skipped else "")
|
|
604
625
|
|
|
605
626
|
if not options.apply:
|
|
606
627
|
logger.info("")
|
|
@@ -612,7 +633,14 @@ def run_update(
|
|
|
612
633
|
return ExitCode.OK
|
|
613
634
|
|
|
614
635
|
moved_anything = (
|
|
615
|
-
updated
|
|
636
|
+
updated
|
|
637
|
+
or noted
|
|
638
|
+
or rested
|
|
639
|
+
or recounted
|
|
640
|
+
or unskipped
|
|
641
|
+
or skipped
|
|
642
|
+
or regaps
|
|
643
|
+
or renames
|
|
616
644
|
)
|
|
617
645
|
if not (moved_anything or shaped):
|
|
618
646
|
logger.info("")
|
|
@@ -628,6 +656,7 @@ def run_update(
|
|
|
628
656
|
+ (f" Set {recounted} set count(s)." if recounted else "")
|
|
629
657
|
+ (f" Set {rested} rest time(s)." if rested else "")
|
|
630
658
|
+ (f" Restored the last rest on {unskipped} step(s)." if unskipped else "")
|
|
659
|
+
+ (f" Dropped the last rest on {skipped} step(s)." if skipped else "")
|
|
631
660
|
+ (f" Set the rest between exercises in {regaps} workout(s)." if regaps else "")
|
|
632
661
|
+ (f" Renamed {renames} workout(s)." if renames else "")
|
|
633
662
|
+ (f" Refreshed {noted} note(s)." if noted else "")
|
|
@@ -35,7 +35,7 @@ from .domain.effort import (
|
|
|
35
35
|
within_tolerance,
|
|
36
36
|
)
|
|
37
37
|
from .domain.matching import ExerciseIndex
|
|
38
|
-
from .domain.models import
|
|
38
|
+
from .domain.models import STORED_NOTE, ExerciseSpec, Workout
|
|
39
39
|
from .garmin.catalog import ExerciseCatalog
|
|
40
40
|
from .garmin.payloads import (
|
|
41
41
|
ExerciseBlock,
|
|
@@ -142,8 +142,15 @@ def check_catalog(workout: Workout, catalog: ExerciseCatalog) -> list[Finding]:
|
|
|
142
142
|
return findings
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
def check_workout(
|
|
146
|
-
|
|
145
|
+
def check_workout(
|
|
146
|
+
workout: Workout, payload: dict[str, Any], watch_note_limit: int = STORED_NOTE
|
|
147
|
+
) -> list[Finding]:
|
|
148
|
+
"""Look for exercises the config cannot name properly.
|
|
149
|
+
|
|
150
|
+
`watch_note_limit` is how much of a note the watch in hand shows, which is a
|
|
151
|
+
per-device figure - see `settings.watch_note_limit`. Left at the stored cap it
|
|
152
|
+
reports nothing, since a longer note was cut before it ever got here.
|
|
153
|
+
"""
|
|
147
154
|
findings: list[Finding] = []
|
|
148
155
|
|
|
149
156
|
def note(detail: str, severity: str = "warning") -> None:
|
|
@@ -164,10 +171,10 @@ def check_workout(workout: Workout, payload: dict[str, Any]) -> list[Finding]:
|
|
|
164
171
|
)
|
|
165
172
|
|
|
166
173
|
for spec in workout.exercises:
|
|
167
|
-
if len(spec.note) >
|
|
174
|
+
if len(spec.note) > watch_note_limit:
|
|
168
175
|
note(
|
|
169
176
|
f"{spec.name}: its note comes to {len(spec.note)} characters, past "
|
|
170
|
-
f"the {
|
|
177
|
+
f"the {watch_note_limit} your watch shows, so the end of it is simply "
|
|
171
178
|
f"never read"
|
|
172
179
|
)
|
|
173
180
|
|
|
@@ -16,6 +16,7 @@ from typing import Any
|
|
|
16
16
|
|
|
17
17
|
from .domain.models import (
|
|
18
18
|
BODYWEIGHT,
|
|
19
|
+
STORED_NOTE,
|
|
19
20
|
Config,
|
|
20
21
|
ExerciseSpec,
|
|
21
22
|
GarminSettings,
|
|
@@ -171,8 +172,9 @@ def default_dump_dir() -> str:
|
|
|
171
172
|
def _flag(declared: object, key: str, *, default: bool) -> bool:
|
|
172
173
|
"""A yes-or-no setting, read as one rather than coerced into one.
|
|
173
174
|
|
|
174
|
-
`key` is the whole
|
|
175
|
-
|
|
175
|
+
`key` is the whole path to the setting, as the message should name it,
|
|
176
|
+
since these live at more than one level of the file and a message naming
|
|
177
|
+
the wrong one is worse than no message.
|
|
176
178
|
|
|
177
179
|
YAML has booleans, so a setting that wants one should insist: `bool()`
|
|
178
180
|
would read the string `"false"` as true and turn a feature on for someone
|
|
@@ -187,7 +189,7 @@ def _flag(declared: object, key: str, *, default: bool) -> bool:
|
|
|
187
189
|
return default
|
|
188
190
|
if not isinstance(declared, bool):
|
|
189
191
|
raise ConfigError(
|
|
190
|
-
f"
|
|
192
|
+
f"{key} should be true or false, not "
|
|
191
193
|
f"{declared!r}. Unquoted, so that YAML reads it as a boolean."
|
|
192
194
|
)
|
|
193
195
|
return declared
|
|
@@ -641,13 +643,14 @@ def _bodyweight_factor(raw: dict[str, Any], where: str, problems: Problems) -> f
|
|
|
641
643
|
return factor
|
|
642
644
|
|
|
643
645
|
|
|
644
|
-
def _build_exercise(
|
|
646
|
+
def _build_exercise( # noqa: PLR0913 - the flags are settings resolved onto it
|
|
645
647
|
raw: dict[str, Any],
|
|
646
648
|
types: dict[str, LoadType],
|
|
647
649
|
where: str,
|
|
648
650
|
problems: Problems,
|
|
649
651
|
*,
|
|
650
652
|
partial_progression: bool = True,
|
|
653
|
+
skip_last_rest: bool = False,
|
|
651
654
|
) -> ExerciseSpec | None:
|
|
652
655
|
missing = [key for key in _REQUIRED if raw.get(key) is None]
|
|
653
656
|
if missing:
|
|
@@ -711,6 +714,7 @@ def _build_exercise(
|
|
|
711
714
|
max_weight = None
|
|
712
715
|
|
|
713
716
|
bodyweight_factor = _bodyweight_factor(raw, where, problems)
|
|
717
|
+
freeze = _flag(raw.get("freeze"), f"{where}: {raw['name']}: freeze", default=False)
|
|
714
718
|
|
|
715
719
|
# The equipment comes from the load type, but an exercise that overrides
|
|
716
720
|
# any of the three scalars has stated its own single rack and means it: a
|
|
@@ -745,7 +749,9 @@ def _build_exercise(
|
|
|
745
749
|
min_weight=min_weight,
|
|
746
750
|
max_weight=max_weight,
|
|
747
751
|
bodyweight_factor=bodyweight_factor,
|
|
752
|
+
freeze=freeze,
|
|
748
753
|
partial_progression=partial_progression,
|
|
754
|
+
skip_last_rest=skip_last_rest,
|
|
749
755
|
tiers=tiers,
|
|
750
756
|
)
|
|
751
757
|
|
|
@@ -767,6 +773,12 @@ def _build_workout(
|
|
|
767
773
|
|
|
768
774
|
workout_id = entry.get("garmin_workout_id")
|
|
769
775
|
|
|
776
|
+
# A property of the workout, written to every repeat group in it, so it is
|
|
777
|
+
# resolved onto each exercise rather than consulted from the workout.
|
|
778
|
+
skip_last_rest = _flag(
|
|
779
|
+
entry.get("skip_last_rest"), f"{path}:{key}: skip_last_rest", default=False
|
|
780
|
+
)
|
|
781
|
+
|
|
770
782
|
exercises = []
|
|
771
783
|
for raw in entry.get("exercises") or []:
|
|
772
784
|
spec = _build_exercise(
|
|
@@ -775,6 +787,7 @@ def _build_workout(
|
|
|
775
787
|
f"{path}:{key}",
|
|
776
788
|
problems,
|
|
777
789
|
partial_progression=partial_progression,
|
|
790
|
+
skip_last_rest=skip_last_rest,
|
|
778
791
|
)
|
|
779
792
|
if spec is not None:
|
|
780
793
|
exercises.append(spec)
|
|
@@ -809,9 +822,10 @@ def _check_shared(config: Config, path: str, problems: Problems) -> None:
|
|
|
809
822
|
"""A shared exercise must be programmed identically everywhere.
|
|
810
823
|
|
|
811
824
|
Otherwise a target synced out of one workout could land outside another
|
|
812
|
-
workout's range
|
|
813
|
-
|
|
814
|
-
what they ask for is nobody
|
|
825
|
+
workout's range, or move a target another workout has frozen. Only the
|
|
826
|
+
copies that really do sync are compared: two entries carrying one name on
|
|
827
|
+
different loads never reach each other, so what they ask for is nobody
|
|
828
|
+
else's business.
|
|
815
829
|
"""
|
|
816
830
|
for garmin_name in config.shared_exercises():
|
|
817
831
|
by_load: dict[str, list[ExerciseSpec]] = {}
|
|
@@ -828,6 +842,14 @@ def _check_shared(config: Config, path: str, problems: Problems) -> None:
|
|
|
828
842
|
f"{load} with different rep ranges {sorted(ranges)}; a "
|
|
829
843
|
f"synced target could fall outside one of them"
|
|
830
844
|
)
|
|
845
|
+
# One target between them, so a copy left unfrozen would progress
|
|
846
|
+
# it in its own workout and sync the result into the frozen one.
|
|
847
|
+
if len({s.freeze for s in specs}) > 1:
|
|
848
|
+
problems.add(
|
|
849
|
+
f"{path}: {garmin_name} appears in several workouts on "
|
|
850
|
+
f"{load}, frozen in some and not others; they share one "
|
|
851
|
+
f"target, so freeze every copy or none"
|
|
852
|
+
)
|
|
831
853
|
|
|
832
854
|
|
|
833
855
|
def load_config(path: str | None = None) -> Config:
|
|
@@ -869,7 +891,7 @@ def load_config(path: str | None = None) -> Config:
|
|
|
869
891
|
),
|
|
870
892
|
activity_caching=_flag(
|
|
871
893
|
garmin_raw.get("activity_caching"),
|
|
872
|
-
"garmin.activity_caching",
|
|
894
|
+
"settings.garmin.activity_caching",
|
|
873
895
|
default=defaults.activity_caching,
|
|
874
896
|
),
|
|
875
897
|
)
|
|
@@ -879,7 +901,9 @@ def load_config(path: str | None = None) -> Config:
|
|
|
879
901
|
# every exercise, the way a weight step is: the rules read it
|
|
880
902
|
# off the spec in hand rather than being handed the settings.
|
|
881
903
|
partial_progression = _flag(
|
|
882
|
-
settings.get("partial_progression"),
|
|
904
|
+
settings.get("partial_progression"),
|
|
905
|
+
"settings.partial_progression",
|
|
906
|
+
default=True,
|
|
883
907
|
)
|
|
884
908
|
|
|
885
909
|
# Unset means "ask Garmin", which is the better answer for anyone who
|
|
@@ -888,6 +912,12 @@ def load_config(path: str | None = None) -> Config:
|
|
|
888
912
|
declared_bodyweight = settings.get("bodyweight")
|
|
889
913
|
bodyweight = None if declared_bodyweight is None else float(declared_bodyweight)
|
|
890
914
|
|
|
915
|
+
# What your own watch shows, when it shows less than Garmin stores. A fact
|
|
916
|
+
# about the screen rather than about the training, so it is stated here and
|
|
917
|
+
# read only by `check`.
|
|
918
|
+
declared_limit = settings.get("watch_note_limit")
|
|
919
|
+
watch_note_limit = STORED_NOTE if declared_limit is None else int(declared_limit)
|
|
920
|
+
|
|
891
921
|
problems = Problems()
|
|
892
922
|
types = _load_types(data.get("load"), path, problems)
|
|
893
923
|
workouts: dict[str, Workout] = {}
|
|
@@ -911,7 +941,22 @@ def load_config(path: str | None = None) -> Config:
|
|
|
911
941
|
problems.add(f"{path}: settings.bodyweight is {bodyweight:g}")
|
|
912
942
|
bodyweight = None
|
|
913
943
|
|
|
914
|
-
|
|
944
|
+
# Above the stored cap it would be a promise nothing can keep: Garmin drops
|
|
945
|
+
# the rest of the note on the way in whatever the screen could have shown.
|
|
946
|
+
if not 1 <= watch_note_limit <= STORED_NOTE:
|
|
947
|
+
problems.add(
|
|
948
|
+
f"{path}: settings.watch_note_limit is {watch_note_limit}, "
|
|
949
|
+
f"which is not 1 to {STORED_NOTE}"
|
|
950
|
+
)
|
|
951
|
+
watch_note_limit = STORED_NOTE
|
|
952
|
+
|
|
953
|
+
config = Config(
|
|
954
|
+
workouts=workouts,
|
|
955
|
+
garmin=garmin,
|
|
956
|
+
path=path,
|
|
957
|
+
bodyweight=bodyweight,
|
|
958
|
+
watch_note_limit=watch_note_limit,
|
|
959
|
+
)
|
|
915
960
|
_check_shared(config, path, problems)
|
|
916
961
|
|
|
917
962
|
problems.raise_any()
|
|
@@ -11,22 +11,16 @@ from dataclasses import dataclass, field
|
|
|
11
11
|
|
|
12
12
|
BODYWEIGHT = "bodyweight"
|
|
13
13
|
|
|
14
|
-
#: How long a step's note may be before it stops being read.
|
|
15
|
-
#:
|
|
16
|
-
#: Not the API's limit, which is 512 - Garmin stores that many characters and
|
|
17
|
-
#: silently drops the rest, with no error and nothing to say anything was lost.
|
|
18
|
-
#: The binding limit is the screen: a Forerunner displays a 160-character note
|
|
19
|
-
#: whole and truncates a 200-character one, measured by writing both to a real
|
|
20
|
-
#: workout and reading them off the watch. Round down to the one that fits.
|
|
21
|
-
READABLE_NOTE = 160
|
|
22
|
-
|
|
23
14
|
#: The most of a note Garmin keeps. Past this it drops the rest on the way in,
|
|
24
15
|
#: with no error and nothing to say it happened - so what was sent back and
|
|
25
16
|
#: what is stored no longer agree, and every later run finds the note stale and
|
|
26
17
|
#: writes it again. The note is cut to fit here for that reason: this tool has
|
|
27
|
-
#: to be able to predict what comes back. `check`
|
|
28
|
-
#:
|
|
29
|
-
#:
|
|
18
|
+
#: to be able to predict what comes back. It is also as far as `check` looks by
|
|
19
|
+
#: default, since no watch can show a character that was never stored - and the
|
|
20
|
+
#: screen that shows every one of them exists: a Fenix 9 Pro displays a
|
|
21
|
+
#: 512-character note whole, measured by writing notes of graduated length to a
|
|
22
|
+
#: real workout and reading them back off the watch. A smaller screen says so
|
|
23
|
+
#: through `settings.watch_note_limit`, which only ever lowers this.
|
|
30
24
|
STORED_NOTE = 512
|
|
31
25
|
|
|
32
26
|
#: The word a note carries while an exercise is holding after a missed target.
|
|
@@ -34,14 +28,21 @@ STORED_NOTE = 512
|
|
|
34
28
|
#: here is one the cue behind it does not get.
|
|
35
29
|
HOLD = "hold"
|
|
36
30
|
|
|
37
|
-
#:
|
|
38
|
-
#:
|
|
31
|
+
#: The word a note carries while an exercise is frozen by hand - `freeze` in
|
|
32
|
+
#: workouts.yaml - and is holding a target it has been hitting. A different
|
|
33
|
+
#: word from `HOLD` because it asks something different: `hold` is the tool
|
|
34
|
+
#: saying match this, `frozen` is you having said not yet.
|
|
35
|
+
FROZEN = "frozen"
|
|
36
|
+
|
|
37
|
+
#: What a marker looks like, matched against a whole `|`-separated field rather
|
|
38
|
+
#: than searched for. Either word, bare or with a count.
|
|
39
39
|
#:
|
|
40
40
|
#: Anchored on purpose. A cue is free text that a user typed, and one of them
|
|
41
41
|
#: begins "hold the chair, lean away" - searching for the word would read that
|
|
42
42
|
#: as a marker, and clearing it would delete the cue. Only a field that is
|
|
43
|
-
#: exactly `hold`, `hold x3
|
|
44
|
-
|
|
43
|
+
#: exactly `hold`, `hold x3`, `frozen x3+` and the like, and nothing else,
|
|
44
|
+
#: counts.
|
|
45
|
+
MARKER = re.compile(rf"^(?:{HOLD}|{FROZEN})(?: x\d+\+?)?$")
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
def hold_marker(streak: int, sets: int) -> str:
|
|
@@ -66,6 +67,22 @@ def hold_marker(streak: int, sets: int) -> str:
|
|
|
66
67
|
return f"{HOLD} x{misses}{saturated}"
|
|
67
68
|
|
|
68
69
|
|
|
70
|
+
def frozen_marker(streak: int, cap: int) -> str:
|
|
71
|
+
"""The marker for a frozen session, `streak` sessions at its target behind it.
|
|
72
|
+
|
|
73
|
+
Counted the way `hold_marker` counts: `streak` is the sessions *before* the
|
|
74
|
+
one just judged, so the figure shown is one more. `cap` is where the walk
|
|
75
|
+
that produced `streak` stopped looking, and a count that reached it is
|
|
76
|
+
shown with a `+` - `frozen x3+` means three or more, since the history
|
|
77
|
+
behind the third was never read.
|
|
78
|
+
"""
|
|
79
|
+
sessions = streak + 1
|
|
80
|
+
if sessions == 1:
|
|
81
|
+
return FROZEN
|
|
82
|
+
saturated = "+" if streak >= cap else ""
|
|
83
|
+
return f"{FROZEN} x{sessions}{saturated}"
|
|
84
|
+
|
|
85
|
+
|
|
69
86
|
def _split_note(note: str) -> tuple[str, str, str]:
|
|
70
87
|
"""A note as its fixed head, its marker, and everything after.
|
|
71
88
|
|
|
@@ -80,13 +97,13 @@ def _split_note(note: str) -> tuple[str, str, str]:
|
|
|
80
97
|
return note, "", ""
|
|
81
98
|
head = " | ".join(parts[:2])
|
|
82
99
|
field, _, rest = parts[2].partition(" | ")
|
|
83
|
-
if
|
|
100
|
+
if MARKER.match(field):
|
|
84
101
|
return head, field, rest
|
|
85
102
|
return head, "", parts[2]
|
|
86
103
|
|
|
87
104
|
|
|
88
105
|
def marker_of(note: str) -> str:
|
|
89
|
-
"""The
|
|
106
|
+
"""The marker a note is carrying, `hold` or `frozen`, or empty for none."""
|
|
90
107
|
return _split_note(note)[1]
|
|
91
108
|
|
|
92
109
|
|
|
@@ -198,6 +215,21 @@ class ExerciseSpec:
|
|
|
198
215
|
#: Declared once as settings.partial_progression and resolved onto every
|
|
199
216
|
#: exercise, the way a weight step is.
|
|
200
217
|
partial_progression: bool = True
|
|
218
|
+
#: Whether the exercise's repeat groups drop the rest after the final set -
|
|
219
|
+
#: Connect's "skip last rest". Declared once per workout as
|
|
220
|
+
#: `skip_last_rest` and resolved onto each of its exercises, the way
|
|
221
|
+
#: `partial_progression` is: it is a choice about how the session runs,
|
|
222
|
+
#: most useful where a lap-button wait already follows every exercise and
|
|
223
|
+
#: a timed rest in front of it would only be waited out twice.
|
|
224
|
+
skip_last_rest: bool = False
|
|
225
|
+
#: Hold the target where it is, through sessions that hit it, until you
|
|
226
|
+
#: say otherwise. For the exercise whose numbers are going up while the
|
|
227
|
+
#: effort behind them says they should not - reps at 0-1 in reserve where
|
|
228
|
+
#: the programme meant 2-3. Only a hit is held: a miss is still a miss and
|
|
229
|
+
#: runs the rules as usual, and a session at a load other than the one
|
|
230
|
+
#: prescribed is judged as usual too, which is how a frozen exercise is
|
|
231
|
+
#: deloaded by hand.
|
|
232
|
+
freeze: bool = False
|
|
201
233
|
#: The equipment this exercise is loaded on, ascending. Empty means the
|
|
202
234
|
#: load type said nothing a single `weight_step`, `min_weight` and
|
|
203
235
|
#: `max_weight` could not, which is every config written before groups
|
|
@@ -250,8 +282,8 @@ class ExerciseSpec:
|
|
|
250
282
|
rather than about taste: Garmin silently drops a note past 512
|
|
251
283
|
characters, and `GENERATED_NOTE` cannot match one carrying a newline,
|
|
252
284
|
so either would leave this tool unable to recognise what it had just
|
|
253
|
-
written.
|
|
254
|
-
|
|
285
|
+
written. A screen may run out well before 512 - a Forerunner 945 does,
|
|
286
|
+
at 160 - which is what `settings.watch_note_limit` is for.
|
|
255
287
|
"""
|
|
256
288
|
span = f"{self.rep_low}-{self.rep_high} {'s' if self.time_based else 'reps'}"
|
|
257
289
|
if self.rep_step != 1:
|
|
@@ -335,6 +367,13 @@ class Config:
|
|
|
335
367
|
#: keeps it current without anyone editing a file. Only ever an input to
|
|
336
368
|
#: `check`; no target depends on it.
|
|
337
369
|
bodyweight: float | None = None
|
|
370
|
+
#: How long a note may be before your watch stops showing all of it. Here
|
|
371
|
+
#: rather than a constant because the cap is the screen's and the screens
|
|
372
|
+
#: disagree: a Fenix 9 Pro shows all 512 characters Garmin keeps, while a
|
|
373
|
+
#: Forerunner 945 shows 160 and cuts from 165. Unset means the stored cap,
|
|
374
|
+
#: which reports nothing a watch could have shown; state your own screen to
|
|
375
|
+
#: be warned before it cuts. Only ever an input to `check`.
|
|
376
|
+
watch_note_limit: int = STORED_NOTE
|
|
338
377
|
#: The file this was read from. Carried so that a use case which learns
|
|
339
378
|
#: something the file should record - a workout id Garmin has just issued -
|
|
340
379
|
#: can write it back without the CLI having to pass the path separately.
|
|
@@ -28,7 +28,7 @@ from collections import Counter
|
|
|
28
28
|
from dataclasses import dataclass, field
|
|
29
29
|
|
|
30
30
|
from .effort import next_weight_above, next_weight_below
|
|
31
|
-
from .models import ExerciseSpec
|
|
31
|
+
from .models import FROZEN, ExerciseSpec
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
@dataclass(frozen=True)
|
|
@@ -274,6 +274,54 @@ def top_streak(spec: ExerciseSpec, history: list[Session], weight: float) -> int
|
|
|
274
274
|
return streak
|
|
275
275
|
|
|
276
276
|
|
|
277
|
+
#: How many sessions a frozen exercise holds one target before `update` asks
|
|
278
|
+
#: whether the freeze is still earning its place. Three, because a freeze is
|
|
279
|
+
#: for a load that should become easy with repetition, and one that has not
|
|
280
|
+
#: after three sessions is more likely waiting on recovery - sleep, stress,
|
|
281
|
+
#: the volume around it - than on adaptation. Past that, the answer is to
|
|
282
|
+
#: take the freeze off or take the load down, not to keep holding.
|
|
283
|
+
FREEZE_REVIEW_AFTER = 3
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def frozen_streak(history: list[Session], target: Target) -> int:
|
|
287
|
+
"""How many sessions in a row, before the latest, were asked for `target`.
|
|
288
|
+
|
|
289
|
+
What a freeze has been holding is the target, so that is what is compared -
|
|
290
|
+
but in two halves. The reps and the ramp come off the workout each past
|
|
291
|
+
session was performed against. The load cannot: Garmin's record of an
|
|
292
|
+
executed workout carries none (see docs/garmin-api.md), which is also why
|
|
293
|
+
`_moved_on` compares reps alone. So the load is read off what was lifted,
|
|
294
|
+
as `miss_streak` reads it, and a session worked at another weight belonged
|
|
295
|
+
to another ladder.
|
|
296
|
+
|
|
297
|
+
It is also how long the target has stood for any other reason - a miss
|
|
298
|
+
held at the same figure, a top-of-range confirmation - and those count,
|
|
299
|
+
since the question is how long this load has been asked for rather than
|
|
300
|
+
how long the key has been in the file.
|
|
301
|
+
|
|
302
|
+
The walk stops at the first session asked for something else, and at
|
|
303
|
+
`FREEZE_REVIEW_AFTER - 1`, past which the review is already due and a
|
|
304
|
+
longer count would change nothing but the figure.
|
|
305
|
+
"""
|
|
306
|
+
limit = FREEZE_REVIEW_AFTER - 1
|
|
307
|
+
streak = 0
|
|
308
|
+
for session in history:
|
|
309
|
+
if streak >= limit:
|
|
310
|
+
break
|
|
311
|
+
asked = (session.target.reps, session.target.lead)
|
|
312
|
+
if asked != (target.reps, target.lead):
|
|
313
|
+
break
|
|
314
|
+
if not session.performed or working_weight(session.performed) != target.weight:
|
|
315
|
+
break
|
|
316
|
+
streak += 1
|
|
317
|
+
return streak
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def frozen(reason: str) -> bool:
|
|
321
|
+
"""Whether a reason from `next_target` reports a target held by `freeze`."""
|
|
322
|
+
return reason.startswith(FROZEN)
|
|
323
|
+
|
|
324
|
+
|
|
277
325
|
#: How many sessions must have missed *before* this one for it to count as a
|
|
278
326
|
#: stall rather than a bad day. One, so the target eases on the second miss in
|
|
279
327
|
#: a row - and, because easing has to bottom out in the range before the load
|
|
@@ -577,7 +625,7 @@ def _advance( # noqa: PLR0913 - each argument is one independent input
|
|
|
577
625
|
)
|
|
578
626
|
|
|
579
627
|
|
|
580
|
-
def next_target( # noqa: PLR0913 -
|
|
628
|
+
def next_target( # noqa: PLR0911, PLR0913 - a return per rule, an argument per input
|
|
581
629
|
spec: ExerciseSpec,
|
|
582
630
|
current: Target,
|
|
583
631
|
performed: list[PerformedSet],
|
|
@@ -585,6 +633,7 @@ def next_target( # noqa: PLR0913 - each argument is one independent input
|
|
|
585
633
|
*,
|
|
586
634
|
bodyweight: float = 0.0,
|
|
587
635
|
topped: int = 0,
|
|
636
|
+
held: int = 0,
|
|
588
637
|
) -> tuple[Target, str]:
|
|
589
638
|
"""Decide the next prescription for one exercise.
|
|
590
639
|
|
|
@@ -607,6 +656,10 @@ def next_target( # noqa: PLR0913 - each argument is one independent input
|
|
|
607
656
|
behind - and costs a single held session at the top of the range, which the
|
|
608
657
|
session after it then confirms.
|
|
609
658
|
|
|
659
|
+
`held` is how many sessions in a row were already asked for this target,
|
|
660
|
+
from `frozen_streak`, and is only ever read to say how long a frozen
|
|
661
|
+
exercise has been holding.
|
|
662
|
+
|
|
610
663
|
Returns the new target plus a short human-readable reason.
|
|
611
664
|
"""
|
|
612
665
|
if not performed:
|
|
@@ -655,6 +708,16 @@ def next_target( # noqa: PLR0913 - each argument is one independent input
|
|
|
655
708
|
return _deload(spec, current, weight, counted, bodyweight=bodyweight)
|
|
656
709
|
return current, _missed(floor)
|
|
657
710
|
|
|
711
|
+
# Frozen by hand: the session met its target, and the target stays. Only
|
|
712
|
+
# at the load prescribed - a session at another one is your own choice of
|
|
713
|
+
# load, judged like any other, and lifting lighter is how a frozen
|
|
714
|
+
# exercise is deloaded without taking the freeze off first.
|
|
715
|
+
if spec.freeze and not rebased:
|
|
716
|
+
sessions = held + 1
|
|
717
|
+
shown = f"{sessions}+" if held >= FREEZE_REVIEW_AFTER - 1 else f"{sessions}"
|
|
718
|
+
plural = "" if sessions == 1 else "s"
|
|
719
|
+
return current, f"{FROZEN}, {shown} session{plural} at this target"
|
|
720
|
+
|
|
658
721
|
return _advance(
|
|
659
722
|
spec, current, weight, floor, streak, bodyweight=bodyweight, topped=topped
|
|
660
723
|
)
|