repwise 2.2.0__tar.gz → 3.0.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-2.2.0/src/repwise.egg-info → repwise-3.0.0}/PKG-INFO +1 -1
- {repwise-2.2.0 → repwise-3.0.0}/pyproject.toml +2 -2
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/__init__.py +1 -1
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/update.py +18 -3
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/config.py +183 -54
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/domain/models.py +13 -5
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/importer.py +16 -12
- {repwise-2.2.0 → repwise-3.0.0/src/repwise.egg-info}/PKG-INFO +1 -1
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_config.py +164 -25
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_importer.py +9 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_update.py +29 -0
- {repwise-2.2.0 → repwise-3.0.0}/LICENSE +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/README.md +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/setup.cfg +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/__main__.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/__init__.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/checking.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/fetch.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/importing.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/listing.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/logout.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/app/report.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/checker.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/cli/__init__.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/cli/completion.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/cli/parser.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/domain/__init__.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/domain/effort.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/domain/matching.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/domain/progression.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/dumps.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/errors.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/garmin/__init__.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/garmin/catalog.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/garmin/client.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/garmin/payloads.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/log.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/planner.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise/yamlio.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise.egg-info/SOURCES.txt +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise.egg-info/requires.txt +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_catalog.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_checker.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_checking.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_cli.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_client.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_completion.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_dumps.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_effort.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_fetch.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_log.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_logout.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_main.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_matching.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_models.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_payloads.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_planner.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_progression.py +0 -0
- {repwise-2.2.0 → repwise-3.0.0}/tests/test_report.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "repwise"
|
|
7
|
-
version = "
|
|
7
|
+
version = "3.0.0"
|
|
8
8
|
description = "Advance Garmin strength workout targets using double progression"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -70,7 +70,7 @@ dev = [
|
|
|
70
70
|
"mypy==2.3.1",
|
|
71
71
|
"pre-commit==4.6.2",
|
|
72
72
|
"pytest==9.1.1",
|
|
73
|
-
"ruff==0.16.
|
|
73
|
+
"ruff==0.16.5",
|
|
74
74
|
"types-PyYAML==6.0.12.20260815",
|
|
75
75
|
]
|
|
76
76
|
|
|
@@ -317,16 +317,31 @@ def sync_other_workouts(
|
|
|
317
317
|
source: Workout,
|
|
318
318
|
targets: dict[str, Target],
|
|
319
319
|
) -> list[Plan]:
|
|
320
|
-
"""Propagate decided targets into every other workout that shares them.
|
|
320
|
+
"""Propagate decided targets into every other workout that shares them.
|
|
321
|
+
|
|
322
|
+
Shared means the same exercise on the same equipment. A movement
|
|
323
|
+
programmed on another load is a different exercise wearing the same Garmin
|
|
324
|
+
name, and the weight one of them earned is not a weight the other can be
|
|
325
|
+
asked for: 20 kg of gym machine says nothing about a pair of dumbbells.
|
|
326
|
+
Such an entry is left where it is, to be moved by its own sessions.
|
|
327
|
+
"""
|
|
328
|
+
loads = {normalise(spec.garmin_name): spec.load for spec in source.exercises}
|
|
329
|
+
|
|
321
330
|
plans: list[Plan] = []
|
|
322
331
|
for other in config:
|
|
323
332
|
if other.key == source.key or other.garmin_workout_id is None:
|
|
324
333
|
continue
|
|
325
|
-
|
|
334
|
+
|
|
335
|
+
carried: dict[str, Target] = {}
|
|
336
|
+
for spec in other.exercises:
|
|
337
|
+
name = normalise(spec.garmin_name)
|
|
338
|
+
if name in targets and spec.load == loads.get(name):
|
|
339
|
+
carried[name] = targets[name]
|
|
340
|
+
if not carried:
|
|
326
341
|
continue
|
|
327
342
|
|
|
328
343
|
payload = payloads[garmin_id(other)]
|
|
329
|
-
plan = plan_sync(other, payload,
|
|
344
|
+
plan = plan_sync(other, payload, carried, source.key)
|
|
330
345
|
if not plan.writable:
|
|
331
346
|
continue
|
|
332
347
|
|
|
@@ -10,7 +10,7 @@ for rather than computed from this module's location - see `search_path()`.
|
|
|
10
10
|
|
|
11
11
|
import logging
|
|
12
12
|
import os
|
|
13
|
-
from dataclasses import dataclass
|
|
13
|
+
from dataclasses import dataclass
|
|
14
14
|
from typing import Any
|
|
15
15
|
|
|
16
16
|
from .domain.models import BODYWEIGHT, Config, ExerciseSpec, GarminSettings, Workout
|
|
@@ -49,22 +49,67 @@ _REQUIRED = ("name", "garmin_name", "rep_low", "rep_high", "sets", "load")
|
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
@dataclass(frozen=True)
|
|
52
|
-
class
|
|
53
|
-
"""
|
|
52
|
+
class LoadType:
|
|
53
|
+
"""One named way of loading: how it steps, and how light and heavy it goes.
|
|
54
|
+
|
|
55
|
+
Named by the user rather than drawn from a list of equipment types, because
|
|
56
|
+
one word does not tell one rack from another: the dumbbells at home start
|
|
57
|
+
at 1 kg and stop at 10, the pair in the gym start at 2 and run to 40. Both
|
|
58
|
+
are dumbbells, and a deload can only be told what exists to prescribe if
|
|
59
|
+
they are declared apart. So each rack is named under the top-level `load`,
|
|
60
|
+
and an exercise's own `load` says which one it is performed on.
|
|
54
61
|
|
|
55
62
|
All three are properties of the equipment rather than of any one exercise -
|
|
56
|
-
a
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
a rack goes up in ones, starts at one and ends at whatever the heaviest
|
|
64
|
+
pair is - so they are declared once and only overridden where an exercise
|
|
65
|
+
really differs.
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
#: kg added when a rep range is topped out. Required: a load type that
|
|
69
|
+
#: cannot say how it steps cannot progress anything.
|
|
70
|
+
step: float
|
|
71
|
+
#: The lightest this equipment goes: the smallest bar on the rack, the
|
|
72
|
+
#: lightest pair, the top plate of the stack. Required, because every rack
|
|
73
|
+
#: has a bottom, and a deload that does not know it prescribes a weight you
|
|
74
|
+
#: have no way to make up.
|
|
75
|
+
minimum: float
|
|
76
|
+
#: The heaviest it goes, or None where it outlasts you - a gym's stack, a
|
|
77
|
+
#: bar with more plates left in the rack. Only equipment you own runs out.
|
|
78
|
+
maximum: float | None = None
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
#: The three maps the top-level `load` replaced, each keyed by load type.
|
|
82
|
+
_MOVED = ("weight_steps", "min_weights", "max_weights")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _reject_moved_settings(settings: dict, path: str) -> None:
|
|
86
|
+
"""Say what became of the three maps that the top-level `load` replaced.
|
|
87
|
+
|
|
88
|
+
They were keyed by a fixed idea of equipment - one `dumbbell` entry for
|
|
89
|
+
every dumbbell you own - which is the thing named load types exist to
|
|
90
|
+
undo.
|
|
91
|
+
Loading such a file halfway would quietly drop its floors, ceilings and
|
|
92
|
+
steps, so it is refused outright with the shape to write instead.
|
|
59
93
|
"""
|
|
94
|
+
found = [key for key in _MOVED if settings.get(key) is not None]
|
|
95
|
+
if not found:
|
|
96
|
+
return
|
|
60
97
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
98
|
+
named = ", ".join(f"settings.{key}" for key in found)
|
|
99
|
+
raise ConfigError(
|
|
100
|
+
f"{path}: {named} {'has' if len(found) == 1 else 'have'} been replaced "
|
|
101
|
+
f"by a top-level 'load' key. Each named load type states its own step "
|
|
102
|
+
f"and how light and heavy it goes:\n"
|
|
103
|
+
f" load:\n"
|
|
104
|
+
f" barbell:\n"
|
|
105
|
+
f" min: 12.0\n"
|
|
106
|
+
f" step: 2.5\n"
|
|
107
|
+
f" home_dumbbell:\n"
|
|
108
|
+
f" min: 1.0\n"
|
|
109
|
+
f" max: 10.0\n"
|
|
110
|
+
f" step: 1.0\n"
|
|
111
|
+
f"An exercise's 'load' then names one of them."
|
|
112
|
+
)
|
|
68
113
|
|
|
69
114
|
|
|
70
115
|
def _xdg_config_home() -> str:
|
|
@@ -292,8 +337,84 @@ class Problems:
|
|
|
292
337
|
raise ConfigError(f"{len(self.found)} problems:\n{listed}")
|
|
293
338
|
|
|
294
339
|
|
|
340
|
+
def _load_types(declared: Any, path: str, problems: Problems) -> dict[str, LoadType]:
|
|
341
|
+
"""The named ways of loading an exercise, from the top-level `load`.
|
|
342
|
+
|
|
343
|
+
Every name here is the user's own - `barbell`, `gym_dumbbell`,
|
|
344
|
+
`home_dumbbell`, whatever tells one rack from another. Only `bodyweight` is
|
|
345
|
+
spoken for: an exercise loaded that way carries no equipment, so it draws
|
|
346
|
+
on nothing declared here.
|
|
347
|
+
|
|
348
|
+
Names are lower-cased on the way in, and an exercise's `load` is lower-cased
|
|
349
|
+
to match, so `Gym_Dumbbell` and `gym_dumbbell` are one rack however either
|
|
350
|
+
end happens to be typed. Which is also why two names differing only in case
|
|
351
|
+
are refused: they would otherwise be one entry silently overwriting the
|
|
352
|
+
other, and only one of the two racks would survive.
|
|
353
|
+
|
|
354
|
+
A broken entry is recorded and then kept, in the shape it can be, so that
|
|
355
|
+
the exercises using it are still checked rather than each being reported a
|
|
356
|
+
second time as naming a load type that does not exist.
|
|
357
|
+
"""
|
|
358
|
+
if declared is None:
|
|
359
|
+
return {}
|
|
360
|
+
if not isinstance(declared, dict):
|
|
361
|
+
problems.add(f"{path}: 'load' should be a mapping of name to min/max/step")
|
|
362
|
+
return {}
|
|
363
|
+
|
|
364
|
+
types: dict[str, LoadType] = {}
|
|
365
|
+
#: Lower-cased name -> the name as written, for a message that can be
|
|
366
|
+
#: found in the file.
|
|
367
|
+
written: dict[str, str] = {}
|
|
368
|
+
for name, entry in declared.items():
|
|
369
|
+
where = f"{path}: load.{name}"
|
|
370
|
+
key = str(name).lower()
|
|
371
|
+
if key == BODYWEIGHT:
|
|
372
|
+
problems.add(
|
|
373
|
+
f"{where} is a reserved name: an exercise loaded {BODYWEIGHT!r} "
|
|
374
|
+
f"has no equipment, so it draws on no load type of yours"
|
|
375
|
+
)
|
|
376
|
+
continue
|
|
377
|
+
if key in written:
|
|
378
|
+
problems.add(
|
|
379
|
+
f"{where} and load.{written[key]} are one name: load types are "
|
|
380
|
+
f"matched in lower case, so only one of the two would survive"
|
|
381
|
+
)
|
|
382
|
+
continue
|
|
383
|
+
written[key] = str(name)
|
|
384
|
+
if not isinstance(entry, dict):
|
|
385
|
+
problems.add(f"{where} should state min, step and optionally max")
|
|
386
|
+
continue
|
|
387
|
+
|
|
388
|
+
missing = [field for field in ("min", "step") if entry.get(field) is None]
|
|
389
|
+
if missing:
|
|
390
|
+
problems.add(f"{where} is missing {', '.join(missing)}")
|
|
391
|
+
|
|
392
|
+
minimum = float(entry.get("min") or 0.0)
|
|
393
|
+
if minimum < 0:
|
|
394
|
+
problems.add(f"{where} has a negative min")
|
|
395
|
+
minimum = 0.0
|
|
396
|
+
|
|
397
|
+
step = float(entry.get("step") or 0.0)
|
|
398
|
+
if step < 0:
|
|
399
|
+
problems.add(f"{where} has a negative step")
|
|
400
|
+
step = 0.0
|
|
401
|
+
|
|
402
|
+
declared_maximum = entry.get("max")
|
|
403
|
+
maximum = None if declared_maximum is None else float(declared_maximum)
|
|
404
|
+
if maximum is not None and maximum < minimum:
|
|
405
|
+
problems.add(
|
|
406
|
+
f"{where} has a max of {maximum:g} below its min of "
|
|
407
|
+
f"{minimum:g}, so no load fits between them"
|
|
408
|
+
)
|
|
409
|
+
maximum = None
|
|
410
|
+
|
|
411
|
+
types[key] = LoadType(step=step, minimum=minimum, maximum=maximum)
|
|
412
|
+
|
|
413
|
+
return types
|
|
414
|
+
|
|
415
|
+
|
|
295
416
|
def _bounds(
|
|
296
|
-
raw: dict,
|
|
417
|
+
raw: dict, load_type: LoadType | None, where: str, problems: Problems
|
|
297
418
|
) -> tuple[float, float | None]:
|
|
298
419
|
"""How light and how heavy this exercise may be loaded.
|
|
299
420
|
|
|
@@ -301,12 +422,12 @@ def _bounds(
|
|
|
301
422
|
ceiling under its own floor leaves progression choosing between two
|
|
302
423
|
impossible loads, and that is only visible once both are known.
|
|
303
424
|
|
|
304
|
-
The two ends default differently, and deliberately.
|
|
305
|
-
|
|
425
|
+
The two ends default differently, and deliberately. The floor comes from
|
|
426
|
+
the load type the exercise names, which always states one; nothing but a
|
|
427
|
+
bodyweight movement, which names none, reaches the zero here. No
|
|
306
428
|
ceiling is `None` rather than zero, because zero is a real maximum -
|
|
307
429
|
nothing may be added at all - and equipment that does not run out before
|
|
308
|
-
you do is the common case.
|
|
309
|
-
ceilings existed keeps its meaning exactly.
|
|
430
|
+
you do is the common case.
|
|
310
431
|
|
|
311
432
|
Anything contradictory is dropped rather than honoured. The file will not
|
|
312
433
|
load either way - `problems` sees to that - so the only question is which
|
|
@@ -314,7 +435,7 @@ def _bounds(
|
|
|
314
435
|
"""
|
|
315
436
|
declared_minimum = raw.get("min_weight")
|
|
316
437
|
if declared_minimum is None:
|
|
317
|
-
minimum =
|
|
438
|
+
minimum = load_type.minimum if load_type else 0.0
|
|
318
439
|
else:
|
|
319
440
|
minimum = float(declared_minimum)
|
|
320
441
|
if minimum < 0:
|
|
@@ -323,10 +444,10 @@ def _bounds(
|
|
|
323
444
|
|
|
324
445
|
declared_maximum = raw.get("max_weight")
|
|
325
446
|
if declared_maximum is None:
|
|
326
|
-
ceiling =
|
|
447
|
+
ceiling = load_type.maximum if load_type else None
|
|
327
448
|
if ceiling is None:
|
|
328
449
|
return minimum, None
|
|
329
|
-
maximum =
|
|
450
|
+
maximum = ceiling
|
|
330
451
|
else:
|
|
331
452
|
maximum = float(declared_maximum)
|
|
332
453
|
|
|
@@ -367,7 +488,7 @@ def _bodyweight_factor(raw: dict, where: str, problems: Problems) -> float:
|
|
|
367
488
|
|
|
368
489
|
def _build_exercise(
|
|
369
490
|
raw: dict,
|
|
370
|
-
|
|
491
|
+
types: dict[str, LoadType],
|
|
371
492
|
where: str,
|
|
372
493
|
problems: Problems,
|
|
373
494
|
*,
|
|
@@ -379,17 +500,25 @@ def _build_exercise(
|
|
|
379
500
|
problems.add(f"{where}: exercise is missing {', '.join(missing)}")
|
|
380
501
|
return None
|
|
381
502
|
|
|
382
|
-
load
|
|
503
|
+
# Lower-cased to match the load types, which are keyed that way, and stored
|
|
504
|
+
# lower-cased so that everything reading a load downstream - the bodyweight
|
|
505
|
+
# test, the sync that refuses to cross equipment - compares like with like.
|
|
506
|
+
load = str(raw["load"]).lower()
|
|
507
|
+
# Bodyweight is the one load that names no load type: there is no
|
|
508
|
+
# equipment to describe, and nothing to add to it.
|
|
509
|
+
load_type = None if load == BODYWEIGHT else types.get(load)
|
|
510
|
+
if load != BODYWEIGHT and load_type is None:
|
|
511
|
+
known = ", ".join(sorted(types)) or "none"
|
|
512
|
+
problems.add(
|
|
513
|
+
f"{where}: exercise {raw['name']!r} has load {load!r}, which is "
|
|
514
|
+
f"not among the load types defined at the top level ({known})"
|
|
515
|
+
)
|
|
516
|
+
|
|
383
517
|
# An exercise may set its own step, e.g. the deadlift moves in bigger jumps
|
|
384
|
-
# than the other barbell lifts. Otherwise the load type decides.
|
|
518
|
+
# than the other barbell lifts. Otherwise the load type it names decides.
|
|
385
519
|
declared_step = raw.get("weight_step")
|
|
386
520
|
if declared_step is None:
|
|
387
|
-
|
|
388
|
-
problems.add(
|
|
389
|
-
f"{where}: exercise {raw['name']!r} has load {load!r}, "
|
|
390
|
-
f"which has no entry in settings.weight_steps"
|
|
391
|
-
)
|
|
392
|
-
weight_step = float(loads.steps.get(load, 0.0))
|
|
521
|
+
weight_step = load_type.step if load_type else 0.0
|
|
393
522
|
else:
|
|
394
523
|
weight_step = float(declared_step)
|
|
395
524
|
if weight_step <= 0 and load != BODYWEIGHT:
|
|
@@ -415,7 +544,7 @@ def _build_exercise(
|
|
|
415
544
|
problems.add(f"{where}: {raw['name']!r} has a negative start_weight")
|
|
416
545
|
start_weight = 0.0
|
|
417
546
|
|
|
418
|
-
min_weight, max_weight = _bounds(raw,
|
|
547
|
+
min_weight, max_weight = _bounds(raw, load_type, where, problems)
|
|
419
548
|
if max_weight is not None and start_weight > max_weight:
|
|
420
549
|
# `start_weight` is read only when the step is created, which is the
|
|
421
550
|
# one moment nothing else could catch this: no session has been logged
|
|
@@ -452,7 +581,7 @@ def _build_exercise(
|
|
|
452
581
|
|
|
453
582
|
def _build_workout(
|
|
454
583
|
entry: dict,
|
|
455
|
-
|
|
584
|
+
types: dict[str, LoadType],
|
|
456
585
|
path: str,
|
|
457
586
|
problems: Problems,
|
|
458
587
|
*,
|
|
@@ -471,7 +600,7 @@ def _build_workout(
|
|
|
471
600
|
for raw in entry.get("exercises") or []:
|
|
472
601
|
spec = _build_exercise(
|
|
473
602
|
raw,
|
|
474
|
-
|
|
603
|
+
types,
|
|
475
604
|
f"{path}:{key}",
|
|
476
605
|
problems,
|
|
477
606
|
partial_progression=partial_progression,
|
|
@@ -509,22 +638,25 @@ def _check_shared(config: Config, path: str, problems: Problems) -> None:
|
|
|
509
638
|
"""A shared exercise must be programmed identically everywhere.
|
|
510
639
|
|
|
511
640
|
Otherwise a target synced out of one workout could land outside another
|
|
512
|
-
workout's range.
|
|
641
|
+
workout's range. Only the copies that really do sync are compared: two
|
|
642
|
+
entries carrying one name on different loads never reach each other, so
|
|
643
|
+
what they ask for is nobody else's business.
|
|
513
644
|
"""
|
|
514
645
|
for garmin_name in config.shared_exercises():
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
for
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
646
|
+
by_load: dict[str, list[ExerciseSpec]] = {}
|
|
647
|
+
for workout in config.workouts.values():
|
|
648
|
+
for spec in workout.exercises:
|
|
649
|
+
if spec.garmin_name == garmin_name:
|
|
650
|
+
by_load.setdefault(spec.load, []).append(spec)
|
|
651
|
+
|
|
652
|
+
for load, specs in by_load.items():
|
|
653
|
+
ranges = {(s.rep_low, s.rep_high, s.rep_step) for s in specs}
|
|
654
|
+
if len(ranges) > 1:
|
|
655
|
+
problems.add(
|
|
656
|
+
f"{path}: {garmin_name} appears in several workouts on "
|
|
657
|
+
f"{load} with different rep ranges {sorted(ranges)}; a "
|
|
658
|
+
f"synced target could fall outside one of them"
|
|
659
|
+
)
|
|
528
660
|
|
|
529
661
|
|
|
530
662
|
def load_config(path: str | None = None) -> Config:
|
|
@@ -545,11 +677,7 @@ def load_config(path: str | None = None) -> Config:
|
|
|
545
677
|
raise ConfigError(f"{path}: 'workouts' should be a list of workouts")
|
|
546
678
|
|
|
547
679
|
settings = data.get("settings") or {}
|
|
548
|
-
|
|
549
|
-
steps=settings.get("weight_steps") or {},
|
|
550
|
-
minimums=settings.get("min_weights") or {},
|
|
551
|
-
maximums=settings.get("max_weights") or {},
|
|
552
|
-
)
|
|
680
|
+
_reject_moved_settings(settings, path)
|
|
553
681
|
garmin_raw = settings.get("garmin") or {}
|
|
554
682
|
defaults = GarminSettings()
|
|
555
683
|
# A declared store is an instruction: second-guessing it would move
|
|
@@ -577,7 +705,7 @@ def load_config(path: str | None = None) -> Config:
|
|
|
577
705
|
_warn_if_wandering(garmin)
|
|
578
706
|
|
|
579
707
|
# Whether a hit after a stall may move only some of the sets. Resolved onto
|
|
580
|
-
# every exercise, the way a
|
|
708
|
+
# every exercise, the way a weight step is: the rules read it
|
|
581
709
|
# off the spec in hand rather than being handed the settings.
|
|
582
710
|
partial_progression = _flag(
|
|
583
711
|
settings.get("partial_progression"), "partial_progression", True
|
|
@@ -590,10 +718,11 @@ def load_config(path: str | None = None) -> Config:
|
|
|
590
718
|
bodyweight = None if declared_bodyweight is None else float(declared_bodyweight)
|
|
591
719
|
|
|
592
720
|
problems = Problems()
|
|
721
|
+
types = _load_types(data.get("load"), path, problems)
|
|
593
722
|
workouts: dict[str, Workout] = {}
|
|
594
723
|
for entry in data["workouts"]:
|
|
595
724
|
workout = _build_workout(
|
|
596
|
-
entry,
|
|
725
|
+
entry, types, path, problems, partial_progression=partial_progression
|
|
597
726
|
)
|
|
598
727
|
if workout is None:
|
|
599
728
|
continue
|
|
@@ -55,7 +55,7 @@ class ExerciseSpec:
|
|
|
55
55
|
#: asked for nine. Off, every set moves together however long the stall,
|
|
56
56
|
#: and a deload steps the whole target down rather than one set of it.
|
|
57
57
|
#: Declared once as settings.partial_progression and resolved onto every
|
|
58
|
-
#: exercise, the way a
|
|
58
|
+
#: exercise, the way a weight step is.
|
|
59
59
|
partial_progression: bool = True
|
|
60
60
|
|
|
61
61
|
@property
|
|
@@ -160,9 +160,17 @@ class Config:
|
|
|
160
160
|
return iter(self.workouts.values())
|
|
161
161
|
|
|
162
162
|
def shared_exercises(self) -> set[str]:
|
|
163
|
-
"""Garmin names that appear in more than one workout.
|
|
164
|
-
|
|
163
|
+
"""Garmin names that appear in more than one workout on one load.
|
|
164
|
+
|
|
165
|
+
The load counts as much as the name. The same movement performed on
|
|
166
|
+
different equipment is two exercises that happen to be called the same
|
|
167
|
+
thing - the seated calf raise on the gym machine and the one done with
|
|
168
|
+
a pair of dumbbells at home - and a weight decided on one of them is
|
|
169
|
+
not a weight the other can be asked for.
|
|
170
|
+
"""
|
|
171
|
+
seen: dict[tuple[str, str], int] = {}
|
|
165
172
|
for workout in self.workouts.values():
|
|
166
173
|
for spec in workout.exercises:
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
key = (spec.garmin_name, spec.load)
|
|
175
|
+
seen[key] = seen.get(key, 0) + 1
|
|
176
|
+
return {name for (name, _), count in seen.items() if count > 1}
|
|
@@ -174,6 +174,9 @@ HEADER = """\
|
|
|
174
174
|
# - Garmin stores a single target rather than a rep range, and records no
|
|
175
175
|
# load type, so rep_high and load had to be inferred. Each exercise says
|
|
176
176
|
# what was guessed about it in its notes.
|
|
177
|
+
# - load holds one entry per guessed load type, with a floor and a step but
|
|
178
|
+
# no ceiling. Rename them, split the ones that are really two racks, and
|
|
179
|
+
# give each a max where the equipment runs out.
|
|
177
180
|
#
|
|
178
181
|
# notes is free text this tool never reads. Clear it once you have checked the
|
|
179
182
|
# exercise, or keep your own reminders there.
|
|
@@ -190,18 +193,18 @@ DEFAULT_SETTINGS: dict = {
|
|
|
190
193
|
"garmin": {
|
|
191
194
|
"activity_search_limit": 50,
|
|
192
195
|
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
#: The load types a fresh config starts with, one per load `guess_load` knows
|
|
199
|
+
#: how to name. They are a starting point and nothing more: the names are the
|
|
200
|
+
#: user's to choose, and anyone lifting on more than one rack will want an
|
|
201
|
+
#: entry for each - `home_dumbbell` and `gym_dumbbell` rather than `dumbbell` -
|
|
202
|
+
#: with the exercises pointed at whichever they are performed on.
|
|
203
|
+
DEFAULT_LOADS: dict = {
|
|
204
|
+
"barbell": {"min": 12.0, "step": 2.5},
|
|
205
|
+
"dumbbell": {"min": 1.0, "step": 1.0},
|
|
206
|
+
"cable": {"min": 5.0, "step": 5.0},
|
|
207
|
+
"machine": {"min": 5.0, "step": 5.0},
|
|
205
208
|
}
|
|
206
209
|
|
|
207
210
|
|
|
@@ -262,6 +265,7 @@ def render_config(workouts: list[ImportedWorkout]) -> str:
|
|
|
262
265
|
"""A complete, valid workouts.yaml for the given workouts."""
|
|
263
266
|
document = {
|
|
264
267
|
"settings": DEFAULT_SETTINGS,
|
|
268
|
+
"load": DEFAULT_LOADS,
|
|
265
269
|
"workouts": [render_workout(workout) for workout in workouts],
|
|
266
270
|
}
|
|
267
271
|
return HEADER + dump(document)
|
|
@@ -20,9 +20,13 @@ from repwise.config import (
|
|
|
20
20
|
from repwise.domain.models import GarminSettings
|
|
21
21
|
|
|
22
22
|
SHARED = """
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
load:
|
|
24
|
+
machine:
|
|
25
|
+
min: 5.0
|
|
26
|
+
step: 5.0
|
|
27
|
+
dumbbell:
|
|
28
|
+
min: 2.5
|
|
29
|
+
step: 2.5
|
|
26
30
|
|
|
27
31
|
workouts:
|
|
28
32
|
- key: Workout A
|
|
@@ -126,9 +130,10 @@ def test_notes_are_optional(write_config):
|
|
|
126
130
|
|
|
127
131
|
COMMENTED = """\
|
|
128
132
|
# My routine. Edit the numbers, not the ids.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
load:
|
|
134
|
+
barbell:
|
|
135
|
+
min: 12.0
|
|
136
|
+
step: 5.0
|
|
132
137
|
|
|
133
138
|
workouts:
|
|
134
139
|
# Trained on Mondays.
|
|
@@ -414,7 +419,14 @@ def test_partial_progression_must_be_a_boolean(write_config):
|
|
|
414
419
|
|
|
415
420
|
def test_unknown_load_is_rejected(write_config):
|
|
416
421
|
bad = FIXTURE.replace("load: barbell", "load: kettlebell")
|
|
417
|
-
with pytest.raises(ConfigError, match="
|
|
422
|
+
with pytest.raises(ConfigError, match="not among the load types"):
|
|
423
|
+
load_config(write_config(bad))
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
def test_an_unknown_load_is_told_what_was_defined(write_config):
|
|
427
|
+
"""The name is the user's own, so the list is the only way to spot a typo."""
|
|
428
|
+
bad = FIXTURE.replace("load: barbell", "load: barbel")
|
|
429
|
+
with pytest.raises(ConfigError, match=r"\(barbell, dumbbell\)"):
|
|
418
430
|
load_config(write_config(bad))
|
|
419
431
|
|
|
420
432
|
|
|
@@ -465,7 +477,7 @@ def test_several_problems_are_all_reported(write_config):
|
|
|
465
477
|
message = str(caught.value)
|
|
466
478
|
assert "2 problems" in message
|
|
467
479
|
assert "rep_low >= rep_high" in message
|
|
468
|
-
assert "
|
|
480
|
+
assert "not among the load types" in message
|
|
469
481
|
|
|
470
482
|
|
|
471
483
|
def test_problems_in_different_workouts_are_all_reported(write_config):
|
|
@@ -548,6 +560,21 @@ def test_shared_exercise_with_differing_ranges_is_rejected(write_config):
|
|
|
548
560
|
load_config(write_config(SHARED.format(low=8)))
|
|
549
561
|
|
|
550
562
|
|
|
563
|
+
def test_one_name_on_two_loads_is_not_shared(write_config):
|
|
564
|
+
"""The machine calf raise and the dumbbell one are two exercises."""
|
|
565
|
+
text = SHARED.format(low=12).replace("load: machine", "load: dumbbell", 1)
|
|
566
|
+
assert load_config(write_config(text)).shared_exercises() == set()
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
def test_one_name_on_two_loads_may_have_different_ranges(write_config):
|
|
570
|
+
"""No target crosses between them, so neither constrains the other."""
|
|
571
|
+
text = SHARED.format(low=8).replace("load: machine", "load: dumbbell", 1)
|
|
572
|
+
config = load_config(write_config(text))
|
|
573
|
+
|
|
574
|
+
assert config["Workout A"].exercises[0].rep_low == 12
|
|
575
|
+
assert config["Workout B"].exercises[0].rep_low == 8
|
|
576
|
+
|
|
577
|
+
|
|
551
578
|
# --- the shipped example --------------------------------------------------
|
|
552
579
|
|
|
553
580
|
|
|
@@ -694,15 +721,129 @@ def test_nothing_found_suggests_import_when_there_is_no_example(nowhere):
|
|
|
694
721
|
resolve_config()
|
|
695
722
|
|
|
696
723
|
|
|
697
|
-
# ---
|
|
724
|
+
# --- load types of your own naming ----------------------------------------
|
|
698
725
|
|
|
699
726
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
727
|
+
TWO_RACKS = """
|
|
728
|
+
load:
|
|
729
|
+
home_dumbbell:
|
|
730
|
+
min: 1.0
|
|
731
|
+
max: 10.0
|
|
732
|
+
step: 1.0
|
|
733
|
+
gym_dumbbell:
|
|
734
|
+
min: 4.0
|
|
735
|
+
max: 40.0
|
|
736
|
+
step: 2.0
|
|
737
|
+
|
|
738
|
+
workouts:
|
|
739
|
+
- key: Workout A
|
|
740
|
+
garmin_workout_id: "1"
|
|
741
|
+
activity_prefixes: ["training a"]
|
|
742
|
+
exercises:
|
|
743
|
+
- name: Dumbbell Curl
|
|
744
|
+
garmin_name: DUMBBELL_BICEPS_CURL
|
|
745
|
+
rep_low: 10
|
|
746
|
+
rep_high: 15
|
|
747
|
+
sets: 3
|
|
748
|
+
load: gym_dumbbell
|
|
749
|
+
- name: Dumbbell Lateral Raise
|
|
750
|
+
garmin_name: DUMBBELL_LATERAL_RAISE
|
|
751
|
+
rep_low: 12
|
|
752
|
+
rep_high: 15
|
|
753
|
+
sets: 3
|
|
754
|
+
load: home_dumbbell
|
|
755
|
+
"""
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
def test_two_racks_of_dumbbells_are_two_load_types(write_config):
|
|
759
|
+
"""The whole point: one word does not tell one rack from another."""
|
|
760
|
+
curl, raise_ = load_config(write_config(TWO_RACKS))["Workout A"].exercises
|
|
761
|
+
|
|
762
|
+
assert (curl.weight_step, curl.min_weight, curl.max_weight) == (2.0, 4.0, 40.0)
|
|
763
|
+
assert (raise_.weight_step, raise_.min_weight, raise_.max_weight) == (
|
|
764
|
+
1.0,
|
|
765
|
+
1.0,
|
|
766
|
+
10.0,
|
|
704
767
|
)
|
|
705
|
-
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
def test_a_load_type_without_a_min_is_rejected(write_config):
|
|
771
|
+
text = TWO_RACKS.replace(" min: 1.0\n", "")
|
|
772
|
+
with pytest.raises(ConfigError, match=r"load\.home_dumbbell is missing min"):
|
|
773
|
+
load_config(write_config(text))
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
def test_a_load_type_without_a_step_is_rejected(write_config):
|
|
777
|
+
text = TWO_RACKS.replace(" step: 1.0\n", "")
|
|
778
|
+
with pytest.raises(ConfigError, match=r"load\.home_dumbbell is missing step"):
|
|
779
|
+
load_config(write_config(text))
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
def test_a_max_below_its_own_min_is_rejected(write_config):
|
|
783
|
+
text = TWO_RACKS.replace(" max: 10.0", " max: 0.5")
|
|
784
|
+
with pytest.raises(ConfigError, match="no load fits between them"):
|
|
785
|
+
load_config(write_config(text))
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
def test_bodyweight_cannot_be_used_as_a_load_type_name(write_config):
|
|
789
|
+
"""It is what an exercise says when it has no equipment at all."""
|
|
790
|
+
text = TWO_RACKS.replace(" home_dumbbell:", " bodyweight:")
|
|
791
|
+
with pytest.raises(ConfigError, match="reserved name"):
|
|
792
|
+
load_config(write_config(text))
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
def test_a_load_type_name_is_matched_whatever_the_case(write_config):
|
|
796
|
+
"""`Gym_Dumbbell` and `gym_dumbbell` are one rack, however either is typed."""
|
|
797
|
+
text = TWO_RACKS.replace(" gym_dumbbell:", " Gym_Dumbbell:").replace(
|
|
798
|
+
"load: gym_dumbbell", "load: GYM_DUMBBELL"
|
|
799
|
+
)
|
|
800
|
+
curl = load_config(write_config(text))["Workout A"].exercises[0]
|
|
801
|
+
|
|
802
|
+
assert curl.load == "gym_dumbbell", "and it is stored lower-cased"
|
|
803
|
+
assert (curl.weight_step, curl.min_weight, curl.max_weight) == (2.0, 4.0, 40.0)
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
def test_bodyweight_is_reserved_whatever_the_case(write_config):
|
|
807
|
+
text = TWO_RACKS.replace(" home_dumbbell:", " BodyWeight:")
|
|
808
|
+
with pytest.raises(ConfigError, match="reserved name"):
|
|
809
|
+
load_config(write_config(text))
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
def test_two_load_types_differing_only_in_case_are_rejected(write_config):
|
|
813
|
+
"""One would silently overwrite the other, leaving one rack undeclared."""
|
|
814
|
+
text = TWO_RACKS.replace(" home_dumbbell:", " Gym_Dumbbell:")
|
|
815
|
+
with pytest.raises(ConfigError, match="are one name"):
|
|
816
|
+
load_config(write_config(text))
|
|
817
|
+
|
|
818
|
+
|
|
819
|
+
def test_a_load_block_that_is_not_a_mapping_is_rejected(write_config):
|
|
820
|
+
text = (
|
|
821
|
+
TWO_RACKS[: TWO_RACKS.index("load:")]
|
|
822
|
+
+ "load: 5.0\n"
|
|
823
|
+
+ (TWO_RACKS[TWO_RACKS.index("workouts:") :])
|
|
824
|
+
)
|
|
825
|
+
with pytest.raises(ConfigError, match="'load' should be a mapping"):
|
|
826
|
+
load_config(write_config(text))
|
|
827
|
+
|
|
828
|
+
|
|
829
|
+
@pytest.mark.parametrize("moved", ["weight_steps", "min_weights", "max_weights"])
|
|
830
|
+
def test_the_settings_that_the_load_block_replaced_are_rejected(write_config, moved):
|
|
831
|
+
"""Loading such a file halfway would quietly drop its floors and steps."""
|
|
832
|
+
text = FIXTURE.replace("settings:\n", f"settings:\n {moved}:\n barbell: 5.0\n")
|
|
833
|
+
|
|
834
|
+
with pytest.raises(ConfigError) as caught:
|
|
835
|
+
load_config(write_config(text))
|
|
836
|
+
|
|
837
|
+
message = str(caught.value)
|
|
838
|
+
assert f"settings.{moved}" in message
|
|
839
|
+
assert "top-level 'load' key" in message
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
# --- how light a load can go ----------------------------------------------
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
def test_the_floor_comes_from_the_load_type_named(write_config):
|
|
846
|
+
config = load_config(write_config(FIXTURE))
|
|
706
847
|
assert config["Workout A"].exercises[0].min_weight == 12.0
|
|
707
848
|
|
|
708
849
|
|
|
@@ -714,10 +855,10 @@ def test_an_exercise_can_set_its_own_min_weight(write_config):
|
|
|
714
855
|
assert config["Workout A"].exercises[0].min_weight == 20.0
|
|
715
856
|
|
|
716
857
|
|
|
717
|
-
def
|
|
718
|
-
"""
|
|
858
|
+
def test_bodyweight_has_no_floor(write_config):
|
|
859
|
+
"""It names no load type, so there is no equipment to have a bottom."""
|
|
719
860
|
config = load_config(write_config(FIXTURE))
|
|
720
|
-
assert config["Workout A"].exercises[
|
|
861
|
+
assert config["Workout A"].exercises[1].min_weight == 0.0
|
|
721
862
|
|
|
722
863
|
|
|
723
864
|
def test_a_negative_min_weight_is_rejected(write_config):
|
|
@@ -731,10 +872,9 @@ def test_a_negative_min_weight_is_rejected(write_config):
|
|
|
731
872
|
# --- how heavy a load can go ----------------------------------------------
|
|
732
873
|
|
|
733
874
|
|
|
734
|
-
def
|
|
875
|
+
def test_the_ceiling_comes_from_the_load_type_named(write_config):
|
|
735
876
|
text = FIXTURE.replace(
|
|
736
|
-
"
|
|
737
|
-
" max_weights:\n barbell: 100.0\n\n weight_steps:",
|
|
877
|
+
" min: 12.0\n step: 5.0", " min: 12.0\n max: 100.0\n step: 5.0"
|
|
738
878
|
)
|
|
739
879
|
config = load_config(write_config(text))
|
|
740
880
|
assert config["Workout A"].exercises[0].max_weight == 100.0
|
|
@@ -748,11 +888,10 @@ def test_an_exercise_can_set_its_own_max_weight(write_config):
|
|
|
748
888
|
assert config["Workout A"].exercises[0].max_weight == 60.0
|
|
749
889
|
|
|
750
890
|
|
|
751
|
-
def
|
|
891
|
+
def test_an_exercise_max_weight_beats_the_load_type_named(write_config):
|
|
752
892
|
"""Only this one movement is capped, and the rack is not."""
|
|
753
893
|
text = FIXTURE.replace(
|
|
754
|
-
"
|
|
755
|
-
" max_weights:\n barbell: 100.0\n\n weight_steps:",
|
|
894
|
+
" min: 12.0\n step: 5.0", " min: 12.0\n max: 100.0\n step: 5.0"
|
|
756
895
|
).replace(
|
|
757
896
|
" load: barbell", " load: barbell\n max_weight: 60.0"
|
|
758
897
|
)
|
|
@@ -760,7 +899,7 @@ def test_an_exercise_max_weight_beats_the_load_type(write_config):
|
|
|
760
899
|
assert config["Workout A"].exercises[0].max_weight == 60.0
|
|
761
900
|
|
|
762
901
|
|
|
763
|
-
def
|
|
902
|
+
def test_a_load_type_with_no_max_means_no_ceiling(write_config):
|
|
764
903
|
"""Unset is None rather than zero: zero would be a real maximum."""
|
|
765
904
|
config = load_config(write_config(FIXTURE))
|
|
766
905
|
assert config["Workout A"].exercises[0].max_weight is None
|
|
@@ -788,7 +927,7 @@ def test_a_start_weight_above_the_max_weight_is_rejected(write_config):
|
|
|
788
927
|
"""The one moment no session exists yet to correct it."""
|
|
789
928
|
text = FIXTURE.replace(
|
|
790
929
|
" load: barbell",
|
|
791
|
-
" load: barbell\n start_weight: 30.0\n max_weight:
|
|
930
|
+
" load: barbell\n start_weight: 30.0\n max_weight: 20.0",
|
|
792
931
|
)
|
|
793
932
|
with pytest.raises(ConfigError, match="above its own max_weight"):
|
|
794
933
|
load_config(write_config(text))
|
|
@@ -129,6 +129,15 @@ def test_rendered_config_is_valid_and_loadable(tmp_path):
|
|
|
129
129
|
assert plank.time_based and plank.bodyweight
|
|
130
130
|
|
|
131
131
|
|
|
132
|
+
def test_rendered_config_gives_every_load_its_own_type(tmp_path):
|
|
133
|
+
"""A load type states a floor as well as a step, so both are written."""
|
|
134
|
+
path = tmp_path / "workouts.yaml"
|
|
135
|
+
path.write_text(render_config([describe_workout(payload(SQUAT))]))
|
|
136
|
+
|
|
137
|
+
squat = load_config(str(path))["Workout A"].exercises[0]
|
|
138
|
+
assert squat.weight_step > 0 and squat.min_weight > 0
|
|
139
|
+
|
|
140
|
+
|
|
132
141
|
def test_rendered_config_flags_what_was_inferred(tmp_path):
|
|
133
142
|
"""A dumped document has nowhere to put a comment, so what had to be
|
|
134
143
|
guessed is said in the exercise's own notes."""
|
|
@@ -290,6 +290,30 @@ def test_a_shared_exercise_ends_up_at_the_most_recent_decision(account):
|
|
|
290
290
|
assert calf_targets(account.saved) == {"111": 18.0, "222": 18.0}
|
|
291
291
|
|
|
292
292
|
|
|
293
|
+
def test_the_same_exercise_on_another_load_is_not_synced(account):
|
|
294
|
+
"""One Garmin name, two kinds of equipment: two exercises, not one.
|
|
295
|
+
|
|
296
|
+
Workout B does the calf raise with dumbbells rather than on the machine,
|
|
297
|
+
so Workout A's 18 has nothing to say about it and B keeps the 16 its own
|
|
298
|
+
session earned.
|
|
299
|
+
"""
|
|
300
|
+
config = config_ab(b_exercises=(BENCH, replace(CALF, load="dumbbell")))
|
|
301
|
+
|
|
302
|
+
run(account, config, apply=True)
|
|
303
|
+
|
|
304
|
+
assert calf_targets(account.saved) == {"111": 18.0, "222": 16.0}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def test_the_same_exercise_on_another_load_is_left_out_of_the_report(account, caplog):
|
|
308
|
+
"""Nothing is 'Also in' a workout the decision does not reach."""
|
|
309
|
+
config = config_ab(b_exercises=(BENCH, replace(CALF, load="dumbbell")))
|
|
310
|
+
|
|
311
|
+
with caplog.at_level(logging.INFO):
|
|
312
|
+
run(account, config, apply=True)
|
|
313
|
+
|
|
314
|
+
assert "Also in" not in caplog.text
|
|
315
|
+
|
|
316
|
+
|
|
293
317
|
def test_a_dry_run_writes_nothing(account):
|
|
294
318
|
assert run(account) == ExitCode.OK
|
|
295
319
|
assert account.saved == []
|
|
@@ -299,6 +323,11 @@ def test_a_dry_run_writes_nothing(account):
|
|
|
299
323
|
|
|
300
324
|
|
|
301
325
|
NEW_WORKOUT = """\
|
|
326
|
+
load:
|
|
327
|
+
barbell:
|
|
328
|
+
min: 12.0
|
|
329
|
+
step: 2.5
|
|
330
|
+
|
|
302
331
|
workouts:
|
|
303
332
|
- key: Workout C
|
|
304
333
|
activity_prefixes: ["workout c"]
|
|
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
|
|
File without changes
|