sweatstack 0.31.1__tar.gz → 0.32.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 (27) hide show
  1. {sweatstack-0.31.1 → sweatstack-0.32.0}/PKG-INFO +1 -1
  2. {sweatstack-0.31.1 → sweatstack-0.32.0}/pyproject.toml +1 -1
  3. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/client.py +21 -12
  4. {sweatstack-0.31.1 → sweatstack-0.32.0}/.gitignore +0 -0
  5. {sweatstack-0.31.1 → sweatstack-0.32.0}/.python-version +0 -0
  6. {sweatstack-0.31.1 → sweatstack-0.32.0}/DEVELOPMENT.md +0 -0
  7. {sweatstack-0.31.1 → sweatstack-0.32.0}/Makefile +0 -0
  8. {sweatstack-0.31.1 → sweatstack-0.32.0}/README.md +0 -0
  9. {sweatstack-0.31.1 → sweatstack-0.32.0}/playground/.ipynb_checkpoints/Untitled-checkpoint.ipynb +0 -0
  10. {sweatstack-0.31.1 → sweatstack-0.32.0}/playground/README.md +0 -0
  11. {sweatstack-0.31.1 → sweatstack-0.32.0}/playground/Sweat Stack examples/Getting started.ipynb +0 -0
  12. {sweatstack-0.31.1 → sweatstack-0.32.0}/playground/Untitled.ipynb +0 -0
  13. {sweatstack-0.31.1 → sweatstack-0.32.0}/playground/hello.py +0 -0
  14. {sweatstack-0.31.1 → sweatstack-0.32.0}/playground/pyproject.toml +0 -0
  15. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/Sweat Stack examples/Getting started.ipynb +0 -0
  16. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/__init__.py +0 -0
  17. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/cli.py +0 -0
  18. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/constants.py +0 -0
  19. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/ipython_init.py +0 -0
  20. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/jupyterlab_oauth2_startup.py +0 -0
  21. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/openapi_schemas.py +0 -0
  22. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/py.typed +0 -0
  23. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/schemas.py +0 -0
  24. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/streamlit.py +0 -0
  25. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/sweatshell.py +0 -0
  26. {sweatstack-0.31.1 → sweatstack-0.32.0}/src/sweatstack/utils.py +0 -0
  27. {sweatstack-0.31.1 → sweatstack-0.32.0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sweatstack
3
- Version: 0.31.1
3
+ Version: 0.32.0
4
4
  Summary: The official Python client for SweatStack
5
5
  Author-email: Aart Goossens <aart@gssns.io>
6
6
  Requires-Python: >=3.9
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sweatstack"
3
- version = "0.31.1"
3
+ version = "0.32.0"
4
4
  description = "The official Python client for SweatStack"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -8,6 +8,7 @@ import time
8
8
  import urllib
9
9
  import webbrowser
10
10
  from datetime import date, datetime
11
+ from enum import Enum
11
12
  from functools import wraps
12
13
  from http.server import BaseHTTPRequestHandler, HTTPServer
13
14
  from importlib.metadata import version
@@ -20,7 +21,7 @@ import pandas as pd
20
21
 
21
22
  from .constants import DEFAULT_URL
22
23
  from .schemas import (
23
- ActivityDetails, ActivitySummary, Sport, TraceDetails, UserSummary
24
+ ActivityDetails, ActivitySummary, Metric, Sport, TraceDetails, UserSummary
24
25
  )
25
26
  from .utils import decode_jwt_body, make_dataframe_streamlit_compatible
26
27
 
@@ -286,6 +287,9 @@ class Client(OAuth2Mixin, DelegationMixin):
286
287
  with httpx.Client(base_url=self.url, headers=headers) as client:
287
288
  yield client
288
289
 
290
+ def _enums_to_strings(self, values: list[Enum | str]) -> list[str]:
291
+ return [value.value if isinstance(value, Enum) else value for value in values]
292
+
289
293
  def _get_activities_generator(
290
294
  self,
291
295
  *,
@@ -306,8 +310,7 @@ class Client(OAuth2Mixin, DelegationMixin):
306
310
  if end is not None:
307
311
  params["end"] = end.isoformat()
308
312
  if sports is not None:
309
- sports = [sport.value if isinstance(sport, Sport) else sport for sport in sports]
310
- params["sports"] = sports
313
+ params["sports"] = self._enums_to_strings(sports)
311
314
  if tags is not None:
312
315
  params["tags"] = tags
313
316
 
@@ -409,9 +412,10 @@ class Client(OAuth2Mixin, DelegationMixin):
409
412
  def get_activity_mean_max(
410
413
  self,
411
414
  activity_id: str,
412
- metric: str,
415
+ metric: Metric | str,
413
416
  adaptive_sampling: bool = False,
414
417
  ) -> pd.DataFrame:
418
+ metric = self._enums_to_strings([metric])[0]
415
419
  with self._http_client() as client:
416
420
  response = client.get(
417
421
  url=f"/api/v1/activities/{activity_id}/mean-max",
@@ -426,7 +430,7 @@ class Client(OAuth2Mixin, DelegationMixin):
426
430
 
427
431
  def get_latest_activity_data(
428
432
  self,
429
- sport: Sport | None = None,
433
+ sport: Sport | str | None = None,
430
434
  adaptive_sampling_on: Literal["power", "speed"] | None = None,
431
435
  ) -> pd.DataFrame:
432
436
  activity = self.get_latest_activity(sport=sport)
@@ -434,8 +438,8 @@ class Client(OAuth2Mixin, DelegationMixin):
434
438
 
435
439
  def get_latest_activity_mean_max(
436
440
  self,
437
- metric: str,
438
- sport: Sport | None = None,
441
+ metric: Metric | str,
442
+ sport: Sport | str | None = None,
439
443
  adaptive_sampling: bool = False,
440
444
  ) -> pd.DataFrame:
441
445
  activity = self.get_latest_activity(sport=sport)
@@ -444,11 +448,11 @@ class Client(OAuth2Mixin, DelegationMixin):
444
448
  def get_longitudinal_data(
445
449
  self,
446
450
  *,
447
- sport: Sport | None = None,
451
+ sport: Sport | str | None = None,
448
452
  sports: list[Sport | str] | None = None,
449
453
  start: date | str,
450
454
  end: date | str | None = None,
451
- metrics: list[str] | None = None,
455
+ metrics: list[Metric | str] | None = None,
452
456
  adaptive_sampling_on: Literal["power", "speed"] | None = None,
453
457
  ) -> pd.DataFrame:
454
458
  if sport and sports:
@@ -458,6 +462,9 @@ class Client(OAuth2Mixin, DelegationMixin):
458
462
  elif sports is None:
459
463
  sports = []
460
464
 
465
+ sports = self._enums_to_strings(sports)
466
+ metrics = self._enums_to_strings(metrics)
467
+
461
468
  params = {
462
469
  "sports": sports,
463
470
  "start": start,
@@ -483,10 +490,13 @@ class Client(OAuth2Mixin, DelegationMixin):
483
490
  self,
484
491
  *,
485
492
  sport: Sport | str,
486
- metric: str,
493
+ metric: Metric | str,
487
494
  date: date | str | None = None,
488
495
  window_days: int | None = None,
489
496
  ) -> pd.DataFrame:
497
+ sport = self._enums_to_strings([sport])[0]
498
+ metric = self._enums_to_strings([metric])[0]
499
+
490
500
  params = {
491
501
  "sport": sport,
492
502
  "metric": metric,
@@ -526,8 +536,7 @@ class Client(OAuth2Mixin, DelegationMixin):
526
536
  if end is not None:
527
537
  params["end"] = end.isoformat()
528
538
  if sports is not None:
529
- sports = [sport.value if isinstance(sport, Sport) else sport for sport in sports]
530
- params["sports"] = sports
539
+ params["sports"] = self._enums_to_strings(sports)
531
540
  if tags is not None:
532
541
  params["tags"] = tags
533
542
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes