repwise 3.0.0__tar.gz → 3.2.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.0.0/src/repwise.egg-info → repwise-3.2.0}/PKG-INFO +1 -1
- {repwise-3.0.0 → repwise-3.2.0}/pyproject.toml +86 -2
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/__init__.py +1 -1
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/fetch.py +2 -2
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/importing.py +3 -2
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/listing.py +3 -2
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/report.py +15 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/update.py +36 -14
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/checker.py +46 -12
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/cli/__init__.py +15 -1
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/cli/parser.py +1 -2
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/config.py +190 -19
- repwise-3.2.0/src/repwise/domain/effort.py +367 -0
- repwise-3.2.0/src/repwise/domain/models.py +363 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/domain/progression.py +111 -39
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/dumps.py +10 -5
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/errors.py +6 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/garmin/catalog.py +4 -3
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/garmin/client.py +11 -6
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/garmin/payloads.py +39 -5
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/importer.py +14 -10
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/log.py +1 -1
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/planner.py +213 -28
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/yamlio.py +16 -6
- {repwise-3.0.0 → repwise-3.2.0/src/repwise.egg-info}/PKG-INFO +1 -1
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise.egg-info/SOURCES.txt +4 -1
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_catalog.py +92 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_checker.py +222 -5
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_checking.py +1 -1
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_config.py +248 -3
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_effort.py +182 -17
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_fetch.py +66 -4
- repwise-3.2.0/tests/test_importing.py +181 -0
- repwise-3.2.0/tests/test_listing.py +129 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_log.py +3 -3
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_main.py +125 -2
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_matching.py +10 -1
- repwise-3.2.0/tests/test_models.py +251 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_payloads.py +39 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_planner.py +441 -16
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_progression.py +184 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_report.py +114 -3
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_update.py +138 -2
- repwise-3.2.0/tests/test_yamlio.py +126 -0
- repwise-3.0.0/src/repwise/domain/effort.py +0 -199
- repwise-3.0.0/src/repwise/domain/models.py +0 -176
- repwise-3.0.0/tests/test_models.py +0 -43
- {repwise-3.0.0 → repwise-3.2.0}/LICENSE +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/README.md +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/setup.cfg +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/__main__.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/__init__.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/checking.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/app/logout.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/cli/completion.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/domain/__init__.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/domain/matching.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise/garmin/__init__.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise.egg-info/requires.txt +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_cli.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_client.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_completion.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_dumps.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_importer.py +0 -0
- {repwise-3.0.0 → repwise-3.2.0}/tests/test_logout.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "repwise"
|
|
7
|
-
version = "3.
|
|
7
|
+
version = "3.2.0"
|
|
8
8
|
description = "Advance Garmin strength workout targets using double progression"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -67,6 +67,7 @@ release = [
|
|
|
67
67
|
]
|
|
68
68
|
dev = [
|
|
69
69
|
{ include-group = "release" },
|
|
70
|
+
"coverage==7.16.0",
|
|
70
71
|
"mypy==2.3.1",
|
|
71
72
|
"pre-commit==4.6.2",
|
|
72
73
|
"pytest==9.1.1",
|
|
@@ -124,6 +125,23 @@ select = [
|
|
|
124
125
|
"BLE", # blind except - the existing noqa comments name this rule
|
|
125
126
|
"PL", # pylint subset
|
|
126
127
|
"RUF", # ruff's own
|
|
128
|
+
# Added as ratchets: each was already clean, so it costs nothing today and
|
|
129
|
+
# refuses the first regression. See [[tool.mypy.overrides]] below for the
|
|
130
|
+
# same reasoning applied to types.
|
|
131
|
+
"LOG", # logging misuse: a logger built by hand, warn() on the root
|
|
132
|
+
"PGH", # a bare `noqa` or `type: ignore` that names no rule
|
|
133
|
+
"FURB", # constructs with a plainer spelling
|
|
134
|
+
"A", # an argument or variable shadowing a builtin
|
|
135
|
+
# A boolean argument read at the call site as a bare True is a coin flip
|
|
136
|
+
# for the reader: `connect(settings, False)` says nothing about which of
|
|
137
|
+
# two flags it set. Keyword-only, so the call says what it means. The one
|
|
138
|
+
# exemption is `yamlio._Dumper.increase_indent`, whose signature is
|
|
139
|
+
# PyYAML's rather than ours, and which says so.
|
|
140
|
+
"FBT", # boolean traps
|
|
141
|
+
# `Any` in a signature where a real type exists. Where it has none - a
|
|
142
|
+
# dump, a parsed document - the noqa says so rather than the annotation
|
|
143
|
+
# quietly meaning nothing.
|
|
144
|
+
"ANN401", # dynamically typed signatures
|
|
127
145
|
]
|
|
128
146
|
ignore = [
|
|
129
147
|
# This is a CLI whose job is printing, and its errors carry the detail a
|
|
@@ -138,8 +156,53 @@ ignore = [
|
|
|
138
156
|
]
|
|
139
157
|
|
|
140
158
|
[tool.mypy]
|
|
141
|
-
|
|
159
|
+
# tools/ as well: the checks in there are part of the repository and read the
|
|
160
|
+
# same tree, so a wrong assumption about it should fail here rather than in a
|
|
161
|
+
# hook that then reports nonsense.
|
|
162
|
+
files = ["src", "tests", "tools"]
|
|
142
163
|
python_version = "3.14"
|
|
164
|
+
# A cast that is no longer needed is a leftover from a type that has since
|
|
165
|
+
# improved, and it silently keeps the old shape. Global rather than per-module
|
|
166
|
+
# because mypy offers it nowhere else.
|
|
167
|
+
warn_redundant_casts = true
|
|
168
|
+
|
|
169
|
+
# The shipped package is held to a stricter standard than the tests that drive
|
|
170
|
+
# it. Every flag here was already clean when it was added, so this locks in
|
|
171
|
+
# where the code got to rather than announcing a cleanup nobody is doing - a
|
|
172
|
+
# rule that fails the day it lands teaches people to skip the hook.
|
|
173
|
+
#
|
|
174
|
+
# `disallow_untyped_defs` is the one that matters, and the reason a bare `mypy`
|
|
175
|
+
# is not enough: without it the *bodies* of unannotated functions are never
|
|
176
|
+
# checked, so an unannotated function is a hole rather than a looser check.
|
|
177
|
+
# Deliberately not applied to tests, where 900-odd `def test_x():` signatures
|
|
178
|
+
# would be noise for no safety - the code under test is what has to be right.
|
|
179
|
+
[[tool.mypy.overrides]]
|
|
180
|
+
module = "repwise.*"
|
|
181
|
+
disallow_untyped_defs = true
|
|
182
|
+
disallow_incomplete_defs = true
|
|
183
|
+
disallow_untyped_calls = true
|
|
184
|
+
disallow_untyped_decorators = true
|
|
185
|
+
disallow_subclassing_any = true
|
|
186
|
+
# Comparing two types that can never be equal is always a bug, and the shapes
|
|
187
|
+
# this maps between - Garmin's strings against our enums and ints - are exactly
|
|
188
|
+
# where that happens silently.
|
|
189
|
+
strict_equality = true
|
|
190
|
+
extra_checks = true
|
|
191
|
+
warn_unreachable = true
|
|
192
|
+
# An ignore that stopped being needed is an ignore that now hides something.
|
|
193
|
+
warn_unused_ignores = true
|
|
194
|
+
# A bare `dict` or `list` is Any wearing a container, and this reads YAML and
|
|
195
|
+
# Garmin's JSON into both. Spelling the shape out is what stops Any spreading
|
|
196
|
+
# from the two files that have a reason for it into the ones that do not.
|
|
197
|
+
disallow_any_generics = true
|
|
198
|
+
# The value garminconnect hands back is Any, so without this a function can
|
|
199
|
+
# promise `dict[str, Any]` and return whatever came off the wire unchecked.
|
|
200
|
+
# `garmin/client.py` casts at the boundary instead, which is what an adapter is.
|
|
201
|
+
warn_return_any = true
|
|
202
|
+
# A name is imported from where it is defined, not from the last module that
|
|
203
|
+
# happened to import it - `ActivityNotFound` lives in `errors.py`, whoever else
|
|
204
|
+
# passes it through.
|
|
205
|
+
no_implicit_reexport = true
|
|
143
206
|
|
|
144
207
|
# garminconnect ships no type information. garmin/client.py is the only module
|
|
145
208
|
# that imports it, which is what keeping the adapter in one place buys.
|
|
@@ -150,3 +213,24 @@ ignore_missing_imports = true
|
|
|
150
213
|
[tool.pytest.ini_options]
|
|
151
214
|
pythonpath = ["src"]
|
|
152
215
|
testpaths = ["tests"]
|
|
216
|
+
|
|
217
|
+
# Coverage is a decay alarm, not a quality bar. It answers "was this line
|
|
218
|
+
# executed", never "would a test notice a wrong answer" - the audit that added
|
|
219
|
+
# these floors found three of its four bugs in covered code, one of them in a
|
|
220
|
+
# module sitting at 100%. So the floors are set at a decent distance below
|
|
221
|
+
# where the suite actually is, and are meant to fire when whole modules arrive
|
|
222
|
+
# untested rather than to be climbed towards. Test strength is a separate
|
|
223
|
+
# question, and mutation testing is what answers it.
|
|
224
|
+
[tool.coverage.run]
|
|
225
|
+
source = ["src"]
|
|
226
|
+
omit = [
|
|
227
|
+
# Three lines that call main() and exit. Reaching them means running the
|
|
228
|
+
# process, which is what tests/test_main.py does through main() itself.
|
|
229
|
+
"src/repwise/__main__.py",
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
[tool.coverage.report]
|
|
233
|
+
#: The floor for the tree as a whole. Read by `tools/check_coverage.py` as well
|
|
234
|
+
#: as by `coverage report`, so there is one number rather than two that can
|
|
235
|
+
#: disagree.
|
|
236
|
+
fail_under = 90
|
|
@@ -10,7 +10,7 @@ from ..domain.models import Config, GarminSettings
|
|
|
10
10
|
from ..errors import ExitCode, GarminError
|
|
11
11
|
from ..garmin import catalog
|
|
12
12
|
from ..garmin.client import STRENGTH, GarminSession
|
|
13
|
-
from ..garmin.payloads import activity_sport
|
|
13
|
+
from ..garmin.payloads import activity_sport, workout_name
|
|
14
14
|
|
|
15
15
|
logger = logging.getLogger(__name__)
|
|
16
16
|
|
|
@@ -54,7 +54,7 @@ def run_fetch(
|
|
|
54
54
|
continue
|
|
55
55
|
|
|
56
56
|
path = dumps.write(payload, config.garmin.dump_dir, dumps.WORKOUT, workout_id)
|
|
57
|
-
logger.info(f"Saved {payload
|
|
57
|
+
logger.info(f"Saved {workout_name(payload) or '(unnamed)'} -> {path}")
|
|
58
58
|
|
|
59
59
|
return ExitCode.NOTHING_USABLE if failed else ExitCode.OK
|
|
60
60
|
|
|
@@ -7,6 +7,7 @@ from typing import Any
|
|
|
7
7
|
|
|
8
8
|
from ..errors import ActivityNotFound, ExitCode, UsageError
|
|
9
9
|
from ..garmin.client import STRENGTH, GarminSession
|
|
10
|
+
from ..garmin.payloads import workout_name
|
|
10
11
|
from ..importer import describe_workout, render_config
|
|
11
12
|
from ..yamlio import write
|
|
12
13
|
|
|
@@ -33,9 +34,9 @@ def select(session: GarminSession, options: ImportOptions) -> list[dict[str, Any
|
|
|
33
34
|
return wanted
|
|
34
35
|
if options.name:
|
|
35
36
|
needle = options.name.lower()
|
|
36
|
-
wanted = [w for w in workouts if needle in (w
|
|
37
|
+
wanted = [w for w in workouts if needle in (workout_name(w) or "").lower()]
|
|
37
38
|
if not wanted:
|
|
38
|
-
names = ", ".join(repr(w
|
|
39
|
+
names = ", ".join(repr(workout_name(w)) for w in workouts)
|
|
39
40
|
raise ActivityNotFound(
|
|
40
41
|
f"No strength workout matching {options.name!r}. Found: {names}"
|
|
41
42
|
)
|
|
@@ -5,12 +5,13 @@ import logging
|
|
|
5
5
|
from ..domain.models import Config
|
|
6
6
|
from ..errors import ExitCode
|
|
7
7
|
from ..garmin.client import STRENGTH, GarminSession
|
|
8
|
+
from ..garmin.payloads import workout_name
|
|
8
9
|
|
|
9
10
|
logger = logging.getLogger(__name__)
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
def run_list(
|
|
13
|
-
session: GarminSession, config: Config, every_sport: bool = False
|
|
14
|
+
session: GarminSession, config: Config, *, every_sport: bool = False
|
|
14
15
|
) -> ExitCode:
|
|
15
16
|
workouts = session.list_workouts(sport_type=None if every_sport else STRENGTH)
|
|
16
17
|
|
|
@@ -24,7 +25,7 @@ def run_list(
|
|
|
24
25
|
workout_id = str(entry.get("workoutId"))
|
|
25
26
|
updated = (entry.get("updateDate") or "")[:10]
|
|
26
27
|
mark = "*" if workout_id in known else " "
|
|
27
|
-
name = entry
|
|
28
|
+
name = workout_name(entry) or "(unnamed)"
|
|
28
29
|
if every_sport:
|
|
29
30
|
kind = (entry.get("sportType") or {}).get("sportTypeKey", "?")
|
|
30
31
|
name = f"{name} [{kind}]"
|
|
@@ -252,6 +252,10 @@ def rows(plan: Plan) -> list[Row]:
|
|
|
252
252
|
An exercise the config no longer names has no place among the ones it
|
|
253
253
|
does, so a removal follows them, and the rest between exercises - which
|
|
254
254
|
belongs to the whole workout rather than to any one of them - comes last.
|
|
255
|
+
|
|
256
|
+
The workout's own name is not among them. Every row here is something the
|
|
257
|
+
workout contains; the name is what the workout *is*, so it is announced
|
|
258
|
+
with the heading instead - see `report_plan`.
|
|
255
259
|
"""
|
|
256
260
|
described = {spec.name: spec for spec in plan.workout.exercises}
|
|
257
261
|
places = {name: place for place, name in enumerate(described, 1)}
|
|
@@ -303,6 +307,17 @@ def joins(row: Row) -> str:
|
|
|
303
307
|
|
|
304
308
|
|
|
305
309
|
def report_plan(plan: Plan) -> None:
|
|
310
|
+
# Under the heading the caller has just printed, which is where the workout
|
|
311
|
+
# is being named anyway. It is a fact about the workout rather than about
|
|
312
|
+
# anything in it, and a table of exercises is no place to say it.
|
|
313
|
+
if plan.name:
|
|
314
|
+
logger.info(f"Renaming: {plan.name.was} -> {plan.name.new}")
|
|
315
|
+
|
|
316
|
+
# The blank between the heading and the table belongs here rather than to
|
|
317
|
+
# the caller, so that a rename joins the heading above it instead of being
|
|
318
|
+
# stranded on the far side of the gap.
|
|
319
|
+
logger.info("")
|
|
320
|
+
|
|
306
321
|
for text in render(rows(plan)):
|
|
307
322
|
logger.info(text)
|
|
308
323
|
|
|
@@ -29,6 +29,7 @@ from ..planner import (
|
|
|
29
29
|
History,
|
|
30
30
|
Performed,
|
|
31
31
|
Plan,
|
|
32
|
+
decided_markers,
|
|
32
33
|
decided_targets,
|
|
33
34
|
executed_targets,
|
|
34
35
|
find_workout,
|
|
@@ -316,6 +317,7 @@ def sync_other_workouts(
|
|
|
316
317
|
config: Config,
|
|
317
318
|
source: Workout,
|
|
318
319
|
targets: dict[str, Target],
|
|
320
|
+
markers: dict[str, str],
|
|
319
321
|
) -> list[Plan]:
|
|
320
322
|
"""Propagate decided targets into every other workout that shares them.
|
|
321
323
|
|
|
@@ -324,6 +326,10 @@ def sync_other_workouts(
|
|
|
324
326
|
name, and the weight one of them earned is not a weight the other can be
|
|
325
327
|
asked for: 20 kg of gym machine says nothing about a pair of dumbbells.
|
|
326
328
|
Such an entry is left where it is, to be moved by its own sessions.
|
|
329
|
+
|
|
330
|
+
`markers` is carried on the same terms and gated the same way. A miss is
|
|
331
|
+
about the exercise as it was actually loaded, so a miss on the gym cable
|
|
332
|
+
says nothing about the same movement done on a band at home.
|
|
327
333
|
"""
|
|
328
334
|
loads = {normalise(spec.garmin_name): spec.load for spec in source.exercises}
|
|
329
335
|
|
|
@@ -333,21 +339,27 @@ def sync_other_workouts(
|
|
|
333
339
|
continue
|
|
334
340
|
|
|
335
341
|
carried: dict[str, Target] = {}
|
|
342
|
+
held: dict[str, str] = {}
|
|
336
343
|
for spec in other.exercises:
|
|
337
344
|
name = normalise(spec.garmin_name)
|
|
338
|
-
if
|
|
345
|
+
if spec.load != loads.get(name):
|
|
346
|
+
continue
|
|
347
|
+
if name in targets:
|
|
339
348
|
carried[name] = targets[name]
|
|
340
|
-
|
|
349
|
+
if name in markers:
|
|
350
|
+
held[name] = markers[name]
|
|
351
|
+
# A hold moves no target, so a workout worth visiting for its notes
|
|
352
|
+
# alone is the ordinary case rather than an edge one.
|
|
353
|
+
if not carried and not held:
|
|
341
354
|
continue
|
|
342
355
|
|
|
343
356
|
payload = payloads[garmin_id(other)]
|
|
344
|
-
plan = plan_sync(other, payload, carried, source.key)
|
|
357
|
+
plan = plan_sync(other, payload, carried, held, source.key)
|
|
345
358
|
if not plan.writable:
|
|
346
359
|
continue
|
|
347
360
|
|
|
348
361
|
logger.info("")
|
|
349
362
|
logger.info(f"Also in {other.key} (workout {other.garmin_workout_id}):")
|
|
350
|
-
logger.info("")
|
|
351
363
|
report_plan(plan)
|
|
352
364
|
plans.append(plan)
|
|
353
365
|
|
|
@@ -398,18 +410,16 @@ def shape_untrained(
|
|
|
398
410
|
logger.info(
|
|
399
411
|
f"Shaping: {workout.key} -> workout {workout.garmin_workout_id}"
|
|
400
412
|
)
|
|
401
|
-
logger.info("")
|
|
402
413
|
report_plan(plan)
|
|
403
414
|
plans.append(plan)
|
|
404
415
|
|
|
405
416
|
return plans
|
|
406
417
|
|
|
407
418
|
|
|
408
|
-
def advance_trained(
|
|
419
|
+
def advance_trained(
|
|
409
420
|
session: GarminSession,
|
|
410
421
|
payloads: Payloads,
|
|
411
422
|
config: Config,
|
|
412
|
-
options: UpdateOptions,
|
|
413
423
|
sessions: list[Trained],
|
|
414
424
|
*,
|
|
415
425
|
trusted: Container[str] | None = None,
|
|
@@ -430,7 +440,6 @@ def advance_trained( # noqa: PLR0913 - each argument is one independent input
|
|
|
430
440
|
logger.info("")
|
|
431
441
|
logger.info(f"Activity: {activity.get('activityName') or ''} ({activity_id})")
|
|
432
442
|
logger.info(f"Updating: {workout.key} -> workout {workout.garmin_workout_id}")
|
|
433
|
-
logger.info("")
|
|
434
443
|
|
|
435
444
|
sets_payload = session.exercise_sets(activity_id)
|
|
436
445
|
payload = payloads[garmin_id(workout)]
|
|
@@ -458,10 +467,16 @@ def advance_trained( # noqa: PLR0913 - each argument is one independent input
|
|
|
458
467
|
report_plan(plan)
|
|
459
468
|
plans.append(plan)
|
|
460
469
|
|
|
461
|
-
# Anything that moved must move everywhere that exercise appears
|
|
470
|
+
# Anything that moved must move everywhere that exercise appears, and
|
|
471
|
+
# so must a hold - which moves nothing, so it has to be asked for
|
|
472
|
+
# separately or a stalled exercise would carry its marker in one
|
|
473
|
+
# workout and not in the others.
|
|
462
474
|
targets = decided_targets(plan)
|
|
463
|
-
|
|
464
|
-
|
|
475
|
+
markers = decided_markers(plan)
|
|
476
|
+
if targets or markers:
|
|
477
|
+
plans.extend(
|
|
478
|
+
sync_other_workouts(payloads, config, workout, targets, markers)
|
|
479
|
+
)
|
|
465
480
|
|
|
466
481
|
return plans, usable
|
|
467
482
|
|
|
@@ -536,7 +551,7 @@ def run_update(
|
|
|
536
551
|
)
|
|
537
552
|
|
|
538
553
|
trained, usable = advance_trained(
|
|
539
|
-
session, payloads, config,
|
|
554
|
+
session, payloads, config, sessions, trusted=trusted
|
|
540
555
|
)
|
|
541
556
|
plans.extend(trained)
|
|
542
557
|
|
|
@@ -559,6 +574,7 @@ def run_update(
|
|
|
559
574
|
unskipped = counted(plans, lambda plan: (c.spec.garmin_name for c in plan.skips))
|
|
560
575
|
# One per workout however many gap steps it touched: the config says it once.
|
|
561
576
|
regaps = len({counted_as(plan.workout) for plan in plans if plan.gaps})
|
|
577
|
+
renames = len({counted_as(plan.workout) for plan in plans if plan.name})
|
|
562
578
|
shaped = counted(plans, lambda plan: ((c.kind, c.name) for c in plan.reshaped))
|
|
563
579
|
structure = (
|
|
564
580
|
f", {shaped} exercise(s) would be added, removed or moved" if shaped else ""
|
|
@@ -569,6 +585,7 @@ def run_update(
|
|
|
569
585
|
if regaps
|
|
570
586
|
else ""
|
|
571
587
|
)
|
|
588
|
+
renamed = f", {renames} workout(s) would be renamed" if renames else ""
|
|
572
589
|
notes = f", {noted} note(s) would be refreshed" if noted else ""
|
|
573
590
|
rests = f", {rested} rest time(s) would change" if rested else ""
|
|
574
591
|
skips = (
|
|
@@ -581,11 +598,15 @@ def run_update(
|
|
|
581
598
|
logger.info("")
|
|
582
599
|
logger.info(
|
|
583
600
|
f"Dry run: {updated} step(s) would change"
|
|
584
|
-
f"{structure}{counts}{rests}{skips}{between}{notes}.
|
|
601
|
+
f"{structure}{counts}{rests}{skips}{between}{renamed}{notes}."
|
|
602
|
+
f" Re-run with --apply."
|
|
585
603
|
)
|
|
586
604
|
return ExitCode.OK
|
|
587
605
|
|
|
588
|
-
|
|
606
|
+
moved_anything = (
|
|
607
|
+
updated or noted or rested or recounted or unskipped or regaps or renames
|
|
608
|
+
)
|
|
609
|
+
if not (moved_anything or shaped):
|
|
589
610
|
logger.info("")
|
|
590
611
|
logger.info("Nothing to write.")
|
|
591
612
|
return ExitCode.OK
|
|
@@ -600,6 +621,7 @@ def run_update(
|
|
|
600
621
|
+ (f" Set {rested} rest time(s)." if rested else "")
|
|
601
622
|
+ (f" Restored the last rest on {unskipped} step(s)." if unskipped else "")
|
|
602
623
|
+ (f" Set the rest between exercises in {regaps} workout(s)." if regaps else "")
|
|
624
|
+
+ (f" Renamed {renames} workout(s)." if renames else "")
|
|
603
625
|
+ (f" Refreshed {noted} note(s)." if noted else "")
|
|
604
626
|
)
|
|
605
627
|
|
|
@@ -24,16 +24,18 @@ Sets, rests and the exercise list are left to the command that owns them.
|
|
|
24
24
|
Pure: takes a config and payloads, returns findings.
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
|
-
from dataclasses import dataclass
|
|
27
|
+
from dataclasses import dataclass, replace
|
|
28
|
+
from typing import Any
|
|
28
29
|
|
|
29
30
|
from .domain.effort import (
|
|
30
|
-
|
|
31
|
+
chosen_step,
|
|
31
32
|
effective_load,
|
|
32
33
|
fitting_rep_highs,
|
|
33
34
|
reset_drop,
|
|
35
|
+
within_tolerance,
|
|
34
36
|
)
|
|
35
37
|
from .domain.matching import ExerciseIndex
|
|
36
|
-
from .domain.models import ExerciseSpec, Workout
|
|
38
|
+
from .domain.models import READABLE_NOTE, ExerciseSpec, Workout
|
|
37
39
|
from .garmin.catalog import ExerciseCatalog
|
|
38
40
|
from .garmin.payloads import (
|
|
39
41
|
ExerciseBlock,
|
|
@@ -140,13 +142,35 @@ def check_catalog(workout: Workout, catalog: ExerciseCatalog) -> list[Finding]:
|
|
|
140
142
|
return findings
|
|
141
143
|
|
|
142
144
|
|
|
143
|
-
def check_workout(workout: Workout, payload: dict) -> list[Finding]:
|
|
145
|
+
def check_workout(workout: Workout, payload: dict[str, Any]) -> list[Finding]:
|
|
144
146
|
"""Look for exercises the config cannot name properly."""
|
|
145
147
|
findings: list[Finding] = []
|
|
146
148
|
|
|
147
149
|
def note(detail: str, severity: str = "warning") -> None:
|
|
148
150
|
findings.append(Finding(workout.key, detail, severity))
|
|
149
151
|
|
|
152
|
+
# `update` writes the config key to Garmin, so it is the name your next
|
|
153
|
+
# session will be logged under - and `activity_prefixes` is what finds it
|
|
154
|
+
# again. A key none of them claims means the sessions you are about to
|
|
155
|
+
# perform match nothing, which is silent until a target stops moving.
|
|
156
|
+
if workout.activity_prefixes and not workout.claims(workout.key):
|
|
157
|
+
listed = ", ".join(repr(prefix) for prefix in workout.activity_prefixes)
|
|
158
|
+
note(
|
|
159
|
+
f"no activity_prefixes entry matches the workout name {workout.key!r}, "
|
|
160
|
+
f"so sessions logged under it would be found by none of {listed}. "
|
|
161
|
+
f"Add {workout.key.lower()!r}, keeping the old ones so past sessions "
|
|
162
|
+
f"still match",
|
|
163
|
+
"error",
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
for spec in workout.exercises:
|
|
167
|
+
if len(spec.note) > READABLE_NOTE:
|
|
168
|
+
note(
|
|
169
|
+
f"{spec.name}: its note comes to {len(spec.note)} characters, past "
|
|
170
|
+
f"the {READABLE_NOTE} a watch shows, so the end of it is simply "
|
|
171
|
+
f"never read"
|
|
172
|
+
)
|
|
173
|
+
|
|
150
174
|
index: ExerciseIndex[ExerciseBlock] = ExerciseIndex()
|
|
151
175
|
for entry in iter_exercise_blocks(payload):
|
|
152
176
|
index.add(
|
|
@@ -217,7 +241,7 @@ def _suggestion(spec: ExerciseSpec, weight: float, bodyweight: float) -> str:
|
|
|
217
241
|
|
|
218
242
|
|
|
219
243
|
def check_programming(
|
|
220
|
-
workout: Workout, payload: dict, bodyweight: float | None = None
|
|
244
|
+
workout: Workout, payload: dict[str, Any], bodyweight: float | None = None
|
|
221
245
|
) -> list[Finding]:
|
|
222
246
|
"""Look for rep ranges that do not fit what their weight step is worth.
|
|
223
247
|
|
|
@@ -261,11 +285,21 @@ def check_programming(
|
|
|
261
285
|
continue
|
|
262
286
|
|
|
263
287
|
carried = bodyweight or 0.0
|
|
264
|
-
|
|
265
|
-
|
|
288
|
+
# Judge the step rule 3 will actually take. Where the equipment offers
|
|
289
|
+
# a choice of increments, that is the one `chosen_step` picks for this
|
|
290
|
+
# weight, not the smallest the load type happens to name - reporting
|
|
291
|
+
# the 1.25 kg increment as a wall on a 60 kg stack would be a finding
|
|
292
|
+
# about a jump the tool was never going to prescribe.
|
|
293
|
+
stepped = replace(
|
|
294
|
+
spec,
|
|
295
|
+
weight_step=chosen_step(spec, target.weight, carried),
|
|
296
|
+
tiers=(),
|
|
297
|
+
)
|
|
298
|
+
shift = reset_drop(stepped, target.weight, carried)
|
|
299
|
+
if shift is None or within_tolerance(shift):
|
|
266
300
|
continue
|
|
267
301
|
|
|
268
|
-
load = effective_load(
|
|
302
|
+
load = effective_load(stepped, target.weight, carried)
|
|
269
303
|
# The sign is the whole diagnosis, so it decides every word that
|
|
270
304
|
# follows: which way the range is wrong, which way to move it, and
|
|
271
305
|
# what it costs you to leave it alone.
|
|
@@ -274,13 +308,13 @@ def check_programming(
|
|
|
274
308
|
settle = "accept the sawtooth"
|
|
275
309
|
else:
|
|
276
310
|
gives, costs = "gives back less", f"{-shift:.0%} jump in effort"
|
|
277
|
-
settle = "
|
|
278
|
-
fix = _suggestion(
|
|
311
|
+
settle = "take a smaller step"
|
|
312
|
+
fix = _suggestion(stepped, target.weight, carried)
|
|
279
313
|
findings.append(
|
|
280
314
|
Finding(
|
|
281
315
|
workout.key,
|
|
282
|
-
f"{spec.name}: +{
|
|
283
|
-
f"{
|
|
316
|
+
f"{spec.name}: +{stepped.weight_step:g} kg on {load:g} kg is "
|
|
317
|
+
f"{stepped.weight_step / load:.1%}, but resetting "
|
|
284
318
|
f"{spec.rep_high}->{spec.rep_low} reps {gives}, so the weight "
|
|
285
319
|
f"increase is a {costs} ({fix}, or {settle})",
|
|
286
320
|
)
|
|
@@ -127,7 +127,7 @@ HANDLERS: dict[str, Handler] = {
|
|
|
127
127
|
def main(argv: list[str] | None = None) -> int:
|
|
128
128
|
parser = build_parser()
|
|
129
129
|
args = parser.parse_args(argv)
|
|
130
|
-
configure(args.verbose)
|
|
130
|
+
configure(verbose=args.verbose)
|
|
131
131
|
|
|
132
132
|
# Answered here rather than through HANDLERS below, because the config is
|
|
133
133
|
# loaded to reach those and this command must run without one: the way to
|
|
@@ -148,6 +148,20 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
148
148
|
if exc.advice:
|
|
149
149
|
logger.error(exc.advice)
|
|
150
150
|
return exc.exit_code
|
|
151
|
+
except KeyboardInterrupt:
|
|
152
|
+
# Not a bug, so not a traceback. A run is stopped from the keyboard
|
|
153
|
+
# most often while it waits on Garmin, and a stack trace through the
|
|
154
|
+
# HTTP library says nothing about what happened or what to do next.
|
|
155
|
+
#
|
|
156
|
+
# Re-running is the answer, and it is a safe one: `update` recomputes
|
|
157
|
+
# every plan from what Garmin holds now, so the workouts that were
|
|
158
|
+
# already written are simply found up to date.
|
|
159
|
+
logger.warning("")
|
|
160
|
+
logger.warning(
|
|
161
|
+
"Stopped. Anything already written to Garmin is still there, and "
|
|
162
|
+
"re-running picks up from it."
|
|
163
|
+
)
|
|
164
|
+
return ExitCode.INTERRUPTED
|
|
151
165
|
|
|
152
166
|
|
|
153
167
|
if __name__ == "__main__":
|
|
@@ -10,7 +10,6 @@ reads them and this parser to write its scripts.
|
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
import argparse
|
|
13
|
-
from typing import Any
|
|
14
13
|
|
|
15
14
|
from .. import __version__
|
|
16
15
|
|
|
@@ -28,7 +27,7 @@ SHELLS = ("bash", "zsh")
|
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
def add_verbose(
|
|
31
|
-
parser: argparse.ArgumentParser, default:
|
|
30
|
+
parser: argparse.ArgumentParser, *, default: bool | str = argparse.SUPPRESS
|
|
32
31
|
) -> None:
|
|
33
32
|
"""Accept -v on this parser, so it reads either side of the command.
|
|
34
33
|
|