repwise 2.1.1__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.
Files changed (62) hide show
  1. {repwise-2.1.1/src/repwise.egg-info → repwise-3.0.0}/PKG-INFO +3 -2
  2. {repwise-2.1.1 → repwise-3.0.0}/README.md +2 -1
  3. {repwise-2.1.1 → repwise-3.0.0}/pyproject.toml +3 -3
  4. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/__init__.py +1 -1
  5. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/update.py +22 -5
  6. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/config.py +213 -55
  7. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/domain/models.py +19 -4
  8. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/domain/progression.py +29 -3
  9. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/importer.py +16 -12
  10. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/planner.py +107 -25
  11. {repwise-2.1.1 → repwise-3.0.0/src/repwise.egg-info}/PKG-INFO +3 -2
  12. {repwise-2.1.1 → repwise-3.0.0}/tests/test_config.py +194 -25
  13. {repwise-2.1.1 → repwise-3.0.0}/tests/test_importer.py +9 -0
  14. {repwise-2.1.1 → repwise-3.0.0}/tests/test_planner.py +85 -0
  15. {repwise-2.1.1 → repwise-3.0.0}/tests/test_progression.py +55 -0
  16. {repwise-2.1.1 → repwise-3.0.0}/tests/test_update.py +29 -0
  17. {repwise-2.1.1 → repwise-3.0.0}/LICENSE +0 -0
  18. {repwise-2.1.1 → repwise-3.0.0}/setup.cfg +0 -0
  19. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/__main__.py +0 -0
  20. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/__init__.py +0 -0
  21. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/checking.py +0 -0
  22. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/fetch.py +0 -0
  23. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/importing.py +0 -0
  24. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/listing.py +0 -0
  25. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/logout.py +0 -0
  26. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/app/report.py +0 -0
  27. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/checker.py +0 -0
  28. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/cli/__init__.py +0 -0
  29. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/cli/completion.py +0 -0
  30. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/cli/parser.py +0 -0
  31. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/domain/__init__.py +0 -0
  32. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/domain/effort.py +0 -0
  33. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/domain/matching.py +0 -0
  34. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/dumps.py +0 -0
  35. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/errors.py +0 -0
  36. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/garmin/__init__.py +0 -0
  37. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/garmin/catalog.py +0 -0
  38. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/garmin/client.py +0 -0
  39. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/garmin/payloads.py +0 -0
  40. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/log.py +0 -0
  41. {repwise-2.1.1 → repwise-3.0.0}/src/repwise/yamlio.py +0 -0
  42. {repwise-2.1.1 → repwise-3.0.0}/src/repwise.egg-info/SOURCES.txt +0 -0
  43. {repwise-2.1.1 → repwise-3.0.0}/src/repwise.egg-info/dependency_links.txt +0 -0
  44. {repwise-2.1.1 → repwise-3.0.0}/src/repwise.egg-info/entry_points.txt +0 -0
  45. {repwise-2.1.1 → repwise-3.0.0}/src/repwise.egg-info/requires.txt +0 -0
  46. {repwise-2.1.1 → repwise-3.0.0}/src/repwise.egg-info/top_level.txt +0 -0
  47. {repwise-2.1.1 → repwise-3.0.0}/tests/test_catalog.py +0 -0
  48. {repwise-2.1.1 → repwise-3.0.0}/tests/test_checker.py +0 -0
  49. {repwise-2.1.1 → repwise-3.0.0}/tests/test_checking.py +0 -0
  50. {repwise-2.1.1 → repwise-3.0.0}/tests/test_cli.py +0 -0
  51. {repwise-2.1.1 → repwise-3.0.0}/tests/test_client.py +0 -0
  52. {repwise-2.1.1 → repwise-3.0.0}/tests/test_completion.py +0 -0
  53. {repwise-2.1.1 → repwise-3.0.0}/tests/test_dumps.py +0 -0
  54. {repwise-2.1.1 → repwise-3.0.0}/tests/test_effort.py +0 -0
  55. {repwise-2.1.1 → repwise-3.0.0}/tests/test_fetch.py +0 -0
  56. {repwise-2.1.1 → repwise-3.0.0}/tests/test_log.py +0 -0
  57. {repwise-2.1.1 → repwise-3.0.0}/tests/test_logout.py +0 -0
  58. {repwise-2.1.1 → repwise-3.0.0}/tests/test_main.py +0 -0
  59. {repwise-2.1.1 → repwise-3.0.0}/tests/test_matching.py +0 -0
  60. {repwise-2.1.1 → repwise-3.0.0}/tests/test_models.py +0 -0
  61. {repwise-2.1.1 → repwise-3.0.0}/tests/test_payloads.py +0 -0
  62. {repwise-2.1.1 → repwise-3.0.0}/tests/test_report.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repwise
3
- Version: 2.1.1
3
+ Version: 3.0.0
4
4
  Summary: Advance Garmin strength workout targets using double progression
5
5
  Author-email: Adam Żmuda <adam@zmuda.pro>
6
6
  License-Expression: MIT
@@ -92,7 +92,8 @@ Three things it handles that a spreadsheet would not:
92
92
  pull the target somewhere you cannot repeat.
93
93
  - **It eases you back after a stall.** Miss a target twice and the session that
94
94
  finally beats it earns a rep on two of your four sets rather than on all of
95
- them, so you are not asked again for the jump that just failed.
95
+ them, so you are not asked again for the jump that just failed. Set
96
+ `partial_progression: false` if you would rather every set moved together.
96
97
  - **It follows the weight you actually used.** Bump the load mid-session and the
97
98
  new load is banked, not discarded.
98
99
  - **It won't keep a load you didn't earn.** Take the 4 kg dumbbells because the
@@ -65,7 +65,8 @@ Three things it handles that a spreadsheet would not:
65
65
  pull the target somewhere you cannot repeat.
66
66
  - **It eases you back after a stall.** Miss a target twice and the session that
67
67
  finally beats it earns a rep on two of your four sets rather than on all of
68
- them, so you are not asked again for the jump that just failed.
68
+ them, so you are not asked again for the jump that just failed. Set
69
+ `partial_progression: false` if you would rather every set moved together.
69
70
  - **It follows the weight you actually used.** Bump the load mid-session and the
70
71
  new load is banked, not discarded.
71
72
  - **It won't keep a load you didn't earn.** Take the 4 kg dumbbells because the
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "repwise"
7
- version = "2.1.1"
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"
@@ -63,14 +63,14 @@ 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.17.1",
66
+ "commitizen==4.18.0",
67
67
  ]
68
68
  dev = [
69
69
  { include-group = "release" },
70
70
  "mypy==2.3.1",
71
71
  "pre-commit==4.6.2",
72
72
  "pytest==9.1.1",
73
- "ruff==0.16.3",
73
+ "ruff==0.16.5",
74
74
  "types-PyYAML==6.0.12.20260815",
75
75
  ]
76
76
 
@@ -1,4 +1,4 @@
1
1
  """Advance Garmin strength workout targets using double progression."""
2
2
 
3
3
  __all__ = ["__version__"]
4
- __version__ = "2.1.1"
4
+ __version__ = "3.0.0"
@@ -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
- if not any(normalise(s.garmin_name) in targets for s in other.exercises):
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, targets, source.key)
344
+ plan = plan_sync(other, payload, carried, source.key)
330
345
  if not plan.writable:
331
346
  continue
332
347
 
@@ -362,8 +377,10 @@ def shape_untrained(
362
377
  """Bring every workout with no session behind it in line with the config.
363
378
 
364
379
  Only the shape: which exercises, in what order, how many sets, resting how
365
- long, described how. Nothing here was earned in a session, so no target
366
- moves and nothing is warned about not having been performed.
380
+ long, described how. Nothing here was earned in a session, so the one target
381
+ that can move is the one the config settles on its own - an uneven target
382
+ evened out because partial progression has been turned off - and nothing is
383
+ warned about not having been performed.
367
384
  """
368
385
  plans: list[Plan] = []
369
386
  for workout in config:
@@ -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, field
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 LoadRules:
53
- """What a load type does: its step size, and how light and heavy it goes.
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 dumbbell rack goes up in ones, starts at one and ends at whatever the
57
- heaviest pair is - so they are declared once per load type and only
58
- overridden where an exercise really differs.
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
- steps: dict[str, float] = field(default_factory=dict)
62
- #: Missing entries mean no floor, so a config written before deloads
63
- #: existed keeps loading and simply never stops a deload.
64
- minimums: dict[str, float] = field(default_factory=dict)
65
- #: Missing entries mean no ceiling, which is the usual case: a gym's rack
66
- #: outlasts you, and only equipment you own runs out.
67
- maximums: dict[str, float] = field(default_factory=dict)
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:
@@ -106,6 +151,9 @@ def default_dump_dir() -> str:
106
151
  def _flag(declared: Any, key: str, default: bool) -> bool:
107
152
  """A yes-or-no setting, read as one rather than coerced into one.
108
153
 
154
+ `key` is the whole dotted path, since these live at more than one level of
155
+ the file and a message naming the wrong one is worse than no message.
156
+
109
157
  YAML has booleans, so a setting that wants one should insist: `bool()`
110
158
  would read the string `"false"` as true and turn a feature on for someone
111
159
  who wrote it in quotes, which is the kind of mistake a config file should
@@ -119,7 +167,7 @@ def _flag(declared: Any, key: str, default: bool) -> bool:
119
167
  return default
120
168
  if not isinstance(declared, bool):
121
169
  raise ConfigError(
122
- f"settings.garmin.{key} should be true or false, not "
170
+ f"settings.{key} should be true or false, not "
123
171
  f"{declared!r}. Unquoted, so that YAML reads it as a boolean."
124
172
  )
125
173
  return declared
@@ -289,8 +337,84 @@ class Problems:
289
337
  raise ConfigError(f"{len(self.found)} problems:\n{listed}")
290
338
 
291
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
+
292
416
  def _bounds(
293
- raw: dict, load: str, loads: LoadRules, where: str, problems: Problems
417
+ raw: dict, load_type: LoadType | None, where: str, problems: Problems
294
418
  ) -> tuple[float, float | None]:
295
419
  """How light and how heavy this exercise may be loaded.
296
420
 
@@ -298,12 +422,12 @@ def _bounds(
298
422
  ceiling under its own floor leaves progression choosing between two
299
423
  impossible loads, and that is only visible once both are known.
300
424
 
301
- The two ends default differently, and deliberately. No floor is zero, which
302
- is the honest answer for anything lifted with no equipment of its own. No
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
303
428
  ceiling is `None` rather than zero, because zero is a real maximum -
304
429
  nothing may be added at all - and equipment that does not run out before
305
- you do is the common case. Either way a config written before deloads or
306
- ceilings existed keeps its meaning exactly.
430
+ you do is the common case.
307
431
 
308
432
  Anything contradictory is dropped rather than honoured. The file will not
309
433
  load either way - `problems` sees to that - so the only question is which
@@ -311,7 +435,7 @@ def _bounds(
311
435
  """
312
436
  declared_minimum = raw.get("min_weight")
313
437
  if declared_minimum is None:
314
- minimum = float(loads.minimums.get(load, 0.0))
438
+ minimum = load_type.minimum if load_type else 0.0
315
439
  else:
316
440
  minimum = float(declared_minimum)
317
441
  if minimum < 0:
@@ -320,10 +444,10 @@ def _bounds(
320
444
 
321
445
  declared_maximum = raw.get("max_weight")
322
446
  if declared_maximum is None:
323
- ceiling = loads.maximums.get(load)
447
+ ceiling = load_type.maximum if load_type else None
324
448
  if ceiling is None:
325
449
  return minimum, None
326
- maximum = float(ceiling)
450
+ maximum = ceiling
327
451
  else:
328
452
  maximum = float(declared_maximum)
329
453
 
@@ -363,7 +487,12 @@ def _bodyweight_factor(raw: dict, where: str, problems: Problems) -> float:
363
487
 
364
488
 
365
489
  def _build_exercise(
366
- raw: dict, loads: LoadRules, where: str, problems: Problems
490
+ raw: dict,
491
+ types: dict[str, LoadType],
492
+ where: str,
493
+ problems: Problems,
494
+ *,
495
+ partial_progression: bool = True,
367
496
  ) -> ExerciseSpec | None:
368
497
  missing = [key for key in _REQUIRED if raw.get(key) is None]
369
498
  if missing:
@@ -371,17 +500,25 @@ def _build_exercise(
371
500
  problems.add(f"{where}: exercise is missing {', '.join(missing)}")
372
501
  return None
373
502
 
374
- load = raw["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
+
375
517
  # An exercise may set its own step, e.g. the deadlift moves in bigger jumps
376
- # than the other barbell lifts. Otherwise the load type decides.
518
+ # than the other barbell lifts. Otherwise the load type it names decides.
377
519
  declared_step = raw.get("weight_step")
378
520
  if declared_step is None:
379
- if load != BODYWEIGHT and load not in loads.steps:
380
- problems.add(
381
- f"{where}: exercise {raw['name']!r} has load {load!r}, "
382
- f"which has no entry in settings.weight_steps"
383
- )
384
- weight_step = float(loads.steps.get(load, 0.0))
521
+ weight_step = load_type.step if load_type else 0.0
385
522
  else:
386
523
  weight_step = float(declared_step)
387
524
  if weight_step <= 0 and load != BODYWEIGHT:
@@ -407,7 +544,7 @@ def _build_exercise(
407
544
  problems.add(f"{where}: {raw['name']!r} has a negative start_weight")
408
545
  start_weight = 0.0
409
546
 
410
- min_weight, max_weight = _bounds(raw, load, loads, where, problems)
547
+ min_weight, max_weight = _bounds(raw, load_type, where, problems)
411
548
  if max_weight is not None and start_weight > max_weight:
412
549
  # `start_weight` is read only when the step is created, which is the
413
550
  # one moment nothing else could catch this: no session has been logged
@@ -438,11 +575,17 @@ def _build_exercise(
438
575
  min_weight=min_weight,
439
576
  max_weight=max_weight,
440
577
  bodyweight_factor=bodyweight_factor,
578
+ partial_progression=partial_progression,
441
579
  )
442
580
 
443
581
 
444
582
  def _build_workout(
445
- entry: dict, loads: LoadRules, path: str, problems: Problems
583
+ entry: dict,
584
+ types: dict[str, LoadType],
585
+ path: str,
586
+ problems: Problems,
587
+ *,
588
+ partial_progression: bool = True,
446
589
  ) -> Workout | None:
447
590
  key = entry.get("key")
448
591
  if not key:
@@ -455,7 +598,13 @@ def _build_workout(
455
598
 
456
599
  exercises = []
457
600
  for raw in entry.get("exercises") or []:
458
- spec = _build_exercise(raw, loads, f"{path}:{key}", problems)
601
+ spec = _build_exercise(
602
+ raw,
603
+ types,
604
+ f"{path}:{key}",
605
+ problems,
606
+ partial_progression=partial_progression,
607
+ )
459
608
  if spec is not None:
460
609
  exercises.append(spec)
461
610
 
@@ -489,22 +638,25 @@ def _check_shared(config: Config, path: str, problems: Problems) -> None:
489
638
  """A shared exercise must be programmed identically everywhere.
490
639
 
491
640
  Otherwise a target synced out of one workout could land outside another
492
- 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.
493
644
  """
494
645
  for garmin_name in config.shared_exercises():
495
- specs = [
496
- spec
497
- for workout in config.workouts.values()
498
- for spec in workout.exercises
499
- if spec.garmin_name == garmin_name
500
- ]
501
- ranges = {(s.rep_low, s.rep_high, s.rep_step) for s in specs}
502
- if len(ranges) > 1:
503
- problems.add(
504
- f"{path}: {garmin_name} appears in several workouts with "
505
- f"different rep ranges {sorted(ranges)}; a synced target could "
506
- f"fall outside one of them"
507
- )
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
+ )
508
660
 
509
661
 
510
662
  def load_config(path: str | None = None) -> Config:
@@ -525,11 +677,7 @@ def load_config(path: str | None = None) -> Config:
525
677
  raise ConfigError(f"{path}: 'workouts' should be a list of workouts")
526
678
 
527
679
  settings = data.get("settings") or {}
528
- loads = LoadRules(
529
- steps=settings.get("weight_steps") or {},
530
- minimums=settings.get("min_weights") or {},
531
- maximums=settings.get("max_weights") or {},
532
- )
680
+ _reject_moved_settings(settings, path)
533
681
  garmin_raw = settings.get("garmin") or {}
534
682
  defaults = GarminSettings()
535
683
  # A declared store is an instruction: second-guessing it would move
@@ -550,12 +698,19 @@ def load_config(path: str | None = None) -> Config:
550
698
  ),
551
699
  activity_caching=_flag(
552
700
  garmin_raw.get("activity_caching"),
553
- "activity_caching",
701
+ "garmin.activity_caching",
554
702
  defaults.activity_caching,
555
703
  ),
556
704
  )
557
705
  _warn_if_wandering(garmin)
558
706
 
707
+ # Whether a hit after a stall may move only some of the sets. Resolved onto
708
+ # every exercise, the way a weight step is: the rules read it
709
+ # off the spec in hand rather than being handed the settings.
710
+ partial_progression = _flag(
711
+ settings.get("partial_progression"), "partial_progression", True
712
+ )
713
+
559
714
  # Unset means "ask Garmin", which is the better answer for anyone who
560
715
  # weighs in: it stays current on its own. Stating it here is for accounts
561
716
  # with no weigh-ins, and for tests that should not need a network.
@@ -563,9 +718,12 @@ def load_config(path: str | None = None) -> Config:
563
718
  bodyweight = None if declared_bodyweight is None else float(declared_bodyweight)
564
719
 
565
720
  problems = Problems()
721
+ types = _load_types(data.get("load"), path, problems)
566
722
  workouts: dict[str, Workout] = {}
567
723
  for entry in data["workouts"]:
568
- workout = _build_workout(entry, loads, path, problems)
724
+ workout = _build_workout(
725
+ entry, types, path, problems, partial_progression=partial_progression
726
+ )
569
727
  if workout is None:
570
728
  continue
571
729
  if workout.key in workouts:
@@ -50,6 +50,13 @@ class ExerciseSpec:
50
50
  #: carries none of you - so the default is to count only the stored weight.
51
51
  #: Read by `check` alone; see `domain/effort.py`.
52
52
  bodyweight_factor: float = 0.0
53
+ #: Whether a hit after a stall may move only some of the sets. On - the
54
+ #: default - a target can ramp, `8+2` being eight reps with two of the sets
55
+ #: asked for nine. Off, every set moves together however long the stall,
56
+ #: and a deload steps the whole target down rather than one set of it.
57
+ #: Declared once as settings.partial_progression and resolved onto every
58
+ #: exercise, the way a weight step is.
59
+ partial_progression: bool = True
53
60
 
54
61
  @property
55
62
  def bodyweight(self) -> bool:
@@ -153,9 +160,17 @@ class Config:
153
160
  return iter(self.workouts.values())
154
161
 
155
162
  def shared_exercises(self) -> set[str]:
156
- """Garmin names that appear in more than one workout."""
157
- seen: dict[str, int] = {}
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] = {}
158
172
  for workout in self.workouts.values():
159
173
  for spec in workout.exercises:
160
- seen[spec.garmin_name] = seen.get(spec.garmin_name, 0) + 1
161
- return {name for name, count in seen.items() if count > 1}
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}
@@ -187,7 +187,18 @@ def _ladder(spec: ExerciseSpec, target: Target) -> int:
187
187
 
188
188
 
189
189
  def _one_rung_down(spec: ExerciseSpec, target: Target) -> Target:
190
- """The target one set easier: the exact inverse of a single advance."""
190
+ """The target one set easier: the exact inverse of a single advance.
191
+
192
+ Without partial progression an advance is the whole target, so the inverse
193
+ is too: the base comes down a step and every set comes with it. A ramp left
194
+ over from before the setting changed loses its lead here along with the
195
+ step, which is the one place this drops by more than a single rung. What
196
+ bounds it is `_deload`, which never eases *above* what the session managed
197
+ and never below `rep_low` - not that it stops at where the session landed,
198
+ since a near miss is exactly the case that eases past it.
199
+ """
200
+ if not spec.partial_progression:
201
+ return Target(target.reps - spec.rep_step, target.weight)
191
202
  if target.lead:
192
203
  return Target(target.reps, target.weight, target.lead - 1)
193
204
  return Target(target.reps - spec.rep_step, target.weight, spec.sets - 1)
@@ -202,6 +213,10 @@ def _achieved(spec: ExerciseSpec, weight: float, reps: list[int]) -> Target:
202
213
  and asking for less than was managed is the safe direction to round.
203
214
  """
204
215
  floor = min(reps)
216
+ if not spec.partial_progression:
217
+ # No rung between two flat targets to land on, so what the session
218
+ # managed is what every set managed.
219
+ return Target(floor, weight)
205
220
  higher = floor + spec.rep_step
206
221
  beat = sum(1 for done in reps if done >= higher)
207
222
  return Target(floor, weight, min(beat, spec.sets - 1))
@@ -265,7 +280,16 @@ def _deload(
265
280
  if eased == bottom:
266
281
  return eased, "missed twice, ease to the bottom of the range"
267
282
  if eased == down:
268
- return eased, "missed twice, ease by one set"
283
+ # With partial progression off there is no set to name: every set moved
284
+ # together on the way up, and the whole target comes down together too.
285
+ unit = "second" if spec.time_based else "rep"
286
+ plural = "" if spec.rep_step == 1 else "s"
287
+ by = (
288
+ "ease by one set"
289
+ if spec.partial_progression
290
+ else f"take {spec.rep_step} {unit}{plural} off"
291
+ )
292
+ return eased, f"missed twice, {by}"
269
293
  return eased, "missed twice, ease to where the session landed"
270
294
 
271
295
 
@@ -345,7 +369,9 @@ def _advance(
345
369
  # whole target moving as it always has, and every miss in the streak behind
346
370
  # it costs one of them. A hit always earns at least one, however long the
347
371
  # streak, or a stall could never end.
348
- units = max(spec.sets - streak, 1)
372
+ # Unless partial progression is off, in which case the streak buys nothing:
373
+ # every set moves together, so a hit is always the whole target moving.
374
+ units = spec.sets if not spec.partial_progression else max(spec.sets - streak, 1)
349
375
  if lead:
350
376
  # Level the sets before the base moves. The ramp is a way through a
351
377
  # stall rather than a shape to keep, so it closes at the first
@@ -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
- "weight_steps": {
194
- "barbell": 2.5,
195
- "dumbbell": 1.0,
196
- "cable": 5.0,
197
- "machine": 5.0,
198
- },
199
- "min_weights": {
200
- "barbell": 12.0,
201
- "dumbbell": 1.0,
202
- "cable": 5.0,
203
- "machine": 5.0,
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)