repwise 3.4.0__tar.gz → 3.5.1__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.1}/PKG-INFO +2 -2
- {repwise-3.4.0 → repwise-3.5.1}/pyproject.toml +13 -15
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/__init__.py +1 -1
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/update.py +23 -3
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/domain/effort.py +15 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/domain/models.py +8 -1
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/domain/progression.py +5 -1
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/garmin/client.py +10 -8
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/garmin/payloads.py +2 -1
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/planner.py +100 -24
- {repwise-3.4.0 → repwise-3.5.1/src/repwise.egg-info}/PKG-INFO +2 -2
- repwise-3.5.1/src/repwise.egg-info/requires.txt +2 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_client.py +13 -7
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_payloads.py +9 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_planner.py +77 -18
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_progression.py +8 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_update.py +74 -1
- repwise-3.4.0/src/repwise.egg-info/requires.txt +0 -2
- {repwise-3.4.0 → repwise-3.5.1}/LICENSE +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/README.md +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/setup.cfg +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/__main__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/checking.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/fetch.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/importing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/listing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/logout.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/app/report.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/checker.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/cli/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/cli/completion.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/cli/parser.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/config.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/domain/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/domain/matching.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/dumps.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/errors.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/garmin/__init__.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/garmin/catalog.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/importer.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/log.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise/yamlio.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise.egg-info/SOURCES.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_catalog.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_checker.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_checking.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_cli.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_completion.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_config.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_dumps.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_effort.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_fetch.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_importer.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_importing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_listing.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_log.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_logout.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_main.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_matching.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_models.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/tests/test_report.py +0 -0
- {repwise-3.4.0 → repwise-3.5.1}/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.1
|
|
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.20
|
|
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.1"
|
|
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.20",
|
|
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.3",
|
|
67
67
|
]
|
|
68
68
|
dev = [
|
|
69
69
|
{ include-group = "release" },
|
|
70
|
-
"coverage==7.
|
|
71
|
-
"mypy==2.
|
|
72
|
-
"pre-commit==4.
|
|
73
|
-
"pytest==9.
|
|
74
|
-
"ruff==0.
|
|
70
|
+
"coverage==7.17.0",
|
|
71
|
+
"mypy==2.4.1",
|
|
72
|
+
"pre-commit==4.7.0",
|
|
73
|
+
"pytest==9.2.0",
|
|
74
|
+
"ruff==0.17.3",
|
|
75
75
|
"types-PyYAML==6.0.12.20260906",
|
|
76
76
|
]
|
|
77
77
|
|
|
@@ -92,6 +92,10 @@ version_provider = "pep621"
|
|
|
92
92
|
# hand-cut 0.1.0 tag, so it is stated only to pin it: the default has changed
|
|
93
93
|
# upstream before, and a silent change would start a second tag series.
|
|
94
94
|
tag_format = "$version"
|
|
95
|
+
# The web service's image tags, from .github/workflows/web.yml. They share the
|
|
96
|
+
# repository's tags but are not repwise releases, and without this commitizen
|
|
97
|
+
# warns about each one on every bump.
|
|
98
|
+
ignored_tag_formats = ["repwise-web-*"]
|
|
95
99
|
version_files = ["src/repwise/__init__.py:__version__"]
|
|
96
100
|
update_changelog_on_bump = true
|
|
97
101
|
# History before 0.1.0 predates conventional commits, so there is nothing to
|
|
@@ -195,7 +199,7 @@ warn_unused_ignores = true
|
|
|
195
199
|
# Garmin's JSON into both. Spelling the shape out is what stops Any spreading
|
|
196
200
|
# from the two files that have a reason for it into the ones that do not.
|
|
197
201
|
disallow_any_generics = true
|
|
198
|
-
#
|
|
202
|
+
# Much of what garminconnect hands back is Any, so without this a function can
|
|
199
203
|
# promise `dict[str, Any]` and return whatever came off the wire unchecked.
|
|
200
204
|
# `garmin/client.py` casts at the boundary instead, which is what an adapter is.
|
|
201
205
|
warn_return_any = true
|
|
@@ -204,12 +208,6 @@ warn_return_any = true
|
|
|
204
208
|
# passes it through.
|
|
205
209
|
no_implicit_reexport = true
|
|
206
210
|
|
|
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
211
|
[tool.pytest.ini_options]
|
|
214
212
|
pythonpath = ["src"]
|
|
215
213
|
testpaths = ["tests"]
|
|
@@ -39,6 +39,7 @@ from ..planner import (
|
|
|
39
39
|
logged_for,
|
|
40
40
|
plan_sync,
|
|
41
41
|
plan_workout,
|
|
42
|
+
trained_exercises,
|
|
42
43
|
)
|
|
43
44
|
from .fetch import cache_activities
|
|
44
45
|
from .report import report_plan
|
|
@@ -457,6 +458,20 @@ def advance_trained(
|
|
|
457
458
|
plans: list[Plan] = []
|
|
458
459
|
usable = False
|
|
459
460
|
|
|
461
|
+
# A newer session that trained a shared exercise has the last word on its
|
|
462
|
+
# marker, so an older one must leave it alone - see `superseded` on
|
|
463
|
+
# `plan_workout`. That needs every session's sets before the first is
|
|
464
|
+
# planned. Matched against the definitions as Garmin holds them, before
|
|
465
|
+
# this run changes any.
|
|
466
|
+
performed_by = [
|
|
467
|
+
performed_sets(session.exercise_sets(trained.activity_id))
|
|
468
|
+
for trained in sessions
|
|
469
|
+
]
|
|
470
|
+
trained_by = [
|
|
471
|
+
trained_exercises(trained.workout, payloads[garmin_id(trained.workout)], sets)
|
|
472
|
+
for trained, sets in zip(sessions, performed_by, strict=True)
|
|
473
|
+
]
|
|
474
|
+
|
|
460
475
|
for position, trained in enumerate(sessions):
|
|
461
476
|
workout, activity = trained.workout, trained.activity
|
|
462
477
|
activity_id = trained.activity_id
|
|
@@ -465,10 +480,9 @@ def advance_trained(
|
|
|
465
480
|
logger.info(f"Activity: {activity.get('activityName') or ''} ({activity_id})")
|
|
466
481
|
logger.info(f"Updating: {workout.key} -> workout {workout.garmin_workout_id}")
|
|
467
482
|
|
|
468
|
-
sets_payload = session.exercise_sets(activity_id)
|
|
469
483
|
payload = payloads[garmin_id(workout)]
|
|
470
484
|
|
|
471
|
-
performed =
|
|
485
|
+
performed = performed_by[position]
|
|
472
486
|
if not any(performed):
|
|
473
487
|
logger.warning("No working sets found in that activity; nothing to do.")
|
|
474
488
|
continue
|
|
@@ -486,7 +500,13 @@ def advance_trained(
|
|
|
486
500
|
history = gather_history(session, workout, trained.earlier, performed)
|
|
487
501
|
|
|
488
502
|
plan = plan_workout(
|
|
489
|
-
workout,
|
|
503
|
+
workout,
|
|
504
|
+
payload,
|
|
505
|
+
performed,
|
|
506
|
+
history,
|
|
507
|
+
asked,
|
|
508
|
+
trusted=trusted,
|
|
509
|
+
superseded=set().union(*trained_by[position + 1 :]),
|
|
490
510
|
)
|
|
491
511
|
report_plan(plan)
|
|
492
512
|
plans.append(plan)
|
|
@@ -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,
|
|
@@ -341,6 +342,33 @@ def logged_for(
|
|
|
341
342
|
return []
|
|
342
343
|
|
|
343
344
|
|
|
345
|
+
def shared_key(spec: ExerciseSpec) -> tuple[str, str]:
|
|
346
|
+
"""What makes two workouts' entries one exercise: the movement and its load.
|
|
347
|
+
|
|
348
|
+
The same rule `update` applies when it carries a decision from one workout
|
|
349
|
+
into another, where the same Garmin name on other equipment is a different
|
|
350
|
+
exercise.
|
|
351
|
+
"""
|
|
352
|
+
return normalise(spec.garmin_name), spec.load
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def trained_exercises(
|
|
356
|
+
workout: Workout, payload: dict[str, Any], performed: Performed
|
|
357
|
+
) -> set[tuple[str, str]]:
|
|
358
|
+
"""The exercises a session holds sets for, as `shared_key` names them.
|
|
359
|
+
|
|
360
|
+
Matched exactly as `plan_workout` matches them when it judges the session,
|
|
361
|
+
so that this is the set of exercises that session will have a verdict on.
|
|
362
|
+
"""
|
|
363
|
+
specs = index_specs(workout.exercises)
|
|
364
|
+
found = set()
|
|
365
|
+
for block in iter_exercise_blocks(payload):
|
|
366
|
+
spec = _match(block.step, specs)
|
|
367
|
+
if spec is not None and _logged_for(spec, block.step, performed, specs):
|
|
368
|
+
found.add(shared_key(spec))
|
|
369
|
+
return found
|
|
370
|
+
|
|
371
|
+
|
|
344
372
|
def _logged_for(
|
|
345
373
|
spec: ExerciseSpec,
|
|
346
374
|
step: dict[str, Any],
|
|
@@ -505,9 +533,12 @@ def _clamped(spec: ExerciseSpec, target: Target) -> Target:
|
|
|
505
533
|
the whole reason, exactly as it is for `_levelled`, so it need not wait to
|
|
506
534
|
be trained.
|
|
507
535
|
|
|
508
|
-
|
|
509
|
-
rule 3
|
|
510
|
-
than
|
|
536
|
+
A target above the new `rep_high` steps the load up and starts again at
|
|
537
|
+
`rep_low`, where rule 3 would have sent it: those reps were already more
|
|
538
|
+
than the range now asks for. Only where there is no heavier load - a
|
|
539
|
+
bodyweight exercise, or the top of the equipment - is it brought down to
|
|
540
|
+
`rep_high` instead. A target below the new `rep_low` is brought up to it,
|
|
541
|
+
at the same weight.
|
|
511
542
|
|
|
512
543
|
A ramp goes when the range can no longer hold one: its leading sets ask for
|
|
513
544
|
`rep_step` more, and at the top of the range that is a figure outside it.
|
|
@@ -515,6 +546,10 @@ def _clamped(spec: ExerciseSpec, target: Target) -> Target:
|
|
|
515
546
|
top = target.reps + spec.rep_step if target.lead else target.reps
|
|
516
547
|
if spec.rep_low <= target.reps and top <= spec.rep_high:
|
|
517
548
|
return target
|
|
549
|
+
if target.reps > spec.rep_high and not spec.bodyweight:
|
|
550
|
+
heavier = next_weight_above(spec, target.weight)
|
|
551
|
+
if heavier is not None:
|
|
552
|
+
return Target(spec.rep_low, heavier)
|
|
518
553
|
reps = min(max(target.reps, spec.rep_low), spec.rep_high)
|
|
519
554
|
lead = target.lead if reps + spec.rep_step <= spec.rep_high else 0
|
|
520
555
|
return Target(reps, target.weight, lead)
|
|
@@ -536,7 +571,12 @@ def _config_fixups(spec: ExerciseSpec, target: Target) -> Iterator[tuple[Target,
|
|
|
536
571
|
clamped = _clamped(spec, target)
|
|
537
572
|
if clamped != target:
|
|
538
573
|
span = f"{spec.rep_low}-{spec.rep_high}"
|
|
539
|
-
if clamped.
|
|
574
|
+
if clamped.weight != target.weight:
|
|
575
|
+
yield (
|
|
576
|
+
clamped,
|
|
577
|
+
f"outside the {span} range, up to {clamped.weight:g} kg at the bottom",
|
|
578
|
+
)
|
|
579
|
+
elif clamped.reps == target.reps:
|
|
540
580
|
# Only the ramp went. The base was inside the range the whole time
|
|
541
581
|
# and it is the leading sets - asking `rep_step` more - that were
|
|
542
582
|
# not, so neither end of the range is where this target was moved
|
|
@@ -625,12 +665,14 @@ def _judge( # noqa: PLR0913 - each argument is one independent input
|
|
|
625
665
|
return Change(spec, current, new, why, marker)
|
|
626
666
|
|
|
627
667
|
|
|
628
|
-
def _refresh_note(
|
|
668
|
+
def _refresh_note( # noqa: PLR0913 - each argument is one independent input
|
|
629
669
|
block: ExerciseBlock,
|
|
630
670
|
spec: ExerciseSpec,
|
|
631
671
|
marker: str | None,
|
|
632
672
|
notes: list[NoteChange],
|
|
633
673
|
warnings: list[str],
|
|
674
|
+
*,
|
|
675
|
+
weight: float,
|
|
634
676
|
) -> None:
|
|
635
677
|
"""Keep the step's notes field showing how the exercise is programmed.
|
|
636
678
|
|
|
@@ -649,12 +691,16 @@ def _refresh_note(
|
|
|
649
691
|
four that have nothing to say - an `update` for another workout, a second
|
|
650
692
|
`--apply` over the same activity, a run that found no session at all -
|
|
651
693
|
and the marker would survive only until the next command.
|
|
694
|
+
|
|
695
|
+
`weight` is the load the exercise is prescribed next, which decides the
|
|
696
|
+
step the note names wherever the equipment offers more than one.
|
|
652
697
|
"""
|
|
698
|
+
programmed = spec.note_at(note_step(spec, weight))
|
|
653
699
|
existing = [step_note(step) for step in block.steps]
|
|
654
700
|
own = [note for note in existing if note and not GENERATED_NOTE.match(note)]
|
|
655
701
|
if own:
|
|
656
702
|
warnings.append(
|
|
657
|
-
f"{spec.name}: has its own note, left alone (wanted {
|
|
703
|
+
f"{spec.name}: has its own note, left alone (wanted {programmed!r})"
|
|
658
704
|
)
|
|
659
705
|
return
|
|
660
706
|
|
|
@@ -665,7 +711,7 @@ def _refresh_note(
|
|
|
665
711
|
# very next session as a freeze that no longer exists.
|
|
666
712
|
if marker.startswith(FROZEN) and not spec.freeze:
|
|
667
713
|
marker = ""
|
|
668
|
-
wanted = with_marker(
|
|
714
|
+
wanted = with_marker(programmed, marker)
|
|
669
715
|
|
|
670
716
|
stale = [step for step in block.steps if step_note(step) != wanted]
|
|
671
717
|
if not stale:
|
|
@@ -767,12 +813,14 @@ class _Shaping:
|
|
|
767
813
|
warnings: list[str] = field(default_factory=list)
|
|
768
814
|
|
|
769
815
|
|
|
770
|
-
def _refresh_block(
|
|
816
|
+
def _refresh_block( # noqa: PLR0913 - each argument is one independent input
|
|
771
817
|
block: ExerciseBlock,
|
|
772
818
|
spec: ExerciseSpec,
|
|
773
819
|
current: Target | None,
|
|
774
820
|
marker: str | None,
|
|
775
821
|
shaped: _Shaping,
|
|
822
|
+
*,
|
|
823
|
+
decided: Target | None,
|
|
776
824
|
) -> list[dict[str, Any]] | None:
|
|
777
825
|
"""Write everything workouts.yaml decides about one exercise.
|
|
778
826
|
|
|
@@ -788,7 +836,8 @@ def _refresh_block(
|
|
|
788
836
|
a verdict - which is the whole reason `marker` is a parameter rather than
|
|
789
837
|
something `spec` could answer. `plan_workout` judges the session first and
|
|
790
838
|
passes what it found; `plan_sync` passes what the session that decided it
|
|
791
|
-
found elsewhere.
|
|
839
|
+
found elsewhere. `decided` is the target the exercise leaves with, whose
|
|
840
|
+
weight decides the step the note names.
|
|
792
841
|
|
|
793
842
|
Returns what `_refresh_sets` returned: the steps the exercise now occupies
|
|
794
843
|
when its count was rewritten, and None when it was not.
|
|
@@ -798,7 +847,14 @@ def _refresh_block(
|
|
|
798
847
|
# marker. Writing here puts the marker on every step that already exists,
|
|
799
848
|
# and a freshly built half is corrected on the next run - the same one-run
|
|
800
849
|
# lag a rep-range edit has always had.
|
|
801
|
-
_refresh_note(
|
|
850
|
+
_refresh_note(
|
|
851
|
+
block,
|
|
852
|
+
spec,
|
|
853
|
+
marker,
|
|
854
|
+
shaped.notes,
|
|
855
|
+
shaped.warnings,
|
|
856
|
+
weight=decided.weight if decided is not None else 0.0,
|
|
857
|
+
)
|
|
802
858
|
_refresh_rest(block, spec, shaped.rests, shaped.skips, shaped.warnings)
|
|
803
859
|
return _refresh_sets(block, spec, current, shaped.sets, shaped.warnings)
|
|
804
860
|
|
|
@@ -1139,6 +1195,7 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1139
1195
|
asked: dict[str, Target] | None = None,
|
|
1140
1196
|
*,
|
|
1141
1197
|
trusted: Container[str] | None = None,
|
|
1198
|
+
superseded: Container[tuple[str, str]] = (),
|
|
1142
1199
|
) -> Plan:
|
|
1143
1200
|
"""Bring a workout in line with the config, and advance what was trained.
|
|
1144
1201
|
|
|
@@ -1163,6 +1220,13 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1163
1220
|
exercise Garmin holds under another name is reused or rebuilt. Without it
|
|
1164
1221
|
every name falls back to its category, which is the behaviour this tool had
|
|
1165
1222
|
before it could tell a real exercise name from an invented one.
|
|
1223
|
+
|
|
1224
|
+
`superseded` is the exercises, as `shared_key` names them, that a newer
|
|
1225
|
+
session in the same run also trained. Their target is still judged here,
|
|
1226
|
+
but their marker is that session's to decide, so this one leaves the note
|
|
1227
|
+
as it is and carries no marker to other workouts. Deciding it here as well
|
|
1228
|
+
would rewrite the note on every run whenever the two sessions disagree,
|
|
1229
|
+
only for the newer one to write it back.
|
|
1166
1230
|
"""
|
|
1167
1231
|
specs = index_specs(workout.exercises)
|
|
1168
1232
|
|
|
@@ -1212,21 +1276,14 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1212
1276
|
added=added,
|
|
1213
1277
|
shaped=shaped,
|
|
1214
1278
|
)
|
|
1279
|
+
if change is not None and shared_key(spec) in superseded:
|
|
1280
|
+
change = replace(change, marker=None)
|
|
1215
1281
|
|
|
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
|
-
|
|
1282
|
+
decided = change.new if change is not None else current
|
|
1225
1283
|
# The last word on the target, whether a session decided it or nobody
|
|
1226
1284
|
# did: with partial progression off, a ramp is not a shape this workout
|
|
1227
1285
|
# is allowed to hold, so it is evened out here rather than left for a
|
|
1228
1286
|
# session that may not come.
|
|
1229
|
-
decided = change.new if change is not None else current
|
|
1230
1287
|
if decided is not None:
|
|
1231
1288
|
for fixed, label in _config_fixups(spec, decided):
|
|
1232
1289
|
# Whatever the session found is still worth saying alongside -
|
|
@@ -1239,11 +1296,25 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1239
1296
|
fixed,
|
|
1240
1297
|
f"{said}; {label}" if said and said not in SAYS_NOTHING else label,
|
|
1241
1298
|
# 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.
|
|
1299
|
+
# the session, so it does not get a say in the marker.
|
|
1244
1300
|
change.marker if change is not None else None,
|
|
1245
1301
|
)
|
|
1246
1302
|
|
|
1303
|
+
# What the config says about this exercise holds whether or not this
|
|
1304
|
+
# session moved anything. The marker is the one part that does not:
|
|
1305
|
+
# None where no session was judged, which leaves the note's alone.
|
|
1306
|
+
# After the fixups, which can move the load the note names a step from.
|
|
1307
|
+
recounted = _refresh_block(
|
|
1308
|
+
block,
|
|
1309
|
+
spec,
|
|
1310
|
+
current,
|
|
1311
|
+
change.marker if change is not None else None,
|
|
1312
|
+
shaped,
|
|
1313
|
+
decided=change.new if change is not None else current,
|
|
1314
|
+
)
|
|
1315
|
+
if recounted is not None:
|
|
1316
|
+
reshaped |= _relay(layout, position, recounted)
|
|
1317
|
+
|
|
1247
1318
|
if change is None:
|
|
1248
1319
|
continue
|
|
1249
1320
|
changes.append(change)
|
|
@@ -1307,14 +1378,19 @@ def plan_sync(
|
|
|
1307
1378
|
continue
|
|
1308
1379
|
|
|
1309
1380
|
current = block_target(block, spec)
|
|
1381
|
+
new = targets.get(normalise(spec.garmin_name))
|
|
1310
1382
|
|
|
1311
1383
|
recounted = _refresh_block(
|
|
1312
|
-
block,
|
|
1384
|
+
block,
|
|
1385
|
+
spec,
|
|
1386
|
+
current,
|
|
1387
|
+
markers.get(normalise(spec.garmin_name)),
|
|
1388
|
+
shaped,
|
|
1389
|
+
decided=new or current,
|
|
1313
1390
|
)
|
|
1314
1391
|
if recounted is not None:
|
|
1315
1392
|
reshaped |= _relay(layout, position, recounted)
|
|
1316
1393
|
|
|
1317
|
-
new = targets.get(normalise(spec.garmin_name))
|
|
1318
1394
|
if new is None:
|
|
1319
1395
|
continue
|
|
1320
1396
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: repwise
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.5.1
|
|
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.20
|
|
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."""
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Choosing which sessions to update, and updating more than one at a time."""
|
|
2
2
|
|
|
3
|
+
import copy
|
|
3
4
|
import logging
|
|
4
5
|
import os
|
|
5
6
|
from dataclasses import replace
|
|
@@ -18,7 +19,7 @@ from repwise.app.update import (
|
|
|
18
19
|
sessions_before,
|
|
19
20
|
)
|
|
20
21
|
from repwise.config import ConfigError
|
|
21
|
-
from repwise.domain.models import Config, GarminSettings, Workout
|
|
22
|
+
from repwise.domain.models import HOLD, Config, GarminSettings, Workout, marker_of
|
|
22
23
|
from repwise.errors import ActivityNotFound, ExitCode, GarminError, UsageError
|
|
23
24
|
from repwise.garmin.payloads import performed_sets
|
|
24
25
|
|
|
@@ -290,6 +291,78 @@ def test_a_shared_exercise_ends_up_at_the_most_recent_decision(account):
|
|
|
290
291
|
assert calf_targets(account.saved) == {"111": 18.0, "222": 18.0}
|
|
291
292
|
|
|
292
293
|
|
|
294
|
+
def calf_notes(saved) -> dict[str, str]:
|
|
295
|
+
"""The hold marker on the calf raise's note in each written workout."""
|
|
296
|
+
return {
|
|
297
|
+
workout_id: marker_of(step.get("description") or "")
|
|
298
|
+
for workout_id, payload in saved
|
|
299
|
+
for step in payload["workoutSegments"][0]["workoutSteps"]
|
|
300
|
+
if step["exerciseName"] == "WEIGHTED_STANDING_CALF_RAISE"
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
def calf_sessions(newer, older, workouts=None):
|
|
305
|
+
"""Workout A today and Workout B two days ago, each training only the calf.
|
|
306
|
+
|
|
307
|
+
The target is 20 x 20 kg, the top of the calf raise's range. `newer` and
|
|
308
|
+
`older` are the reps each session got on every set, or None for a session
|
|
309
|
+
that skipped the calf raise and trained the workout's other exercise.
|
|
310
|
+
"""
|
|
311
|
+
|
|
312
|
+
def session(reps, name, category):
|
|
313
|
+
if reps is None:
|
|
314
|
+
return sets_of(*[active(name, category, 8, 30000.0)] * 3)
|
|
315
|
+
calf = active("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", reps, 20000.0)
|
|
316
|
+
return sets_of(*[calf] * 3)
|
|
317
|
+
|
|
318
|
+
return FakeSession(
|
|
319
|
+
activities=[an_activity(900, "Workout A"), an_activity(800, "Workout B")],
|
|
320
|
+
workouts=workouts
|
|
321
|
+
or {
|
|
322
|
+
"111": steps(
|
|
323
|
+
rep_step("BARBELL_BACK_SQUAT", "SQUAT", 7, 30.0),
|
|
324
|
+
rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 20, 20.0),
|
|
325
|
+
),
|
|
326
|
+
"222": steps(
|
|
327
|
+
rep_step("BARBELL_BENCH_PRESS", "BENCH_PRESS", 8, 40.0),
|
|
328
|
+
rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 20, 20.0),
|
|
329
|
+
),
|
|
330
|
+
},
|
|
331
|
+
sets={
|
|
332
|
+
"900": session(newer, "BARBELL_BACK_SQUAT", "SQUAT"),
|
|
333
|
+
"800": session(older, "BARBELL_BENCH_PRESS", "BENCH_PRESS"),
|
|
334
|
+
},
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def test_a_shared_hold_is_the_newest_sessions_and_is_written_once():
|
|
339
|
+
"""Two sessions disagreeing about a shared exercise's hold.
|
|
340
|
+
|
|
341
|
+
B, the older, topped the calf raise out, which clears the marker; A, the
|
|
342
|
+
newer, missed, which sets it. A has the last word, so both end up holding.
|
|
343
|
+
The older session used to clear both notes on every run before A put the
|
|
344
|
+
marker back, so a run with nothing new rewrote both workouts.
|
|
345
|
+
"""
|
|
346
|
+
first = calf_sessions(newer=17, older=20)
|
|
347
|
+
run(first, apply=True)
|
|
348
|
+
assert calf_notes(first.saved) == {"111": HOLD, "222": HOLD}
|
|
349
|
+
|
|
350
|
+
stored = {workout_id: copy.deepcopy(payload) for workout_id, payload in first.saved}
|
|
351
|
+
again = calf_sessions(newer=17, older=20, workouts=stored)
|
|
352
|
+
run(again, apply=True)
|
|
353
|
+
|
|
354
|
+
assert again.saved == []
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def test_an_older_sessions_hold_still_reaches_a_workout_whose_session_skipped_it():
|
|
358
|
+
"""Only a newer session that trained the exercise takes the marker over."""
|
|
359
|
+
account = calf_sessions(newer=None, older=17)
|
|
360
|
+
|
|
361
|
+
run(account, apply=True)
|
|
362
|
+
|
|
363
|
+
assert calf_notes(account.saved) == {"111": HOLD, "222": HOLD}
|
|
364
|
+
|
|
365
|
+
|
|
293
366
|
def test_the_same_exercise_on_another_load_is_not_synced(account):
|
|
294
367
|
"""One Garmin name, two kinds of equipment: two exercises, not one.
|
|
295
368
|
|
|
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
|