@@ -310,6 +310,25 @@ def _list_target_areas(target_dir=None):
310310 return areas
311311
312312
313+ def _time_of_newest_other_dependency ():
314+ """
315+ Return mtime of the newest non-target dependency that should
316+ invalidate cached area-weight files.
317+ """
318+ from tmd .areas import AREAS_FOLDER
319+ from tmd .storage import STORAGE_FOLDER
320+ from tmd .imputation_assumptions import POPULATION_FILE
321+
322+ deps = [
323+ AREAS_FOLDER / "create_area_weights.py" ,
324+ STORAGE_FOLDER / "output" / "tmd.csv.gz" ,
325+ STORAGE_FOLDER / "output" / "tmd_weights.csv.gz" ,
326+ STORAGE_FOLDER / "output" / "tmd_growfactors.csv" ,
327+ STORAGE_FOLDER / "input" / POPULATION_FILE ,
328+ ]
329+ return max (dpath .stat ().st_mtime for dpath in deps )
330+
331+
313332def _filter_areas (areas , area_filter ):
314333 """Filter areas by type: 'states', 'cds', or 'all'."""
315334 if area_filter == "all" :
@@ -366,9 +385,7 @@ def run_batch(
366385
367386 # Filter to out-of-date areas unless force=True
368387 if not force :
369- from tmd .areas .make_all import time_of_newest_other_dependency
370-
371- newest_dep = time_of_newest_other_dependency ()
388+ newest_dep = _time_of_newest_other_dependency ()
372389 todo = []
373390 for area in areas :
374391 wpath = weight_dir / f"{ area } _tmd_weights.csv.gz"
0 commit comments