diff --git a/.vscode/launch.json b/.vscode/launch.json index 2188d71..d67b11d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -554,9 +554,12 @@ // Test --build_index for 2026 to test a fixed layout //"args": ["-v", "1", "--build_index", "--start", "20260101", "--end", "20261231", "--force"] // Test fixing the "folded" bathymetry - "args": ["-v", "1", "--dlist", "ahi/missionlogs/2026/20260218_20260220.dlist", "--force", "--update_ssds_provenance", "--notify", "mccann@mbari.org"] + //"args": ["-v", "1", "--dlist", "ahi/missionlogs/2026/20260218_20260220.dlist", "--force", "--update_ssds_provenance", "--notify", "mccann@mbari.org"] // Repair a badly plotted deployment with fixed bathymetry plotting - Pontus 54 Docking //"args": ["-v", "1", "--dlist", "pontus/missionlogs/2025/20250604_20250616.dlist"] + // Test caching and setting User-Agent for OSM tile server + "args": ["-v", "1", "--dlist", "pontus/missionlogs/2026/20260810_20260812.dlist"] + }, ] diff --git a/src/data/create_products.py b/src/data/create_products.py index b161a51..1b235cf 100755 --- a/src/data/create_products.py +++ b/src/data/create_products.py @@ -80,6 +80,18 @@ MISSIONODVS = "missionodvs" MISSIONIMAGES = "missionimages" +# Persist contextily's basemap tile cache across process invocations (it defaults to a +# per-session temp dir that's deleted on exit) so repeated/batch runs re-fetch far fewer +# tiles from OpenStreetMap, reducing exposure to its rate limiting (403s). +CONTEXTILY_CACHE_DIR = Path(BASE_PATH).parent / "contextily_cache" +CONTEXTILY_CACHE_DIR.mkdir(parents=True, exist_ok=True) +ctx.set_cache_dir(str(CONTEXTILY_CACHE_DIR)) + +# Identify ourselves to OpenStreetMap's tile servers per their usage policy +# (https://operations.osmfoundation.org/policies/tiles/), instead of contextily's +# default generic/anonymous User-Agent. +ctx.tile.USER_AGENT = "auv-python (https://github.com/mbari-org/auv-python; auv-python@mbari.org)" + class CreateProducts: logger = logging.getLogger(__name__) diff --git a/src/data/test_archive.py b/src/data/test_archive.py index 5f8fb46..bb88873 100644 --- a/src/data/test_archive.py +++ b/src/data/test_archive.py @@ -9,7 +9,7 @@ from archive import Archiver -@pytest.fixture() +@pytest.fixture() # noqa: PT001 def arch(): return Archiver(add_handlers=False, clobber=False)