Skip to content

fix(ci): share Overpass OSM cache across PRs and cap enrichment time - #58

Open
NAVIGUIDE-for-Berry-Mappemonde wants to merge 6 commits into
feat/integrate-poe-pipelinefrom
fix/ci-osm-cache-timeout
Open

NAVIGUIDE-for-Berry-Mappemonde wants to merge 6 commits into
feat/integrate-poe-pipelinefrom
fix/ci-osm-cache-timeout

Conversation

@NAVIGUIDE-for-Berry-Mappemonde

Copy link
Copy Markdown
Contributor

Diagnosis

  • .github/workflows/ci.yml triggers push: branches: [main], but the default branch is feat/integrate-poe-pipeline. So no run on the default branch ever saves the Overpass cache, and PR-scoped caches are not shared between PRs: every PR starts cold.
  • Cold, backend/scripts/enrich_ci_osm.py queries Overpass for 1169 ports (concurrency 3, up to 3 mirrors x 35 s httpx timeout each, 4 rounds) in each of the 6 shards -> hangs until the job timeout of 35 min.

Changes

  • ci.yml:
    • on: push on branches [main, feat/integrate-poe-pipeline] + workflow_dispatch:.
    • Step "Validation OSM réelle + scan d'anomalies": add timeout-minutes: 12.
    • Step "Sauvegarder le cache Overpass": save only if the file exists and is non-empty (if: always() && hashFiles('backend/.ci-cache/osm-ports.json') != '').
    • Between the restore and the validation: if backend/.ci-cache/osm-ports.json is missing after restore, copy the frozen snapshot backend/tests/fixtures/osm-ports.snapshot.json to it.
  • Frozen snapshot: new script backend/scripts/build_osm_snapshot.py generates backend/tests/fixtures/osm-ports.snapshot.json once with REAL Overpass answers (reuses overpass_around and the cache functions, resumable, reads seed/ports_of_entry.geojson, no Mongo). Running in background (nohup, log in ~/lots-live/fix-ci-bi/snapshot.log).
  • backend/scripts/enrich_ci_osm.py: add a global time budget (env CI_OSM_BUDGET_S, default 600): once exceeded, stop launching new Overpass queries, save the cache and exit with a clear message. Final refusals (missing ports / no anomaly) unchanged.
  • Flaky tests (tests only):
    • test_ml_jobs.py::test_validate_osm_non_destructive: limit 3 -> 1, wait_done timeout 180 -> 300.
    • test_ner_unclos_osm.py::test_validate_osm_status_progressing: instead of a single 8 s sample, poll every 2 s for up to 60 s; pass as soon as progress increases; skip (not fail) if the job finishes or stops running in the meantime.

Local validation

  • pytest backend/tests/test_enrich_ci_osm.py -> 4 passed.
  • python -c yaml.safe_load on ci.yml -> valid.

Snapshot status: running in background, partial warm cache committed if not finished within 45 min.

clement added 6 commits October 26, 2026 07:38
ci.yml:
- trigger on push to feat/integrate-poe-pipeline as well (default branch)
  plus workflow_dispatch so the default-branch run saves the Overpass cache
- add timeout-minutes: 12 to the OSM validation step
- save the cache only when the file exists and is non-empty
- copy the frozen snapshot backend/tests/fixtures/osm-ports.snapshot.json
  into the cache when missing after restore

enrich_ci_osm.py:
- add CI_OSM_BUDGET_S (default 600s): stop launching new Overpass queries
  once exceeded, save cache and exit cleanly; final refusals unchanged

tests:
- test_ml_jobs.py: limit 3 -> 1, wait_done timeout 180 -> 300
- test_ner_unclos_osm.py: poll every 2s up to 60s, skip if job stops

snapshot:
- add backend/scripts/build_osm_snapshot.py (resumable, real Overpass data)
… to 1

ci.yml:
- ne copier le snapshot figé que s'il existe et est non vide ([ -s ]), pour eviter le crash 'cp' sur fichier absent

build_osm_snapshot.py:
- concurrence reduite a 1 (Overpass autorise un seul slot par IP)
- flush du fichier JSON sur disque apres chaque lot de 2 ports (au lieu de 25)
- New osm-cache job queries Overpass once from GitHub runners, resumable,
  saves cache after each success, green only if all 1169 ports present.
- Six shards need osm-cache, run enrich_ci_osm.py in CI_OSM_OFFLINE=1 mode
  (no network, missing port = failure). Final refusals unchanged.
- Revert || echo and CI_OSM_BUDGET_S: 60 bypasses; drop the frozen
  12-port snapshot (stored failures as [] => fake data).
- build_osm_snapshot.py: --cache/--budget-s, concurrency 2, resume skips
  cached ports, stores only real answers (never failures), budget checked
  after acquiring the semaphore.
- Add unit tests: offline missing port = failed/no network; offline cached
  port validated; build_osm_snapshot stores nothing on failure; resume
  skips cached ports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant