repwise 3.3.0__tar.gz → 3.5.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.5.0}/PKG-INFO +2 -2
- {repwise-3.3.0 → repwise-3.5.0}/pyproject.toml +9 -15
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/__init__.py +1 -1
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/checking.py +1 -1
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/fetch.py +7 -5
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/report.py +2 -2
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/update.py +33 -4
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/checker.py +12 -5
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/config.py +55 -10
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/domain/effort.py +15 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/domain/models.py +67 -21
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/domain/progression.py +70 -3
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/garmin/client.py +23 -8
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/garmin/payloads.py +8 -6
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/planner.py +136 -49
- {repwise-3.3.0 → repwise-3.5.0/src/repwise.egg-info}/PKG-INFO +2 -2
- repwise-3.5.0/src/repwise.egg-info/requires.txt +2 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_checker.py +37 -16
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_client.py +23 -7
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_config.py +79 -1
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_fetch.py +2 -1
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_models.py +29 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_payloads.py +18 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_planner.py +231 -18
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_progression.py +109 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_report.py +20 -0
- {repwise-3.3.0 → repwise-3.5.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.5.0}/LICENSE +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/README.md +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/setup.cfg +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/__main__.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/importing.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/listing.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/app/logout.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/cli/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/cli/completion.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/cli/parser.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/domain/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/domain/matching.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/dumps.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/errors.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/garmin/__init__.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/garmin/catalog.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/importer.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/log.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise/yamlio.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise.egg-info/SOURCES.txt +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_catalog.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_checking.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_cli.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_completion.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_dumps.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_effort.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_importer.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_importing.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_listing.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_log.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_logout.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_main.py +0 -0
- {repwise-3.3.0 → repwise-3.5.0}/tests/test_matching.py +0 -0
- {repwise-3.3.0 → repwise-3.5.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.5.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.19
|
|
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.5.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.19",
|
|
41
41
|
"pyyaml==6.0.3",
|
|
42
42
|
]
|
|
43
43
|
|
|
@@ -63,16 +63,16 @@ Issues = "https://github.com/theadzik/repwise/issues"
|
|
|
63
63
|
# workflow cannot disagree about the answer.
|
|
64
64
|
[dependency-groups]
|
|
65
65
|
release = [
|
|
66
|
-
"commitizen==4.
|
|
66
|
+
"commitizen==4.19.2",
|
|
67
67
|
]
|
|
68
68
|
dev = [
|
|
69
69
|
{ include-group = "release" },
|
|
70
|
-
"coverage==7.
|
|
71
|
-
"mypy==2.
|
|
72
|
-
"pre-commit==4.
|
|
70
|
+
"coverage==7.17.0",
|
|
71
|
+
"mypy==2.4.0",
|
|
72
|
+
"pre-commit==4.7.0",
|
|
73
73
|
"pytest==9.1.1",
|
|
74
|
-
"ruff==0.
|
|
75
|
-
"types-PyYAML==6.0.12.
|
|
74
|
+
"ruff==0.17.2",
|
|
75
|
+
"types-PyYAML==6.0.12.20260906",
|
|
76
76
|
]
|
|
77
77
|
|
|
78
78
|
[project.scripts]
|
|
@@ -195,7 +195,7 @@ warn_unused_ignores = true
|
|
|
195
195
|
# Garmin's JSON into both. Spelling the shape out is what stops Any spreading
|
|
196
196
|
# from the two files that have a reason for it into the ones that do not.
|
|
197
197
|
disallow_any_generics = true
|
|
198
|
-
#
|
|
198
|
+
# Much of what garminconnect hands back is Any, so without this a function can
|
|
199
199
|
# promise `dict[str, Any]` and return whatever came off the wire unchecked.
|
|
200
200
|
# `garmin/client.py` casts at the boundary instead, which is what an adapter is.
|
|
201
201
|
warn_return_any = true
|
|
@@ -204,12 +204,6 @@ warn_return_any = true
|
|
|
204
204
|
# passes it through.
|
|
205
205
|
no_implicit_reexport = true
|
|
206
206
|
|
|
207
|
-
# garminconnect ships no type information. garmin/client.py is the only module
|
|
208
|
-
# that imports it, which is what keeping the adapter in one place buys.
|
|
209
|
-
[[tool.mypy.overrides]]
|
|
210
|
-
module = "garminconnect.*"
|
|
211
|
-
ignore_missing_imports = true
|
|
212
|
-
|
|
213
207
|
[tool.pytest.ini_options]
|
|
214
208
|
pythonpath = ["src"]
|
|
215
209
|
testpaths = ["tests"]
|
|
@@ -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()
|
|
@@ -341,6 +341,21 @@ def next_weight_above(
|
|
|
341
341
|
return _rungs_above(nxt, weight, chosen_step(spec, nxt.minimum, bodyweight))
|
|
342
342
|
|
|
343
343
|
|
|
344
|
+
def note_step(spec: ExerciseSpec, weight: float) -> float:
|
|
345
|
+
"""The increment the step's note names for a target at `weight`.
|
|
346
|
+
|
|
347
|
+
What rule 3 will actually add next, so the note follows the stack onto its
|
|
348
|
+
larger plates and across onto the next rack rather than always naming the
|
|
349
|
+
smallest increment the load type has. At the top of the equipment there is
|
|
350
|
+
no next load, and the step this weight would take is named instead. With
|
|
351
|
+
no load yet there is nothing to step from, and the declared step stands.
|
|
352
|
+
"""
|
|
353
|
+
if weight <= 0:
|
|
354
|
+
return spec.weight_step
|
|
355
|
+
heavier = next_weight_above(spec, weight)
|
|
356
|
+
return heavier - weight if heavier is not None else chosen_step(spec, weight)
|
|
357
|
+
|
|
358
|
+
|
|
344
359
|
def next_weight_below(
|
|
345
360
|
spec: ExerciseSpec, weight: float, bodyweight: float = 0.0
|
|
346
361
|
) -> float | None:
|
|
@@ -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
|
|
@@ -239,6 +271,10 @@ class ExerciseSpec:
|
|
|
239
271
|
|
|
240
272
|
@property
|
|
241
273
|
def note(self) -> str:
|
|
274
|
+
"""The note at the declared `weight_step`; see `note_at`."""
|
|
275
|
+
return self.note_at(self.weight_step)
|
|
276
|
+
|
|
277
|
+
def note_at(self, step: float) -> str:
|
|
242
278
|
"""How this exercise is programmed, for the step's notes field.
|
|
243
279
|
|
|
244
280
|
The target already tells you what to do today; this says what you are
|
|
@@ -250,13 +286,16 @@ class ExerciseSpec:
|
|
|
250
286
|
rather than about taste: Garmin silently drops a note past 512
|
|
251
287
|
characters, and `GENERATED_NOTE` cannot match one carrying a newline,
|
|
252
288
|
so either would leave this tool unable to recognise what it had just
|
|
253
|
-
written.
|
|
254
|
-
|
|
289
|
+
written. A screen may run out well before 512 - a Forerunner 945 does,
|
|
290
|
+
at 160 - which is what `settings.watch_note_limit` is for.
|
|
291
|
+
|
|
292
|
+
`step` is the increment to name, which depends on the weight where the
|
|
293
|
+
equipment offers more than one - `domain/effort.note_step` decides it.
|
|
255
294
|
"""
|
|
256
295
|
span = f"{self.rep_low}-{self.rep_high} {'s' if self.time_based else 'reps'}"
|
|
257
296
|
if self.rep_step != 1:
|
|
258
297
|
span += f" by {self.rep_step}"
|
|
259
|
-
load = "bodyweight" if self.bodyweight else f"+{
|
|
298
|
+
load = "bodyweight" if self.bodyweight else f"+{step:g} kg"
|
|
260
299
|
written = f"{span} | {load}"
|
|
261
300
|
# One line, whatever the config was written across. A cue holding a
|
|
262
301
|
# newline renders a note that `GENERATED_NOTE` cannot match, and a note
|
|
@@ -335,6 +374,13 @@ class Config:
|
|
|
335
374
|
#: keeps it current without anyone editing a file. Only ever an input to
|
|
336
375
|
#: `check`; no target depends on it.
|
|
337
376
|
bodyweight: float | None = None
|
|
377
|
+
#: How long a note may be before your watch stops showing all of it. Here
|
|
378
|
+
#: rather than a constant because the cap is the screen's and the screens
|
|
379
|
+
#: disagree: a Fenix 9 Pro shows all 512 characters Garmin keeps, while a
|
|
380
|
+
#: Forerunner 945 shows 160 and cuts from 165. Unset means the stored cap,
|
|
381
|
+
#: which reports nothing a watch could have shown; state your own screen to
|
|
382
|
+
#: be warned before it cuts. Only ever an input to `check`.
|
|
383
|
+
watch_note_limit: int = STORED_NOTE
|
|
338
384
|
#: The file this was read from. Carried so that a use case which learns
|
|
339
385
|
#: something the file should record - a workout id Garmin has just issued -
|
|
340
386
|
#: can write it back without the CLI having to pass the path separately.
|