Skip to content

Commit c4b49e6

Browse files
committed
fix(pipeline): Replace hardcoded "processing" label with stage-specific descriptions
1 parent 6c933a8 commit c4b49e6

2 files changed

Lines changed: 27 additions & 8 deletions

File tree

osmsg/pipeline.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,16 @@ def _processing_config(cfg: RunConfig, *, parquet_dir: Path, geom_wkt: str | Non
194194

195195

196196
def _download_all(
197-
urls: list[str], mode: str, max_workers: int, cookie: str | None, cache_dir: Path, label: str
197+
urls: list[str],
198+
mode: str,
199+
max_workers: int,
200+
cookie: str | None,
201+
cache_dir: Path,
202+
label: str,
203+
description: str = "downloading",
198204
) -> None:
199205
with (
200-
progress_bar(len(urls), unit=label) as advance,
206+
progress_bar(len(urls), unit=label, description=description) as advance,
201207
concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as pool,
202208
):
203209
for _ in pool.map(lambda u: download_osm_file(u, mode=mode, cookie=cookie, cache_dir=cache_dir), urls):
@@ -214,9 +220,10 @@ def _process_all(
214220
label: str,
215221
workers: int,
216222
extra_iterables: tuple[list, ...] = (),
223+
description: str = "processing",
217224
) -> None:
218225
with (
219-
progress_bar(len(items), unit=label) as advance,
226+
progress_bar(len(items), unit=label, description=description) as advance,
220227
concurrent.futures.ProcessPoolExecutor(
221228
max_workers=workers, initializer=initializer, initargs=init_args
222229
) as pool,
@@ -314,7 +321,9 @@ def run(cfg: RunConfig) -> dict[str, Any]:
314321
cs_config["window_start_utc"] = cfg.start_date.astimezone(UTC)
315322
cs_config["window_end_utc"] = cfg.end_date.astimezone(UTC)
316323

317-
_download_all(urls, "changeset", max_workers, None, cfg.cache_dir, "changesets")
324+
_download_all(
325+
urls, "changeset", max_workers, None, cfg.cache_dir, "changesets", description="Downloading changesets"
326+
)
318327
_process_all(
319328
urls,
320329
target=process_changeset,
@@ -323,6 +332,7 @@ def run(cfg: RunConfig) -> dict[str, Any]:
323332
chunksize=10,
324333
label="changesets",
325334
workers=max_workers,
335+
description="Processing changesets",
326336
)
327337
dbmod.merge_parquet_files(conn, cs_dir, cleanup=True)
328338
info("Changeset processing complete.")
@@ -353,7 +363,15 @@ def run(cfg: RunConfig) -> dict[str, Any]:
353363
cf_config["start_date_utc"] = url_start_date_utc
354364
cf_config["end_date_utc"] = url_end_date_utc
355365

356-
_download_all(urls, "changefiles", max_workers, cookie, cfg.cache_dir, "changefiles")
366+
_download_all(
367+
urls,
368+
"changefiles",
369+
max_workers,
370+
cookie,
371+
cfg.cache_dir,
372+
"changefiles",
373+
description="Downloading changefiles",
374+
)
357375
chunksize = 10 if "minute" in url.lower() else 1
358376
seq_ids = list(range(src_start_seq, src_end_seq + 1))
359377
_process_all(
@@ -365,6 +383,7 @@ def run(cfg: RunConfig) -> dict[str, Any]:
365383
label="changefiles",
366384
workers=max_workers,
367385
extra_iterables=(seq_ids,),
386+
description="Processing changefiles",
368387
)
369388
dbmod.merge_parquet_files(conn, cf_dir, cleanup=True)
370389
upsert_state(
@@ -374,7 +393,7 @@ def run(cfg: RunConfig) -> dict[str, Any]:
374393
last_ts=url_end_date,
375394
updated_at=dt.datetime.now(UTC),
376395
)
377-
info(f"Done: {url}")
396+
info(f"Changefile processing complete: {url}")
378397

379398
if cfg.delete_temp:
380399
# Never rmtree cfg.cache_dir itself — it may be the user's platform cache root.

osmsg/ui.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def error(message: str) -> None:
2727

2828

2929
@contextmanager
30-
def progress_bar(total: int, unit: str = "items"):
30+
def progress_bar(total: int, unit: str = "items", description: str = "processing"):
3131
# transient=False keeps a one-line summary so cron logs / file-redirected stdout retain context.
3232
with Progress(
3333
TextColumn("[bold blue]{task.description}"),
@@ -37,7 +37,7 @@ def progress_bar(total: int, unit: str = "items"):
3737
console=console,
3838
transient=False,
3939
) as bar:
40-
task = bar.add_task("processing", total=total)
40+
task = bar.add_task(description, total=total)
4141

4242
def advance() -> None:
4343
bar.advance(task)

0 commit comments

Comments
 (0)