From d71c90a73d9ff28ab4adddfc2f5478bf01efa904 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Mon, 29 Jul 2024 18:37:46 +0000 Subject: [PATCH] fix: only delete old map layers at beginning of dataset ingest --- sample_data/use_cases/new_york_energy/import_networks.py | 3 ++- sample_data/use_cases/new_york_energy/nysdp.py | 1 + uvdat/core/tasks/networks.py | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sample_data/use_cases/new_york_energy/import_networks.py b/sample_data/use_cases/new_york_energy/import_networks.py index 88798f7d..89b4298e 100644 --- a/sample_data/use_cases/new_york_energy/import_networks.py +++ b/sample_data/use_cases/new_york_energy/import_networks.py @@ -8,7 +8,7 @@ from django.contrib.gis.measure import D from django.contrib.gis.db.models.functions import Distance from django.contrib.gis.geos import Point, LineString -from uvdat.core.models import Network, NetworkEdge, NetworkNode +from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorMapLayer from uvdat.core.tasks.networks import vector_features_from_network @@ -75,6 +75,7 @@ def perform_import(dataset, **kwargs): print('\tEstimated time: 90 minutes.') start = datetime.now() Network.objects.filter(dataset=dataset).delete() + VectorMapLayer.objects.filter(dataset=network.dataset).delete() for file_item in dataset.source_files.all(): with tempfile.TemporaryDirectory() as temp_dir: archive_path = Path(temp_dir, 'archive.zip') diff --git a/sample_data/use_cases/new_york_energy/nysdp.py b/sample_data/use_cases/new_york_energy/nysdp.py index fc69324b..7fb7217a 100644 --- a/sample_data/use_cases/new_york_energy/nysdp.py +++ b/sample_data/use_cases/new_york_energy/nysdp.py @@ -123,6 +123,7 @@ def download_all_deduped_vector_features(**kwargs): def create_consolidated_network(dataset, **kwargs): start = datetime.now() Network.objects.filter(dataset=dataset).delete() + VectorMapLayer.objects.filter(dataset=network.dataset).delete() gdf = download_all_deduped_vector_features(**kwargs) zones_dataset_name = kwargs.get('zones_dataset_name') diff --git a/uvdat/core/tasks/networks.py b/uvdat/core/tasks/networks.py index 2c2ec9e4..48ceb845 100644 --- a/uvdat/core/tasks/networks.py +++ b/uvdat/core/tasks/networks.py @@ -6,7 +6,7 @@ import numpy import shapely -from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorFeature, VectorMapLayer +from uvdat.core.models import Network, NetworkEdge, NetworkNode, VectorFeature NODE_RECOVERY_MODES = [ 'random', @@ -214,7 +214,6 @@ def geojson_from_network(dataset): def vector_features_from_network(network): - VectorMapLayer.objects.filter(dataset=network.dataset).delete() map_layer, created = VectorMapLayer.objects.get_or_create(dataset=network.dataset, index=0) VectorFeature.objects.bulk_create( [