get default hr and power zones from config file

This commit is contained in:
Davide Scaini
2026-03-29 22:06:22 +02:00
parent 3fcc8bc089
commit 4537273de9
11 changed files with 224 additions and 16 deletions
+10
View File
@@ -149,6 +149,16 @@ def extract(
console.print(f"Using [bold]{n_workers}[/bold] worker processes.")
owner = {"handle": cfg.owner_handle, "display_name": cfg.owner_display_name}
if cfg.athlete:
ath = cfg.athlete
owner["athlete"] = {
k: v for k, v in {
"max_hr": ath.max_hr,
"ftp_w": ath.ftp_w,
"hr_zones": ath.hr_zones,
"power_zones": ath.power_zones,
}.items() if v is not None
}
summaries: list[dict] = []
errors: list[tuple[str, str]] = []
skipped = 0
+18
View File
@@ -27,6 +27,14 @@ class ClassifierConfig:
enabled: bool = False # off by default; opt-in
@dataclass
class AthleteConfig:
max_hr: int | None = None
ftp_w: int | None = None
hr_zones: list[list[int]] | None = None # [[lo, hi], ...]
power_zones: list[list[int]] | None = None
@dataclass
class ExtractConfig:
input_dirs: list[Path]
@@ -39,6 +47,7 @@ class ExtractConfig:
incremental: bool = True
owner_handle: str = "me"
owner_display_name: str = "Me"
athlete: AthleteConfig | None = None
def load_config(path: Path) -> ExtractConfig:
@@ -70,6 +79,14 @@ def load_config(path: Path) -> ExtractConfig:
cls_raw = raw.get("classifier", {})
classifier = ClassifierConfig(enabled=cls_raw.get("enabled", False))
ath_raw = raw.get("athlete", {})
athlete = AthleteConfig(
max_hr=ath_raw.get("max_hr"),
ftp_w=ath_raw.get("ftp_w"),
hr_zones=ath_raw.get("hr_zones"),
power_zones=ath_raw.get("power_zones"),
) if ath_raw else None
return ExtractConfig(
input_dirs=dirs,
output_dir=out,
@@ -81,6 +98,7 @@ def load_config(path: Path) -> ExtractConfig:
incremental=raw.get("incremental", True),
owner_handle=owner.get("handle", "me"),
owner_display_name=owner.get("display_name", "Me"),
athlete=athlete,
)