trying to get sub label showed properly
This commit is contained in:
+25
-1
@@ -113,6 +113,8 @@ def _process_file(path: Path) -> dict:
|
||||
help="Only process files modified after this date.")
|
||||
@click.option("--workers", default=None, type=int,
|
||||
help="Parallel worker processes (default: CPU count).")
|
||||
@click.option("--dev", "dev_sample", default=None, type=int, metavar="N",
|
||||
help="Dev mode: sample N files evenly across the full list, output to /tmp/bincio_dev/.")
|
||||
def extract(
|
||||
config_path: Optional[str],
|
||||
input_dir: Optional[str],
|
||||
@@ -120,6 +122,7 @@ def extract(
|
||||
single_file: Optional[str],
|
||||
since: Optional[str],
|
||||
workers: Optional[int],
|
||||
dev_sample: Optional[int],
|
||||
) -> None:
|
||||
"""Parse GPX/FIT/TCX files and write BAS JSON data store."""
|
||||
|
||||
@@ -128,13 +131,25 @@ def extract(
|
||||
return
|
||||
|
||||
cfg = _resolve_config(config_path, input_dir, output_dir)
|
||||
|
||||
if dev_sample is not None:
|
||||
cfg.output_dir = Path("/tmp/bincio_dev")
|
||||
cfg.incremental = False
|
||||
console.print(f"[yellow]Dev mode:[/yellow] sampling {dev_sample} files → [cyan]{cfg.output_dir}[/cyan]")
|
||||
|
||||
cfg.output_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
files = _collect_files(cfg, since)
|
||||
if not files:
|
||||
console.print("[yellow]No supported files found.[/yellow]")
|
||||
return
|
||||
console.print(f"Found [bold]{len(files)}[/bold] activity files.")
|
||||
|
||||
if dev_sample is not None:
|
||||
total = len(files)
|
||||
files = _sample_diverse(files, dev_sample)
|
||||
console.print(f"Sampled [bold]{len(files)}[/bold] files from {total} total.")
|
||||
else:
|
||||
console.print(f"Found [bold]{len(files)}[/bold] activity files.")
|
||||
|
||||
# Build strava lookup once (serialised dict, sent to workers via initializer)
|
||||
strava_lookup: dict = {}
|
||||
@@ -314,6 +329,15 @@ def _load_existing_summaries(output_dir: Path) -> list[dict]:
|
||||
return []
|
||||
|
||||
|
||||
def _sample_diverse(files: list[Path], n: int) -> list[Path]:
|
||||
"""Return n files sampled evenly across the sorted list for date/format diversity."""
|
||||
if len(files) <= n:
|
||||
return files
|
||||
files = sorted(files)
|
||||
step = len(files) / n
|
||||
return [files[int(i * step)] for i in range(n)]
|
||||
|
||||
|
||||
def _patch_duplicate_of(output_dir: Path, activity_id: str, canonical_id: str) -> None:
|
||||
p = output_dir / "activities" / f"{activity_id}.json"
|
||||
if not p.exists():
|
||||
|
||||
Reference in New Issue
Block a user