DLB: remove the 10-min wait-before-reporting sleep (replace with a datasette readiness check)
Type: Improvement
Background
build-digital-land-builder (prod only) contains a wait-before-reporting task that does time.sleep(600) between build-digital-land-builder and run-reporting-task. It exists to give datasette time to become consistent (pick up the freshly-built digital-land.sqlite3) before the reporting task queries it.
This is a fixed-time workaround, not a real readiness check: it adds 10 minutes of guaranteed dead time to every production run, regardless of whether datasette is actually ready sooner (usually it is) — or, in the worst case, still isn't ready after 10 minutes.
Code: dags/digital_land_builder.py (lines ~182–219)
def delay_execution(**kwargs):
time.sleep(600) # (10 minutes)
wait_before_reporting = PythonOperator(
task_id="wait-before-reporting",
python_callable=delay_execution,
dag=dag,
)
...
build_digital_land_builder >> wait_before_reporting >> run_reporting_task
Goal
Eliminate the fixed 10-minute delay by gating run-reporting-task on an actual datasette-readiness signal, so the reporting task starts as soon as datasette has picked up the new database (typically well under 10 minutes) and doesn't proceed if it genuinely hasn't.
Scope / tasks
- Identify what "datasette is ready / consistent" actually means here — i.e. what signal proves datasette is serving the freshly-built
digital-land.sqlite3 (e.g. datasette has reloaded the DB / a health or version endpoint reflects the new build / the expected table or row count is queryable).
- Replace
delay_execution with a polling sensor/check that waits for that signal, with:
- a sensible poll interval (e.g. 30s),
- a timeout (cap at, say, the current 10 min or a bit more) so a genuinely-stuck datasette fails loudly instead of the reporting task running against stale data,
- clear logging of how long it actually waited.
- Wire it in place of
wait-before-reporting (keep the build → wait → reporting ordering).
- Validate in staging/dev, then confirm in prod that the reporting task starts after a real readiness signal and typical wait time drops well below 10 min.
Acceptance criteria
- No fixed
time.sleep on the reporting path.
run-reporting-task starts only once datasette is confirmed ready, and starts as soon as it is.
- If readiness isn't reached within the timeout, the task fails (or alerts) rather than running against stale data.
- Observed prod wait time recorded before/after.
Notes / risks
- This is prod-only (the
wait_before_reporting / run_reporting_task block is inside if config["env"] == "production").
- Keep a timeout so removing the sleep doesn't turn an occasional slow-datasette into a silent stale-data reporting run — that's the one real risk the original sleep was guarding against.
- Airflow has built-in sensor patterns (
PythonSensor / @task.sensor with poke_interval + timeout) that fit this cleanly.
DLB: remove the 10-min
wait-before-reportingsleep (replace with a datasette readiness check)Type: Improvement
Background
build-digital-land-builder(prod only) contains await-before-reportingtask that doestime.sleep(600)betweenbuild-digital-land-builderandrun-reporting-task. It exists to give datasette time to become consistent (pick up the freshly-builtdigital-land.sqlite3) before the reporting task queries it.This is a fixed-time workaround, not a real readiness check: it adds 10 minutes of guaranteed dead time to every production run, regardless of whether datasette is actually ready sooner (usually it is) — or, in the worst case, still isn't ready after 10 minutes.
Code:
dags/digital_land_builder.py(lines ~182–219)Goal
Eliminate the fixed 10-minute delay by gating
run-reporting-taskon an actual datasette-readiness signal, so the reporting task starts as soon as datasette has picked up the new database (typically well under 10 minutes) and doesn't proceed if it genuinely hasn't.Scope / tasks
digital-land.sqlite3(e.g. datasette has reloaded the DB / a health or version endpoint reflects the new build / the expected table or row count is queryable).delay_executionwith a polling sensor/check that waits for that signal, with:wait-before-reporting(keep thebuild → wait → reportingordering).Acceptance criteria
time.sleepon the reporting path.run-reporting-taskstarts only once datasette is confirmed ready, and starts as soon as it is.Notes / risks
wait_before_reporting/run_reporting_taskblock is insideif config["env"] == "production").PythonSensor/@task.sensorwithpoke_interval+timeout) that fit this cleanly.