repwise 3.4.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.4.0/src/repwise.egg-info → repwise-3.5.0}/PKG-INFO +2 -2
- {repwise-3.4.0 → repwise-3.5.0}/pyproject.toml +8 -14
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/__init__.py +1 -1
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/domain/effort.py +15 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/domain/models.py +8 -1
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/domain/progression.py +5 -1
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/garmin/client.py +10 -8
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/garmin/payloads.py +2 -1
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/planner.py +63 -24
- {repwise-3.4.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.4.0 → repwise-3.5.0}/tests/test_client.py +13 -7
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_payloads.py +9 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_planner.py +77 -18
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_progression.py +8 -0
- repwise-3.4.0/src/repwise.egg-info/requires.txt +0 -2
- {repwise-3.4.0 → repwise-3.5.0}/LICENSE +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/README.md +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/setup.cfg +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/__main__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/checking.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/fetch.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/importing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/listing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/logout.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/report.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/app/update.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/checker.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/cli/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/cli/completion.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/cli/parser.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/config.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/domain/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/domain/matching.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/dumps.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/errors.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/garmin/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/garmin/catalog.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/importer.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/log.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise/yamlio.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise.egg-info/SOURCES.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_catalog.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_checker.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_checking.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_cli.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_completion.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_config.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_dumps.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_effort.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_fetch.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_importer.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_importing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_listing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_log.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_logout.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_main.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_matching.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_models.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_report.py +0 -0
- {repwise-3.4.0 → repwise-3.5.0}/tests/test_update.py +0 -0
- {repwise-3.4.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,15 +63,15 @@ 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.
|
|
74
|
+
"ruff==0.17.2",
|
|
75
75
|
"types-PyYAML==6.0.12.20260906",
|
|
76
76
|
]
|
|
77
77
|
|
|
@@ -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"]
|
|
@@ -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:
|
|
@@ -271,6 +271,10 @@ class ExerciseSpec:
|
|
|
271
271
|
|
|
272
272
|
@property
|
|
273
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:
|
|
274
278
|
"""How this exercise is programmed, for the step's notes field.
|
|
275
279
|
|
|
276
280
|
The target already tells you what to do today; this says what you are
|
|
@@ -284,11 +288,14 @@ class ExerciseSpec:
|
|
|
284
288
|
so either would leave this tool unable to recognise what it had just
|
|
285
289
|
written. A screen may run out well before 512 - a Forerunner 945 does,
|
|
286
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.
|
|
287
294
|
"""
|
|
288
295
|
span = f"{self.rep_low}-{self.rep_high} {'s' if self.time_based else 'reps'}"
|
|
289
296
|
if self.rep_step != 1:
|
|
290
297
|
span += f" by {self.rep_step}"
|
|
291
|
-
load = "bodyweight" if self.bodyweight else f"+{
|
|
298
|
+
load = "bodyweight" if self.bodyweight else f"+{step:g} kg"
|
|
292
299
|
written = f"{span} | {load}"
|
|
293
300
|
# One line, whatever the config was written across. A cue holding a
|
|
294
301
|
# newline renders a note that `GENERATED_NOTE` cannot match, and a note
|
|
@@ -558,7 +558,11 @@ def _advance( # noqa: PLR0913 - each argument is one independent input
|
|
|
558
558
|
# nothing to confirm when there is nothing to add, and an exercise that
|
|
559
559
|
# is bodyweight or out of rack would otherwise be told, every run, to
|
|
560
560
|
# hold once more for a jump that is never coming.
|
|
561
|
-
|
|
561
|
+
#
|
|
562
|
+
# Nor for a target `rep_high` was lowered beneath: holding there would
|
|
563
|
+
# ask for fewer reps than the session just did, and with no session at
|
|
564
|
+
# all the planner already moves such a target onto the heavier load.
|
|
565
|
+
if topped < CONFIRMED_AFTER and current.reps <= spec.rep_high:
|
|
562
566
|
return (
|
|
563
567
|
Target(spec.rep_high, weight),
|
|
564
568
|
f"hit {floor} on every set{lifted}, top of the range, "
|
|
@@ -113,10 +113,11 @@ class GarminSession:
|
|
|
113
113
|
|
|
114
114
|
# --- reads ---
|
|
115
115
|
#
|
|
116
|
-
# garminconnect
|
|
117
|
-
#
|
|
118
|
-
# rather than letting
|
|
119
|
-
# asserts what Garmin sends, and is the one
|
|
116
|
+
# garminconnect types most of its getters as `dict[str, Any]`, but its raw
|
|
117
|
+
# calls return Any and a few getters a union wider than Garmin really sends.
|
|
118
|
+
# Declaring the shape here rather than letting either spread is the whole
|
|
119
|
+
# point of the adapter: one file asserts what Garmin sends, and is the one
|
|
120
|
+
# file to correct when it changes.
|
|
120
121
|
|
|
121
122
|
@_reporting("list your recent activities")
|
|
122
123
|
def recent_activities(self, limit: int | None = None) -> list[dict[str, Any]]:
|
|
@@ -128,19 +129,20 @@ class GarminSession:
|
|
|
128
129
|
away.
|
|
129
130
|
"""
|
|
130
131
|
limit = limit or self._settings.activity_search_limit
|
|
131
|
-
|
|
132
|
+
found = self._api.get_activities(0, limit, FITNESS_EQUIPMENT, STRENGTH)
|
|
133
|
+
return cast(list[dict[str, Any]], found or [])
|
|
132
134
|
|
|
133
135
|
@_reporting("fetch that activity")
|
|
134
136
|
def activity(self, activity_id: str) -> dict[str, Any]:
|
|
135
|
-
return
|
|
137
|
+
return self._api.get_activity(activity_id)
|
|
136
138
|
|
|
137
139
|
@_reporting("fetch the activity's exercise sets")
|
|
138
140
|
def exercise_sets(self, activity_id: str) -> dict[str, Any]:
|
|
139
|
-
return
|
|
141
|
+
return self._api.get_activity_exercise_sets(activity_id)
|
|
140
142
|
|
|
141
143
|
@_reporting("fetch the workout")
|
|
142
144
|
def workout(self, workout_id: str) -> dict[str, Any]:
|
|
143
|
-
return
|
|
145
|
+
return self._api.get_workout_by_id(workout_id)
|
|
144
146
|
|
|
145
147
|
@_reporting("fetch the workout that activity was performed against")
|
|
146
148
|
def executed_workout(self, activity_id: str) -> list[dict[str, Any]]:
|
|
@@ -20,6 +20,7 @@ from collections.abc import Iterator
|
|
|
20
20
|
from dataclasses import dataclass, field
|
|
21
21
|
from typing import Any
|
|
22
22
|
|
|
23
|
+
from ..domain.effort import note_step
|
|
23
24
|
from ..domain.matching import normalise
|
|
24
25
|
from ..domain.models import ExerciseSpec
|
|
25
26
|
from ..domain.progression import PerformedSet, Target
|
|
@@ -469,7 +470,7 @@ def new_group(spec: ExerciseSpec, target: Target) -> dict[str, Any]:
|
|
|
469
470
|
"targetValueTwo": 0.0,
|
|
470
471
|
}
|
|
471
472
|
apply_target(step, target)
|
|
472
|
-
apply_note(step, spec.
|
|
473
|
+
apply_note(step, spec.note_at(note_step(spec, target.weight)))
|
|
473
474
|
|
|
474
475
|
return {
|
|
475
476
|
"type": "RepeatGroupDTO",
|
|
@@ -10,6 +10,7 @@ from collections.abc import Container, Iterator
|
|
|
10
10
|
from dataclasses import dataclass, field, replace
|
|
11
11
|
from typing import Any
|
|
12
12
|
|
|
13
|
+
from .domain.effort import next_weight_above, note_step
|
|
13
14
|
from .domain.matching import ExerciseIndex, normalise, variants
|
|
14
15
|
from .domain.models import (
|
|
15
16
|
FROZEN,
|
|
@@ -505,9 +506,12 @@ def _clamped(spec: ExerciseSpec, target: Target) -> Target:
|
|
|
505
506
|
the whole reason, exactly as it is for `_levelled`, so it need not wait to
|
|
506
507
|
be trained.
|
|
507
508
|
|
|
508
|
-
|
|
509
|
-
rule 3
|
|
510
|
-
than
|
|
509
|
+
A target above the new `rep_high` steps the load up and starts again at
|
|
510
|
+
`rep_low`, where rule 3 would have sent it: those reps were already more
|
|
511
|
+
than the range now asks for. Only where there is no heavier load - a
|
|
512
|
+
bodyweight exercise, or the top of the equipment - is it brought down to
|
|
513
|
+
`rep_high` instead. A target below the new `rep_low` is brought up to it,
|
|
514
|
+
at the same weight.
|
|
511
515
|
|
|
512
516
|
A ramp goes when the range can no longer hold one: its leading sets ask for
|
|
513
517
|
`rep_step` more, and at the top of the range that is a figure outside it.
|
|
@@ -515,6 +519,10 @@ def _clamped(spec: ExerciseSpec, target: Target) -> Target:
|
|
|
515
519
|
top = target.reps + spec.rep_step if target.lead else target.reps
|
|
516
520
|
if spec.rep_low <= target.reps and top <= spec.rep_high:
|
|
517
521
|
return target
|
|
522
|
+
if target.reps > spec.rep_high and not spec.bodyweight:
|
|
523
|
+
heavier = next_weight_above(spec, target.weight)
|
|
524
|
+
if heavier is not None:
|
|
525
|
+
return Target(spec.rep_low, heavier)
|
|
518
526
|
reps = min(max(target.reps, spec.rep_low), spec.rep_high)
|
|
519
527
|
lead = target.lead if reps + spec.rep_step <= spec.rep_high else 0
|
|
520
528
|
return Target(reps, target.weight, lead)
|
|
@@ -536,7 +544,12 @@ def _config_fixups(spec: ExerciseSpec, target: Target) -> Iterator[tuple[Target,
|
|
|
536
544
|
clamped = _clamped(spec, target)
|
|
537
545
|
if clamped != target:
|
|
538
546
|
span = f"{spec.rep_low}-{spec.rep_high}"
|
|
539
|
-
if clamped.
|
|
547
|
+
if clamped.weight != target.weight:
|
|
548
|
+
yield (
|
|
549
|
+
clamped,
|
|
550
|
+
f"outside the {span} range, up to {clamped.weight:g} kg at the bottom",
|
|
551
|
+
)
|
|
552
|
+
elif clamped.reps == target.reps:
|
|
540
553
|
# Only the ramp went. The base was inside the range the whole time
|
|
541
554
|
# and it is the leading sets - asking `rep_step` more - that were
|
|
542
555
|
# not, so neither end of the range is where this target was moved
|
|
@@ -625,12 +638,14 @@ def _judge( # noqa: PLR0913 - each argument is one independent input
|
|
|
625
638
|
return Change(spec, current, new, why, marker)
|
|
626
639
|
|
|
627
640
|
|
|
628
|
-
def _refresh_note(
|
|
641
|
+
def _refresh_note( # noqa: PLR0913 - each argument is one independent input
|
|
629
642
|
block: ExerciseBlock,
|
|
630
643
|
spec: ExerciseSpec,
|
|
631
644
|
marker: str | None,
|
|
632
645
|
notes: list[NoteChange],
|
|
633
646
|
warnings: list[str],
|
|
647
|
+
*,
|
|
648
|
+
weight: float,
|
|
634
649
|
) -> None:
|
|
635
650
|
"""Keep the step's notes field showing how the exercise is programmed.
|
|
636
651
|
|
|
@@ -649,12 +664,16 @@ def _refresh_note(
|
|
|
649
664
|
four that have nothing to say - an `update` for another workout, a second
|
|
650
665
|
`--apply` over the same activity, a run that found no session at all -
|
|
651
666
|
and the marker would survive only until the next command.
|
|
667
|
+
|
|
668
|
+
`weight` is the load the exercise is prescribed next, which decides the
|
|
669
|
+
step the note names wherever the equipment offers more than one.
|
|
652
670
|
"""
|
|
671
|
+
programmed = spec.note_at(note_step(spec, weight))
|
|
653
672
|
existing = [step_note(step) for step in block.steps]
|
|
654
673
|
own = [note for note in existing if note and not GENERATED_NOTE.match(note)]
|
|
655
674
|
if own:
|
|
656
675
|
warnings.append(
|
|
657
|
-
f"{spec.name}: has its own note, left alone (wanted {
|
|
676
|
+
f"{spec.name}: has its own note, left alone (wanted {programmed!r})"
|
|
658
677
|
)
|
|
659
678
|
return
|
|
660
679
|
|
|
@@ -665,7 +684,7 @@ def _refresh_note(
|
|
|
665
684
|
# very next session as a freeze that no longer exists.
|
|
666
685
|
if marker.startswith(FROZEN) and not spec.freeze:
|
|
667
686
|
marker = ""
|
|
668
|
-
wanted = with_marker(
|
|
687
|
+
wanted = with_marker(programmed, marker)
|
|
669
688
|
|
|
670
689
|
stale = [step for step in block.steps if step_note(step) != wanted]
|
|
671
690
|
if not stale:
|
|
@@ -767,12 +786,14 @@ class _Shaping:
|
|
|
767
786
|
warnings: list[str] = field(default_factory=list)
|
|
768
787
|
|
|
769
788
|
|
|
770
|
-
def _refresh_block(
|
|
789
|
+
def _refresh_block( # noqa: PLR0913 - each argument is one independent input
|
|
771
790
|
block: ExerciseBlock,
|
|
772
791
|
spec: ExerciseSpec,
|
|
773
792
|
current: Target | None,
|
|
774
793
|
marker: str | None,
|
|
775
794
|
shaped: _Shaping,
|
|
795
|
+
*,
|
|
796
|
+
decided: Target | None,
|
|
776
797
|
) -> list[dict[str, Any]] | None:
|
|
777
798
|
"""Write everything workouts.yaml decides about one exercise.
|
|
778
799
|
|
|
@@ -788,7 +809,8 @@ def _refresh_block(
|
|
|
788
809
|
a verdict - which is the whole reason `marker` is a parameter rather than
|
|
789
810
|
something `spec` could answer. `plan_workout` judges the session first and
|
|
790
811
|
passes what it found; `plan_sync` passes what the session that decided it
|
|
791
|
-
found elsewhere.
|
|
812
|
+
found elsewhere. `decided` is the target the exercise leaves with, whose
|
|
813
|
+
weight decides the step the note names.
|
|
792
814
|
|
|
793
815
|
Returns what `_refresh_sets` returned: the steps the exercise now occupies
|
|
794
816
|
when its count was rewritten, and None when it was not.
|
|
@@ -798,7 +820,14 @@ def _refresh_block(
|
|
|
798
820
|
# marker. Writing here puts the marker on every step that already exists,
|
|
799
821
|
# and a freshly built half is corrected on the next run - the same one-run
|
|
800
822
|
# lag a rep-range edit has always had.
|
|
801
|
-
_refresh_note(
|
|
823
|
+
_refresh_note(
|
|
824
|
+
block,
|
|
825
|
+
spec,
|
|
826
|
+
marker,
|
|
827
|
+
shaped.notes,
|
|
828
|
+
shaped.warnings,
|
|
829
|
+
weight=decided.weight if decided is not None else 0.0,
|
|
830
|
+
)
|
|
802
831
|
_refresh_rest(block, spec, shaped.rests, shaped.skips, shaped.warnings)
|
|
803
832
|
return _refresh_sets(block, spec, current, shaped.sets, shaped.warnings)
|
|
804
833
|
|
|
@@ -1213,20 +1242,11 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1213
1242
|
shaped=shaped,
|
|
1214
1243
|
)
|
|
1215
1244
|
|
|
1216
|
-
|
|
1217
|
-
# session moved anything. The marker is the one part that does not:
|
|
1218
|
-
# None where no session was judged, which leaves the note's alone.
|
|
1219
|
-
recounted = _refresh_block(
|
|
1220
|
-
block, spec, current, change.marker if change is not None else None, shaped
|
|
1221
|
-
)
|
|
1222
|
-
if recounted is not None:
|
|
1223
|
-
reshaped |= _relay(layout, position, recounted)
|
|
1224
|
-
|
|
1245
|
+
decided = change.new if change is not None else current
|
|
1225
1246
|
# The last word on the target, whether a session decided it or nobody
|
|
1226
1247
|
# did: with partial progression off, a ramp is not a shape this workout
|
|
1227
1248
|
# is allowed to hold, so it is evened out here rather than left for a
|
|
1228
1249
|
# session that may not come.
|
|
1229
|
-
decided = change.new if change is not None else current
|
|
1230
1250
|
if decided is not None:
|
|
1231
1251
|
for fixed, label in _config_fixups(spec, decided):
|
|
1232
1252
|
# Whatever the session found is still worth saying alongside -
|
|
@@ -1239,11 +1259,25 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1239
1259
|
fixed,
|
|
1240
1260
|
f"{said}; {label}" if said and said not in SAYS_NOTHING else label,
|
|
1241
1261
|
# Levelling a ramp is a change of shape, not a verdict on
|
|
1242
|
-
# the session, so it does not get a say in the marker.
|
|
1243
|
-
# note has already been written by here either way.
|
|
1262
|
+
# the session, so it does not get a say in the marker.
|
|
1244
1263
|
change.marker if change is not None else None,
|
|
1245
1264
|
)
|
|
1246
1265
|
|
|
1266
|
+
# What the config says about this exercise holds whether or not this
|
|
1267
|
+
# session moved anything. The marker is the one part that does not:
|
|
1268
|
+
# None where no session was judged, which leaves the note's alone.
|
|
1269
|
+
# After the fixups, which can move the load the note names a step from.
|
|
1270
|
+
recounted = _refresh_block(
|
|
1271
|
+
block,
|
|
1272
|
+
spec,
|
|
1273
|
+
current,
|
|
1274
|
+
change.marker if change is not None else None,
|
|
1275
|
+
shaped,
|
|
1276
|
+
decided=change.new if change is not None else current,
|
|
1277
|
+
)
|
|
1278
|
+
if recounted is not None:
|
|
1279
|
+
reshaped |= _relay(layout, position, recounted)
|
|
1280
|
+
|
|
1247
1281
|
if change is None:
|
|
1248
1282
|
continue
|
|
1249
1283
|
changes.append(change)
|
|
@@ -1307,14 +1341,19 @@ def plan_sync(
|
|
|
1307
1341
|
continue
|
|
1308
1342
|
|
|
1309
1343
|
current = block_target(block, spec)
|
|
1344
|
+
new = targets.get(normalise(spec.garmin_name))
|
|
1310
1345
|
|
|
1311
1346
|
recounted = _refresh_block(
|
|
1312
|
-
block,
|
|
1347
|
+
block,
|
|
1348
|
+
spec,
|
|
1349
|
+
current,
|
|
1350
|
+
markers.get(normalise(spec.garmin_name)),
|
|
1351
|
+
shaped,
|
|
1352
|
+
decided=new or current,
|
|
1313
1353
|
)
|
|
1314
1354
|
if recounted is not None:
|
|
1315
1355
|
reshaped |= _relay(layout, position, recounted)
|
|
1316
1356
|
|
|
1317
|
-
new = targets.get(normalise(spec.garmin_name))
|
|
1318
1357
|
if new is None:
|
|
1319
1358
|
continue
|
|
1320
1359
|
|
|
@@ -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,9 +4,11 @@ import logging
|
|
|
4
4
|
import os
|
|
5
5
|
import stat
|
|
6
6
|
from pathlib import Path
|
|
7
|
+
from typing import cast
|
|
7
8
|
|
|
8
9
|
import pytest
|
|
9
10
|
from garminconnect import (
|
|
11
|
+
Garmin,
|
|
10
12
|
GarminConnectNotFoundError,
|
|
11
13
|
GarminConnectTooManyRequestsError,
|
|
12
14
|
)
|
|
@@ -66,7 +68,7 @@ class StubApi(LibraryUrls):
|
|
|
66
68
|
|
|
67
69
|
def session(total: int) -> tuple[GarminSession, StubApi]:
|
|
68
70
|
api = StubApi(total)
|
|
69
|
-
return GarminSession(api, GarminSettings()), api
|
|
71
|
+
return GarminSession(cast(Garmin, api), GarminSettings()), api
|
|
70
72
|
|
|
71
73
|
|
|
72
74
|
def test_a_single_short_page_needs_one_call():
|
|
@@ -143,7 +145,7 @@ class WriteStub(LibraryUrls):
|
|
|
143
145
|
|
|
144
146
|
def writer(messages=None) -> tuple[GarminSession, WriteStub]:
|
|
145
147
|
api = WriteStub(messages)
|
|
146
|
-
return GarminSession(api, GarminSettings()), api
|
|
148
|
+
return GarminSession(cast(Garmin, api), GarminSettings()), api
|
|
147
149
|
|
|
148
150
|
|
|
149
151
|
def test_save_workout_goes_through_update_workout():
|
|
@@ -195,7 +197,7 @@ class BrokenApi:
|
|
|
195
197
|
|
|
196
198
|
|
|
197
199
|
def broken(failure: Exception) -> GarminSession:
|
|
198
|
-
return GarminSession(BrokenApi(failure), GarminSettings())
|
|
200
|
+
return GarminSession(cast(Garmin, BrokenApi(failure)), GarminSettings())
|
|
199
201
|
|
|
200
202
|
|
|
201
203
|
def test_a_library_failure_becomes_a_garmin_error():
|
|
@@ -557,7 +559,7 @@ class ScaleStub:
|
|
|
557
559
|
|
|
558
560
|
def weighing(body) -> tuple[GarminSession, ScaleStub]:
|
|
559
561
|
api = ScaleStub(body)
|
|
560
|
-
return GarminSession(api, GarminSettings()), api
|
|
562
|
+
return GarminSession(cast(Garmin, api), GarminSettings()), api
|
|
561
563
|
|
|
562
564
|
|
|
563
565
|
def test_the_window_average_is_preferred_and_converted_from_grams():
|
|
@@ -624,7 +626,7 @@ def listed(activity_id="111", reps=40):
|
|
|
624
626
|
def caching(tmp_path, activities=()) -> tuple[CachedSession, ActivityStub]:
|
|
625
627
|
api = ActivityStub(activities)
|
|
626
628
|
settings = GarminSettings(dump_dir=str(tmp_path), activity_caching=True)
|
|
627
|
-
return CachedSession(api, settings), api
|
|
629
|
+
return CachedSession(cast(Garmin, api), settings), api
|
|
628
630
|
|
|
629
631
|
|
|
630
632
|
def test_the_first_read_of_a_session_asks_garmin(tmp_path):
|
|
@@ -670,14 +672,18 @@ def test_only_strength_sessions_are_asked_for(tmp_path):
|
|
|
670
672
|
"""Strength training is a sub-type of fitness equipment to Garmin's search:
|
|
671
673
|
asked for as a type of its own it answers 400."""
|
|
672
674
|
api = ActivityStub()
|
|
673
|
-
GarminSession(
|
|
675
|
+
GarminSession(
|
|
676
|
+
cast(Garmin, api), GarminSettings(dump_dir=str(tmp_path))
|
|
677
|
+
).recent_activities()
|
|
674
678
|
|
|
675
679
|
assert api.searched == ("fitness_equipment", "strength_training")
|
|
676
680
|
|
|
677
681
|
|
|
678
682
|
def test_a_plain_session_holds_nothing(tmp_path):
|
|
679
683
|
"""`is_cached` is asked by callers that only want to report a skip."""
|
|
680
|
-
plain = GarminSession(
|
|
684
|
+
plain = GarminSession(
|
|
685
|
+
cast(Garmin, ActivityStub()), GarminSettings(dump_dir=str(tmp_path))
|
|
686
|
+
)
|
|
681
687
|
|
|
682
688
|
assert plain.is_cached("111") is False
|
|
683
689
|
|
|
@@ -14,6 +14,7 @@ from builders import (
|
|
|
14
14
|
workout,
|
|
15
15
|
)
|
|
16
16
|
|
|
17
|
+
from repwise.domain.models import LoadTier
|
|
17
18
|
from repwise.domain.progression import Target
|
|
18
19
|
from repwise.garmin.payloads import (
|
|
19
20
|
GENERATED_NOTE,
|
|
@@ -379,6 +380,14 @@ def test_a_built_exercise_carries_its_note():
|
|
|
379
380
|
assert step_note(step) == SQUAT.note
|
|
380
381
|
|
|
381
382
|
|
|
383
|
+
def test_a_built_exercise_notes_the_step_its_target_will_take():
|
|
384
|
+
stack = replace(
|
|
385
|
+
SQUAT, weight_step=1.25, tiers=(LoadTier(5.0, None, (1.25, 2.5, 5.0)),)
|
|
386
|
+
)
|
|
387
|
+
group = new_group(stack, Target(8, 40.0))
|
|
388
|
+
assert step_note(group["workoutSteps"][0]) == "6-10 reps | +5 kg"
|
|
389
|
+
|
|
390
|
+
|
|
382
391
|
def test_a_start_weight_is_where_a_built_exercise_begins():
|
|
383
392
|
payload = built(replace(SQUAT, start_weight=40.0))
|
|
384
393
|
step = next(iter(iter_exercise_blocks(payload))).step
|
|
@@ -16,7 +16,7 @@ from builders import (
|
|
|
16
16
|
workout,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
from repwise.domain.models import Config, Workout
|
|
19
|
+
from repwise.domain.models import Config, LoadTier, Workout
|
|
20
20
|
from repwise.domain.progression import PerformedSet, Session, Target
|
|
21
21
|
from repwise.errors import ActivityNotFound
|
|
22
22
|
from repwise.garmin.payloads import (
|
|
@@ -343,6 +343,38 @@ def test_a_stale_generated_note_is_replaced():
|
|
|
343
343
|
], "the report has both halves of the edit, not just the exercise's name"
|
|
344
344
|
|
|
345
345
|
|
|
346
|
+
def test_the_note_names_the_step_the_target_weight_will_take():
|
|
347
|
+
"""A stack that takes several plate sizes steps by more as the load grows,
|
|
348
|
+
and the note has to say the jump that is actually coming, not the smallest
|
|
349
|
+
the load type names."""
|
|
350
|
+
stack = replace(
|
|
351
|
+
CALF, weight_step=1.25, tiers=(LoadTier(5.0, None, (1.25, 2.5, 5.0)),)
|
|
352
|
+
)
|
|
353
|
+
step = rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 14, 12.5)
|
|
354
|
+
step["description"] = stack.note # "12-20 reps | +1.25 kg", the smallest
|
|
355
|
+
plan = plan_workout(a_workout(exercises=[stack]), workout(step), ({}, {}))
|
|
356
|
+
|
|
357
|
+
assert step_note(step) == "12-20 reps | +2.5 kg"
|
|
358
|
+
assert noted(plan) == [
|
|
359
|
+
(
|
|
360
|
+
"Weighted Standing Calf Raise",
|
|
361
|
+
"12-20 reps | +1.25 kg",
|
|
362
|
+
"12-20 reps | +2.5 kg",
|
|
363
|
+
)
|
|
364
|
+
]
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def test_the_note_names_the_jump_onto_the_next_rack():
|
|
368
|
+
racks = replace(
|
|
369
|
+
LATERAL,
|
|
370
|
+
tiers=(LoadTier(1.0, 10.0, (1.0,)), LoadTier(12.0, 30.0, (2.0,))),
|
|
371
|
+
)
|
|
372
|
+
step = rep_step("DUMBBELL_LATERAL_RAISE", "LATERAL_RAISE", 13, 10.0)
|
|
373
|
+
plan_workout(a_workout(exercises=[racks]), workout(step), ({}, {}))
|
|
374
|
+
|
|
375
|
+
assert step_note(step) == "12-15 reps | +2 kg"
|
|
376
|
+
|
|
377
|
+
|
|
346
378
|
def test_a_hand_written_note_is_never_overwritten():
|
|
347
379
|
"""Losing a coaching cue you typed into Connect would be silent, so the
|
|
348
380
|
tool reports it and keeps its hands off."""
|
|
@@ -1590,15 +1622,22 @@ def a_stored_squat(reps, weight=20.0, sets=3):
|
|
|
1590
1622
|
)
|
|
1591
1623
|
|
|
1592
1624
|
|
|
1593
|
-
def
|
|
1594
|
-
"""Narrowing the range is the whole reason, so it need not wait to be trained.
|
|
1625
|
+
def test_a_target_above_the_new_top_steps_the_load_with_no_session_at_all():
|
|
1626
|
+
"""Narrowing the range is the whole reason, so it need not wait to be trained.
|
|
1627
|
+
|
|
1628
|
+
Reps past the new top were already doing more than the range asks for, so
|
|
1629
|
+
the target goes where rule 3 would have sent it: one load step up, back at
|
|
1630
|
+
the bottom of the range.
|
|
1631
|
+
"""
|
|
1595
1632
|
built = a_stored_squat(12)
|
|
1596
1633
|
plan = plan_workout(a_workout(exercises=[NARROWED]), built)
|
|
1597
1634
|
|
|
1598
|
-
assert [c.new for c in plan.moved] == [Target(
|
|
1599
|
-
assert plan.changes[0].reason ==
|
|
1635
|
+
assert [c.new for c in plan.moved] == [Target(6, 22.5)]
|
|
1636
|
+
assert plan.changes[0].reason == (
|
|
1637
|
+
"outside the 6-10 range, up to 22.5 kg at the bottom"
|
|
1638
|
+
)
|
|
1600
1639
|
assert [step_target(b.step) for b in iter_exercise_blocks(built)] == [
|
|
1601
|
-
Target(
|
|
1640
|
+
Target(6, 22.5)
|
|
1602
1641
|
], "the workout Garmin holds is rewritten, not just reported"
|
|
1603
1642
|
|
|
1604
1643
|
|
|
@@ -1615,22 +1654,41 @@ def test_a_target_already_inside_the_range_is_left_alone():
|
|
|
1615
1654
|
assert plan.changes == []
|
|
1616
1655
|
|
|
1617
1656
|
|
|
1618
|
-
def
|
|
1619
|
-
"""
|
|
1620
|
-
|
|
1621
|
-
plan = plan_workout(
|
|
1622
|
-
a_workout(exercises=[NARROWED]), a_stored_squat(12, weight=40.0)
|
|
1623
|
-
)
|
|
1657
|
+
def test_a_target_above_the_top_of_the_equipment_is_brought_to_the_top():
|
|
1658
|
+
"""With no heavier load to move to, the range is all that is left."""
|
|
1659
|
+
capped = replace(NARROWED, max_weight=40.0)
|
|
1660
|
+
plan = plan_workout(a_workout(exercises=[capped]), a_stored_squat(12, weight=40.0))
|
|
1624
1661
|
|
|
1625
1662
|
assert plan.moved[0].new == Target(10, 40.0)
|
|
1663
|
+
assert plan.changes[0].reason == "outside the 6-10 range, brought to the top"
|
|
1664
|
+
|
|
1665
|
+
|
|
1666
|
+
def test_a_bodyweight_target_above_the_new_top_is_brought_to_the_top():
|
|
1667
|
+
shortened = replace(PLANK, rep_high=50)
|
|
1668
|
+
definition = payload(repeat(hold_step("PLANK", "PLANK", 55), sets=3))
|
|
1669
|
+
plan = plan_workout(a_workout(exercises=[shortened]), definition)
|
|
1670
|
+
|
|
1671
|
+
assert plan.moved[0].new == Target(50, 0.0)
|
|
1626
1672
|
|
|
1627
1673
|
|
|
1628
|
-
def
|
|
1629
|
-
"""The leading sets ask for a rep more, which at the top is outside it."""
|
|
1674
|
+
def test_a_ramp_above_the_new_top_steps_the_load_and_is_dropped():
|
|
1630
1675
|
built = a_ramped_squat(base=12, lead=1)
|
|
1631
1676
|
plan = plan_workout(a_workout(exercises=[NARROWED]), built)
|
|
1632
1677
|
|
|
1633
|
-
assert plan.moved[0].new == Target(
|
|
1678
|
+
assert plan.moved[0].new == Target(6, 22.5, 0)
|
|
1679
|
+
|
|
1680
|
+
|
|
1681
|
+
def test_the_note_names_the_step_from_the_load_the_range_moved_to():
|
|
1682
|
+
"""Written in the same run, not one behind the target it describes."""
|
|
1683
|
+
stack = replace(
|
|
1684
|
+
NARROWED, weight_step=1.25, tiers=(LoadTier(5.0, None, (1.25, 2.5, 5.0)),)
|
|
1685
|
+
)
|
|
1686
|
+
built = a_stored_squat(12, weight=13.75) # +1.25 from here, +2.5 from 15
|
|
1687
|
+
plan = plan_workout(a_workout(exercises=[stack]), built)
|
|
1688
|
+
|
|
1689
|
+
assert plan.moved[0].new == Target(6, 15.0)
|
|
1690
|
+
step = next(iter(iter_exercise_blocks(built))).step
|
|
1691
|
+
assert step_note(step) == "6-10 reps | +2.5 kg"
|
|
1634
1692
|
|
|
1635
1693
|
|
|
1636
1694
|
def test_a_ramp_at_the_top_is_dropped_without_claiming_the_target_moved():
|
|
@@ -1679,13 +1737,14 @@ def test_a_session_that_tops_the_new_range_earns_the_load_and_needs_no_clamp():
|
|
|
1679
1737
|
|
|
1680
1738
|
|
|
1681
1739
|
def test_a_session_that_missed_still_has_its_target_brought_into_range():
|
|
1682
|
-
"""The session has its say, and the
|
|
1740
|
+
"""The session has its say, and the range is the last word after it."""
|
|
1683
1741
|
built = a_stored_squat(12)
|
|
1684
1742
|
plan = plan_workout(a_workout(exercises=[NARROWED]), built, a_squat_session(8))
|
|
1685
1743
|
|
|
1686
|
-
assert plan.moved[0].new == Target(
|
|
1744
|
+
assert plan.moved[0].new == Target(6, 22.5)
|
|
1687
1745
|
assert plan.changes[0].reason == (
|
|
1688
|
-
"missed target, 8 on the worst set;
|
|
1746
|
+
"missed target, 8 on the worst set; "
|
|
1747
|
+
"outside the 6-10 range, up to 22.5 kg at the bottom"
|
|
1689
1748
|
)
|
|
1690
1749
|
|
|
1691
1750
|
|
|
@@ -704,6 +704,14 @@ def test_an_overshoot_is_still_capped_at_the_top_while_it_holds():
|
|
|
704
704
|
assert target == Target(10, 20.0)
|
|
705
705
|
|
|
706
706
|
|
|
707
|
+
def test_a_target_left_above_a_narrowed_range_adds_the_load_without_holding():
|
|
708
|
+
"""`rep_high` was lowered under a stored 11. Holding would ask for 10, less
|
|
709
|
+
than the session just did, so the load goes up as it would with no session
|
|
710
|
+
at all."""
|
|
711
|
+
target, why = next_target(FOUR_SET_SQUAT, Target(11, 20.0), [P(11, 20.0)] * 4)
|
|
712
|
+
assert target == Target(6, 22.5), why
|
|
713
|
+
|
|
714
|
+
|
|
707
715
|
def test_a_rebased_load_needs_confirming_at_that_load():
|
|
708
716
|
"""Rule 5 admits 22.5 and the session tops the range on it, but the top of
|
|
709
717
|
the range at 22.5 has still only been reached once."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|