Spaces:
Sleeping
Sleeping
collinschreyer-dev commited on
Commit ·
5a8f74f
1
Parent(s): 820827a
Show download files from first tile, update every 10 tiles
Browse files
app.py
CHANGED
|
@@ -597,29 +597,24 @@ def run_pipeline(
|
|
| 597 |
)
|
| 598 |
|
| 599 |
# Checkpoint: save downloadable files every N tiles
|
| 600 |
-
|
| 601 |
-
if (tile_idx + 1) %
|
| 602 |
temp_by_type = {}
|
| 603 |
for ft in feature_types:
|
| 604 |
ft_feats = [f for f in all_features if f["feature_type"] == ft]
|
| 605 |
if ft_feats:
|
| 606 |
temp_by_type[ft] = gpd.GeoDataFrame(ft_feats, crs=crs_obj)
|
|
|
|
|
|
|
|
|
|
| 607 |
if temp_by_type:
|
| 608 |
checkpoint_files = export_all(temp_by_type, tmp_dir)
|
| 609 |
-
dash += f"\n\n*Checkpoint saved at tile {tile_idx + 1} — files available for download below.*"
|
| 610 |
|
| 611 |
-
# Update overlay periodically
|
| 612 |
-
if (tile_idx + 1) % PREVIEW_INTERVAL == 0 or tile_idx == total_tiles - 1:
|
| 613 |
-
temp_by_type = {}
|
| 614 |
-
for ft in feature_types:
|
| 615 |
-
ft_feats = [f for f in all_features if f["feature_type"] == ft]
|
| 616 |
-
if ft_feats:
|
| 617 |
-
temp_by_type[ft] = gpd.GeoDataFrame(ft_feats, crs=crs_obj)
|
| 618 |
scanned = (scan_left, scan_bottom, scan_right, scan_top)
|
| 619 |
overlay = make_overlay(geotiff, temp_by_type, scanned_bounds=scanned)
|
| 620 |
yield overlay, dash, checkpoint_files
|
| 621 |
else:
|
| 622 |
-
yield gr.update(), dash,
|
| 623 |
|
| 624 |
# -- Deduplicate + filter --
|
| 625 |
elapsed = time.time() - start_time
|
|
|
|
| 597 |
)
|
| 598 |
|
| 599 |
# Checkpoint: save downloadable files every N tiles
|
| 600 |
+
# Update overlay + save files every PREVIEW_INTERVAL tiles
|
| 601 |
+
if (tile_idx + 1) % PREVIEW_INTERVAL == 0 or tile_idx == total_tiles - 1 or tile_idx == 0:
|
| 602 |
temp_by_type = {}
|
| 603 |
for ft in feature_types:
|
| 604 |
ft_feats = [f for f in all_features if f["feature_type"] == ft]
|
| 605 |
if ft_feats:
|
| 606 |
temp_by_type[ft] = gpd.GeoDataFrame(ft_feats, crs=crs_obj)
|
| 607 |
+
|
| 608 |
+
# Save files every update so they're always downloadable
|
| 609 |
+
checkpoint_files = None
|
| 610 |
if temp_by_type:
|
| 611 |
checkpoint_files = export_all(temp_by_type, tmp_dir)
|
|
|
|
| 612 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 613 |
scanned = (scan_left, scan_bottom, scan_right, scan_top)
|
| 614 |
overlay = make_overlay(geotiff, temp_by_type, scanned_bounds=scanned)
|
| 615 |
yield overlay, dash, checkpoint_files
|
| 616 |
else:
|
| 617 |
+
yield gr.update(), dash, gr.update()
|
| 618 |
|
| 619 |
# -- Deduplicate + filter --
|
| 620 |
elapsed = time.time() - start_time
|