Skip to content

Commit

Permalink
Fix source/storage flip in generate tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
pnorman committed May 9, 2024
1 parent 12c672d commit ee07410
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
9 changes: 7 additions & 2 deletions tilekiln/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The code here pulls creates multiple kilns to generate the tiles in parallel
'''
import multiprocessing as mp
from typing import Iterable
from collections.abc import Collection

import psycopg

Expand Down Expand Up @@ -37,7 +37,12 @@ def worker(tile: Tile) -> None:


def generate(config: Config, source_kwargs, storage_kwargs, # type: ignore[no-untyped-def]
tiles: Iterable[Tile], num_processes: int) -> None:
tiles: Collection[Tile], num_processes: int) -> None:

# If there are no processes and no tiles then there's nothing to do.
if num_processes == 0 and len(tiles) == 0:
return

with mp.Pool(num_processes, setup, (config, source_kwargs, storage_kwargs)) as pool:
pool.imap_unordered(worker, tiles)
pool.close()
Expand Down
16 changes: 8 additions & 8 deletions tilekiln/scripts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def tiles(config: int, num_threads: int,

click.echo(f"Rendering {len(tiles)} tiles over {threads} threads")

source_kwargs = {"dbname": storage_dbname,
"host": storage_host,
"port": storage_port,
"user": storage_username}
storage_kwargs = {"dbname": source_dbname,
"host": source_host,
"port": source_port,
"user": source_username}
source_kwargs = {"dbname": source_dbname,
"host": source_host,
"port": source_port,
"user": source_username}
storage_kwargs = {"dbname": storage_dbname,
"host": storage_host,
"port": storage_port,
"user": storage_username}
tilekiln.generator.generate(c, source_kwargs, storage_kwargs, tqdm(tiles), threads)


Expand Down

0 comments on commit ee07410

Please sign in to comment.