Skip to content

Commit 89647c9

Browse files
authored
Merge pull request #323 from tilezen/check-metatile-first
Add option to check for metatile before processing
2 parents a0ed6e9 + bfaacfa commit 89647c9

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

config.yaml.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,5 @@ batch:
386386
job-queue: <job-queue>
387387
# optional number of retry attempts, overrides job definition value
388388
retry-attempts: 5
389+
# check store if metatile already exists, and if so skip processing
390+
check-metatile-exists: true

tilequeue/command.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,8 @@ def tilequeue_batch_process(cfg, args):
19481948
queue_zoom = batch_yaml.get('queue-zoom')
19491949
assert queue_zoom, 'Missing batch queue-zoom config'
19501950

1951+
check_metatile_exists = bool(batch_yaml.get('check-metatile-exists'))
1952+
19511953
queue_coord = deserialize_coord(coord_str)
19521954
if not queue_coord:
19531955
print >> sys.stderr, 'Invalid coordinate: %s' % coord_str
@@ -1996,6 +1998,10 @@ def find_job_coords_for(coord, target_zoom):
19961998

19971999
batch_logger.begin_run(queue_coord)
19982000

2001+
layer = 'all'
2002+
zip_format = lookup_format_by_extension('zip')
2003+
assert zip_format
2004+
19992005
job_coords = find_job_coords_for(queue_coord, group_by_zoom)
20002006
for job_coord in job_coords:
20012007

@@ -2017,6 +2023,12 @@ def find_job_coords_for(coord, target_zoom):
20172023
nominal_zoom = coord.zoom + cfg.metatile_zoom
20182024
unpadded_bounds = coord_to_mercator_bounds(coord)
20192025

2026+
if check_metatile_exists:
2027+
existing_data = store.read_tile(coord, zip_format, layer)
2028+
if existing_data is not None:
2029+
batch_logger.metatile_already_exists(coord)
2030+
continue
2031+
20202032
try:
20212033
source_rows = fetch(nominal_zoom, unpadded_bounds)
20222034
feature_layers = convert_source_data_to_feature_layers(

tilequeue/log.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,6 @@ def tile_process_failed(self, exception, coord):
318318

319319
def metatile_storage_failed(self, exception, coord):
320320
self._log_exception('metatile storage failed', exception, coord)
321+
322+
def metatile_already_exists(self, coord):
323+
self._log('metatile already exists', coord)

0 commit comments

Comments
 (0)