repwise 3.5.0__tar.gz → 3.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. {repwise-3.5.0/src/repwise.egg-info → repwise-3.5.1}/PKG-INFO +2 -2
  2. {repwise-3.5.0 → repwise-3.5.1}/pyproject.toml +10 -6
  3. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/__init__.py +1 -1
  4. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/update.py +23 -3
  5. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/planner.py +37 -0
  6. {repwise-3.5.0 → repwise-3.5.1/src/repwise.egg-info}/PKG-INFO +2 -2
  7. repwise-3.5.1/src/repwise.egg-info/requires.txt +2 -0
  8. {repwise-3.5.0 → repwise-3.5.1}/tests/test_update.py +74 -1
  9. repwise-3.5.0/src/repwise.egg-info/requires.txt +0 -2
  10. {repwise-3.5.0 → repwise-3.5.1}/LICENSE +0 -0
  11. {repwise-3.5.0 → repwise-3.5.1}/README.md +0 -0
  12. {repwise-3.5.0 → repwise-3.5.1}/setup.cfg +0 -0
  13. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/__main__.py +0 -0
  14. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/__init__.py +0 -0
  15. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/checking.py +0 -0
  16. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/fetch.py +0 -0
  17. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/importing.py +0 -0
  18. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/listing.py +0 -0
  19. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/logout.py +0 -0
  20. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/app/report.py +0 -0
  21. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/checker.py +0 -0
  22. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/cli/__init__.py +0 -0
  23. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/cli/completion.py +0 -0
  24. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/cli/parser.py +0 -0
  25. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/config.py +0 -0
  26. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/domain/__init__.py +0 -0
  27. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/domain/effort.py +0 -0
  28. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/domain/matching.py +0 -0
  29. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/domain/models.py +0 -0
  30. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/domain/progression.py +0 -0
  31. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/dumps.py +0 -0
  32. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/errors.py +0 -0
  33. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/garmin/__init__.py +0 -0
  34. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/garmin/catalog.py +0 -0
  35. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/garmin/client.py +0 -0
  36. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/garmin/payloads.py +0 -0
  37. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/importer.py +0 -0
  38. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/log.py +0 -0
  39. {repwise-3.5.0 → repwise-3.5.1}/src/repwise/yamlio.py +0 -0
  40. {repwise-3.5.0 → repwise-3.5.1}/src/repwise.egg-info/SOURCES.txt +0 -0
  41. {repwise-3.5.0 → repwise-3.5.1}/src/repwise.egg-info/dependency_links.txt +0 -0
  42. {repwise-3.5.0 → repwise-3.5.1}/src/repwise.egg-info/entry_points.txt +0 -0
  43. {repwise-3.5.0 → repwise-3.5.1}/src/repwise.egg-info/top_level.txt +0 -0
  44. {repwise-3.5.0 → repwise-3.5.1}/tests/test_catalog.py +0 -0
  45. {repwise-3.5.0 → repwise-3.5.1}/tests/test_checker.py +0 -0
  46. {repwise-3.5.0 → repwise-3.5.1}/tests/test_checking.py +0 -0
  47. {repwise-3.5.0 → repwise-3.5.1}/tests/test_cli.py +0 -0
  48. {repwise-3.5.0 → repwise-3.5.1}/tests/test_client.py +0 -0
  49. {repwise-3.5.0 → repwise-3.5.1}/tests/test_completion.py +0 -0
  50. {repwise-3.5.0 → repwise-3.5.1}/tests/test_config.py +0 -0
  51. {repwise-3.5.0 → repwise-3.5.1}/tests/test_dumps.py +0 -0
  52. {repwise-3.5.0 → repwise-3.5.1}/tests/test_effort.py +0 -0
  53. {repwise-3.5.0 → repwise-3.5.1}/tests/test_fetch.py +0 -0
  54. {repwise-3.5.0 → repwise-3.5.1}/tests/test_importer.py +0 -0
  55. {repwise-3.5.0 → repwise-3.5.1}/tests/test_importing.py +0 -0
  56. {repwise-3.5.0 → repwise-3.5.1}/tests/test_listing.py +0 -0
  57. {repwise-3.5.0 → repwise-3.5.1}/tests/test_log.py +0 -0
  58. {repwise-3.5.0 → repwise-3.5.1}/tests/test_logout.py +0 -0
  59. {repwise-3.5.0 → repwise-3.5.1}/tests/test_main.py +0 -0
  60. {repwise-3.5.0 → repwise-3.5.1}/tests/test_matching.py +0 -0
  61. {repwise-3.5.0 → repwise-3.5.1}/tests/test_models.py +0 -0
  62. {repwise-3.5.0 → repwise-3.5.1}/tests/test_payloads.py +0 -0
  63. {repwise-3.5.0 → repwise-3.5.1}/tests/test_planner.py +0 -0
  64. {repwise-3.5.0 → repwise-3.5.1}/tests/test_progression.py +0 -0
  65. {repwise-3.5.0 → repwise-3.5.1}/tests/test_report.py +0 -0
  66. {repwise-3.5.0 → repwise-3.5.1}/tests/test_yamlio.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repwise
3
- Version: 3.5.0
3
+ Version: 3.5.1
4
4
  Summary: Advance Garmin strength workout targets using double progression
5
5
  Author-email: Adam Żmuda <adam@zmuda.pro>
6
6
  License-Expression: MIT
@@ -21,7 +21,7 @@ Classifier: Topic :: Utilities
21
21
  Requires-Python: >=3.14
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: garminconnect==0.3.19
24
+ Requires-Dist: garminconnect==0.3.20
25
25
  Requires-Dist: pyyaml==6.0.3
26
26
  Dynamic: license-file
27
27
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "repwise"
7
- version = "3.5.0"
7
+ version = "3.5.1"
8
8
  description = "Advance Garmin strength workout targets using double progression"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -37,7 +37,7 @@ classifiers = [
37
37
  # raises a PR per release. garminconnect in particular has broken
38
38
  # authentication before, so the working version is recorded deliberately.
39
39
  dependencies = [
40
- "garminconnect==0.3.19",
40
+ "garminconnect==0.3.20",
41
41
  "pyyaml==6.0.3",
42
42
  ]
43
43
 
@@ -63,15 +63,15 @@ Issues = "https://github.com/theadzik/repwise/issues"
63
63
  # workflow cannot disagree about the answer.
64
64
  [dependency-groups]
65
65
  release = [
66
- "commitizen==4.19.2",
66
+ "commitizen==4.19.3",
67
67
  ]
68
68
  dev = [
69
69
  { include-group = "release" },
70
70
  "coverage==7.17.0",
71
- "mypy==2.4.0",
71
+ "mypy==2.4.1",
72
72
  "pre-commit==4.7.0",
73
- "pytest==9.1.1",
74
- "ruff==0.17.2",
73
+ "pytest==9.2.0",
74
+ "ruff==0.17.3",
75
75
  "types-PyYAML==6.0.12.20260906",
76
76
  ]
77
77
 
@@ -92,6 +92,10 @@ version_provider = "pep621"
92
92
  # hand-cut 0.1.0 tag, so it is stated only to pin it: the default has changed
93
93
  # upstream before, and a silent change would start a second tag series.
94
94
  tag_format = "$version"
95
+ # The web service's image tags, from .github/workflows/web.yml. They share the
96
+ # repository's tags but are not repwise releases, and without this commitizen
97
+ # warns about each one on every bump.
98
+ ignored_tag_formats = ["repwise-web-*"]
95
99
  version_files = ["src/repwise/__init__.py:__version__"]
96
100
  update_changelog_on_bump = true
97
101
  # History before 0.1.0 predates conventional commits, so there is nothing to
@@ -1,4 +1,4 @@
1
1
  """Advance Garmin strength workout targets using double progression."""
2
2
 
3
3
  __all__ = ["__version__"]
4
- __version__ = "3.5.0"
4
+ __version__ = "3.5.1"
@@ -39,6 +39,7 @@ from ..planner import (
39
39
  logged_for,
40
40
  plan_sync,
41
41
  plan_workout,
42
+ trained_exercises,
42
43
  )
43
44
  from .fetch import cache_activities
44
45
  from .report import report_plan
@@ -457,6 +458,20 @@ def advance_trained(
457
458
  plans: list[Plan] = []
458
459
  usable = False
459
460
 
461
+ # A newer session that trained a shared exercise has the last word on its
462
+ # marker, so an older one must leave it alone - see `superseded` on
463
+ # `plan_workout`. That needs every session's sets before the first is
464
+ # planned. Matched against the definitions as Garmin holds them, before
465
+ # this run changes any.
466
+ performed_by = [
467
+ performed_sets(session.exercise_sets(trained.activity_id))
468
+ for trained in sessions
469
+ ]
470
+ trained_by = [
471
+ trained_exercises(trained.workout, payloads[garmin_id(trained.workout)], sets)
472
+ for trained, sets in zip(sessions, performed_by, strict=True)
473
+ ]
474
+
460
475
  for position, trained in enumerate(sessions):
461
476
  workout, activity = trained.workout, trained.activity
462
477
  activity_id = trained.activity_id
@@ -465,10 +480,9 @@ def advance_trained(
465
480
  logger.info(f"Activity: {activity.get('activityName') or ''} ({activity_id})")
466
481
  logger.info(f"Updating: {workout.key} -> workout {workout.garmin_workout_id}")
467
482
 
468
- sets_payload = session.exercise_sets(activity_id)
469
483
  payload = payloads[garmin_id(workout)]
470
484
 
471
- performed = performed_sets(sets_payload)
485
+ performed = performed_by[position]
472
486
  if not any(performed):
473
487
  logger.warning("No working sets found in that activity; nothing to do.")
474
488
  continue
@@ -486,7 +500,13 @@ def advance_trained(
486
500
  history = gather_history(session, workout, trained.earlier, performed)
487
501
 
488
502
  plan = plan_workout(
489
- workout, payload, performed, history, asked, trusted=trusted
503
+ workout,
504
+ payload,
505
+ performed,
506
+ history,
507
+ asked,
508
+ trusted=trusted,
509
+ superseded=set().union(*trained_by[position + 1 :]),
490
510
  )
491
511
  report_plan(plan)
492
512
  plans.append(plan)
@@ -342,6 +342,33 @@ def logged_for(
342
342
  return []
343
343
 
344
344
 
345
+ def shared_key(spec: ExerciseSpec) -> tuple[str, str]:
346
+ """What makes two workouts' entries one exercise: the movement and its load.
347
+
348
+ The same rule `update` applies when it carries a decision from one workout
349
+ into another, where the same Garmin name on other equipment is a different
350
+ exercise.
351
+ """
352
+ return normalise(spec.garmin_name), spec.load
353
+
354
+
355
+ def trained_exercises(
356
+ workout: Workout, payload: dict[str, Any], performed: Performed
357
+ ) -> set[tuple[str, str]]:
358
+ """The exercises a session holds sets for, as `shared_key` names them.
359
+
360
+ Matched exactly as `plan_workout` matches them when it judges the session,
361
+ so that this is the set of exercises that session will have a verdict on.
362
+ """
363
+ specs = index_specs(workout.exercises)
364
+ found = set()
365
+ for block in iter_exercise_blocks(payload):
366
+ spec = _match(block.step, specs)
367
+ if spec is not None and _logged_for(spec, block.step, performed, specs):
368
+ found.add(shared_key(spec))
369
+ return found
370
+
371
+
345
372
  def _logged_for(
346
373
  spec: ExerciseSpec,
347
374
  step: dict[str, Any],
@@ -1168,6 +1195,7 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
1168
1195
  asked: dict[str, Target] | None = None,
1169
1196
  *,
1170
1197
  trusted: Container[str] | None = None,
1198
+ superseded: Container[tuple[str, str]] = (),
1171
1199
  ) -> Plan:
1172
1200
  """Bring a workout in line with the config, and advance what was trained.
1173
1201
 
@@ -1192,6 +1220,13 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
1192
1220
  exercise Garmin holds under another name is reused or rebuilt. Without it
1193
1221
  every name falls back to its category, which is the behaviour this tool had
1194
1222
  before it could tell a real exercise name from an invented one.
1223
+
1224
+ `superseded` is the exercises, as `shared_key` names them, that a newer
1225
+ session in the same run also trained. Their target is still judged here,
1226
+ but their marker is that session's to decide, so this one leaves the note
1227
+ as it is and carries no marker to other workouts. Deciding it here as well
1228
+ would rewrite the note on every run whenever the two sessions disagree,
1229
+ only for the newer one to write it back.
1195
1230
  """
1196
1231
  specs = index_specs(workout.exercises)
1197
1232
 
@@ -1241,6 +1276,8 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
1241
1276
  added=added,
1242
1277
  shaped=shaped,
1243
1278
  )
1279
+ if change is not None and shared_key(spec) in superseded:
1280
+ change = replace(change, marker=None)
1244
1281
 
1245
1282
  decided = change.new if change is not None else current
1246
1283
  # The last word on the target, whether a session decided it or nobody
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: repwise
3
- Version: 3.5.0
3
+ Version: 3.5.1
4
4
  Summary: Advance Garmin strength workout targets using double progression
5
5
  Author-email: Adam Żmuda <adam@zmuda.pro>
6
6
  License-Expression: MIT
@@ -21,7 +21,7 @@ Classifier: Topic :: Utilities
21
21
  Requires-Python: >=3.14
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: garminconnect==0.3.19
24
+ Requires-Dist: garminconnect==0.3.20
25
25
  Requires-Dist: pyyaml==6.0.3
26
26
  Dynamic: license-file
27
27
 
@@ -0,0 +1,2 @@
1
+ garminconnect==0.3.20
2
+ pyyaml==6.0.3
@@ -1,5 +1,6 @@
1
1
  """Choosing which sessions to update, and updating more than one at a time."""
2
2
 
3
+ import copy
3
4
  import logging
4
5
  import os
5
6
  from dataclasses import replace
@@ -18,7 +19,7 @@ from repwise.app.update import (
18
19
  sessions_before,
19
20
  )
20
21
  from repwise.config import ConfigError
21
- from repwise.domain.models import Config, GarminSettings, Workout
22
+ from repwise.domain.models import HOLD, Config, GarminSettings, Workout, marker_of
22
23
  from repwise.errors import ActivityNotFound, ExitCode, GarminError, UsageError
23
24
  from repwise.garmin.payloads import performed_sets
24
25
 
@@ -290,6 +291,78 @@ def test_a_shared_exercise_ends_up_at_the_most_recent_decision(account):
290
291
  assert calf_targets(account.saved) == {"111": 18.0, "222": 18.0}
291
292
 
292
293
 
294
+ def calf_notes(saved) -> dict[str, str]:
295
+ """The hold marker on the calf raise's note in each written workout."""
296
+ return {
297
+ workout_id: marker_of(step.get("description") or "")
298
+ for workout_id, payload in saved
299
+ for step in payload["workoutSegments"][0]["workoutSteps"]
300
+ if step["exerciseName"] == "WEIGHTED_STANDING_CALF_RAISE"
301
+ }
302
+
303
+
304
+ def calf_sessions(newer, older, workouts=None):
305
+ """Workout A today and Workout B two days ago, each training only the calf.
306
+
307
+ The target is 20 x 20 kg, the top of the calf raise's range. `newer` and
308
+ `older` are the reps each session got on every set, or None for a session
309
+ that skipped the calf raise and trained the workout's other exercise.
310
+ """
311
+
312
+ def session(reps, name, category):
313
+ if reps is None:
314
+ return sets_of(*[active(name, category, 8, 30000.0)] * 3)
315
+ calf = active("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", reps, 20000.0)
316
+ return sets_of(*[calf] * 3)
317
+
318
+ return FakeSession(
319
+ activities=[an_activity(900, "Workout A"), an_activity(800, "Workout B")],
320
+ workouts=workouts
321
+ or {
322
+ "111": steps(
323
+ rep_step("BARBELL_BACK_SQUAT", "SQUAT", 7, 30.0),
324
+ rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 20, 20.0),
325
+ ),
326
+ "222": steps(
327
+ rep_step("BARBELL_BENCH_PRESS", "BENCH_PRESS", 8, 40.0),
328
+ rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 20, 20.0),
329
+ ),
330
+ },
331
+ sets={
332
+ "900": session(newer, "BARBELL_BACK_SQUAT", "SQUAT"),
333
+ "800": session(older, "BARBELL_BENCH_PRESS", "BENCH_PRESS"),
334
+ },
335
+ )
336
+
337
+
338
+ def test_a_shared_hold_is_the_newest_sessions_and_is_written_once():
339
+ """Two sessions disagreeing about a shared exercise's hold.
340
+
341
+ B, the older, topped the calf raise out, which clears the marker; A, the
342
+ newer, missed, which sets it. A has the last word, so both end up holding.
343
+ The older session used to clear both notes on every run before A put the
344
+ marker back, so a run with nothing new rewrote both workouts.
345
+ """
346
+ first = calf_sessions(newer=17, older=20)
347
+ run(first, apply=True)
348
+ assert calf_notes(first.saved) == {"111": HOLD, "222": HOLD}
349
+
350
+ stored = {workout_id: copy.deepcopy(payload) for workout_id, payload in first.saved}
351
+ again = calf_sessions(newer=17, older=20, workouts=stored)
352
+ run(again, apply=True)
353
+
354
+ assert again.saved == []
355
+
356
+
357
+ def test_an_older_sessions_hold_still_reaches_a_workout_whose_session_skipped_it():
358
+ """Only a newer session that trained the exercise takes the marker over."""
359
+ account = calf_sessions(newer=None, older=17)
360
+
361
+ run(account, apply=True)
362
+
363
+ assert calf_notes(account.saved) == {"111": HOLD, "222": HOLD}
364
+
365
+
293
366
  def test_the_same_exercise_on_another_load_is_not_synced(account):
294
367
  """One Garmin name, two kinds of equipment: two exercises, not one.
295
368
 
@@ -1,2 +0,0 @@
1
- garminconnect==0.3.19
2
- pyyaml==6.0.3
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