1515
1616import httpx
1717
18- from app .services import stac as stac_service
19- from app .services import imagery as imagery_service
2018from app .services import demographics as demographics_service
19+ from app .services import imagery as imagery_service
2120from app .services import property_events as property_events_service
21+ from app .services import stac as stac_service
2222from app .services .address_normalizer import extract_search_terms , is_address_match
23- from app .services .county_adapters import get_adapter_for_county
2423from app .services .census import (
2524 ACS5_YEARS ,
2625 DECENNIAL_YEARS ,
2726 CensusApiError ,
2827 CensusFetcher ,
2928 parse_tract_fips ,
3029)
30+ from app .services .county_adapters import get_adapter_for_county
3131from app .tasks .celery_app import celery_app
3232
3333logger = logging .getLogger (__name__ )
@@ -148,6 +148,7 @@ async def _fetch_source(
148148 with SessionLocal () as db :
149149 # Find and update the task row
150150 from sqlalchemy import select as sa_select
151+
151152 from app .models .parcels import TimelineRequest , TimelineRequestTask
152153
153154 request = db .execute (
@@ -215,9 +216,10 @@ async def _fetch_source(
215216 extra = {"error" : str (exc )},
216217 )
217218 with SessionLocal () as db :
218- from app .models .parcels import TimelineRequestTask
219219 from sqlalchemy import select as sa_select
220220
221+ from app .models .parcels import TimelineRequestTask
222+
221223 task_row = db .execute (
222224 sa_select (TimelineRequestTask )
223225 .where (TimelineRequestTask .timeline_request_id == timeline_request_id )
@@ -300,9 +302,10 @@ async def _fetch_source(
300302 items_saved += 1
301303
302304 # Update task status
303- from app .models .parcels import TimelineRequestTask
304305 from sqlalchemy import select as sa_select
305306
307+ from app .models .parcels import TimelineRequestTask
308+
306309 task_row = db .execute (
307310 sa_select (TimelineRequestTask )
308311 .where (TimelineRequestTask .timeline_request_id == timeline_request_id )
@@ -331,9 +334,10 @@ async def _fetch_census(
331334
332335 Returns the number of census snapshots saved.
333336 """
337+ from sqlalchemy import select as sa_select
338+
334339 from app .db import SessionLocal
335340 from app .models .parcels import TimelineRequestTask
336- from sqlalchemy import select as sa_select
337341
338342 try :
339343 state_fips , county_fips , tract_code = parse_tract_fips (tract_fips )
@@ -427,7 +431,7 @@ async def _fetch_census(
427431 db , task_row , "complete" , items_found = items_saved
428432 )
429433
430- logger .info (f "Census fetch complete" , extra = {"items_saved" : items_saved , "tract" : tract_fips })
434+ logger .info ("Census fetch complete" , extra = {"items_saved" : items_saved , "tract" : tract_fips })
431435 return items_saved
432436
433437
@@ -442,9 +446,10 @@ async def _fetch_property(
442446
443447 Returns the number of events saved.
444448 """
449+ from sqlalchemy import select as sa_select
450+
445451 from app .db import SessionLocal
446452 from app .models .parcels import TimelineRequestTask
447- from sqlalchemy import select as sa_select
448453
449454 adapter = get_adapter_for_county (county )
450455
@@ -587,9 +592,10 @@ async def _fetch_property(
587592
588593async def _run_timeline (timeline_request_id : str ) -> dict [str , Any ]:
589594 """Orchestrate all imagery sources for a timeline request."""
595+ from sqlalchemy import select as sa_select
596+
590597 from app .db import SessionLocal
591598 from app .models .parcels import TimelineRequest
592- from sqlalchemy import select as sa_select
593599
594600 req_uuid = uuid .UUID (timeline_request_id )
595601
0 commit comments