Skip to content

Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)

fix(#10): hide stale search progress percentages (#377)

Cinna Davis643f630efea5
diff --git a/docs/PRODUCT.md b/docs/PRODUCT.md
index 7bd8d72..1299ef5 100644
--- a/docs/PRODUCT.md
+++ b/docs/PRODUCT.md
@@ -87,7 +87,13 @@ search, parallel workers, fine grids and continuous refinement. See
[country profiles](COUNTRIES.md) for boundary acquisition, offline use and limits.
`analyze` prints the job ID and a monitor command to standard error as soon as
-the upload is queued. `job --watch` reports the status-file progress field, the
+the upload is queued. Search progress is based on completed grid work and is
+persisted after a 2.5 percentage-point increase or at least every 15 seconds
+when another tile completes. A single long-running tile cannot report partial
+work it has not completed. The CLI and upload UI hide the percentage when an
+active job's status has not refreshed for 60 seconds; the job may still be
+processing.
+`job --watch` reports the status-file progress field, the
count/rate of matching coarse and fine search filenames, the newest matching
file modification age, and the job status-file age on standard error. These are
unverified filesystem indicators: the watcher does not validate payload hashes
diff --git a/src/dopplergeist/cli.py b/src/dopplergeist/cli.py
index 8a062f4..beb88dd 100644
--- a/src/dopplergeist/cli.py
+++ b/src/dopplergeist/cli.py
@@ -256,13 +256,15 @@ def main():
finally:
manager.close()
elif args.command=="job":
- from .jobs import read_json
+ from .jobs import read_json, status_for_display
directory=Path(args.jobs)/args.job_id
previous_count=previous_time=previous_fine_support_count=previous_split_count=None
+ stale_after=60.0
try:
while True:
try:
- value = read_json(directory/"result.json")
+ value = status_for_display(directory, read_json(directory/"result.json"),
+ stale_after_s=stale_after)
except (OSError, ValueError) as exc:
parser.error(f"Could not read job {args.job_id}: {exc}")
if not args.watch:
@@ -280,10 +282,12 @@ def main():
progress=value.get("progress")
result_age=max(0.0,wall_now-(directory/"result.json").stat().st_mtime)
age_text=lambda seconds: f"{seconds:.0f}s" if seconds<60 else f"{seconds/60:.1f}m"
- stale_after=max(60.0,args.interval*3)
- progress_stale=" (stale)" if result_age>stale_after else ""
- progress_text=(f", overall progress {progress:.1%}{progress_stale}"
- if isinstance(progress,(int,float)) and math.isfinite(progress) else "")
+ progress_stale=value.get("progress_stale", False)
+ if progress_stale:
+ progress_text=f", overall progress hidden (last update {age_text(result_age)} ago)"
+ else:
+ progress_text=(f", overall progress {progress:.1%}"
+ if isinstance(progress,(int,float)) and math.isfinite(progress) else "")
stage_message=value.get("message")
activity_text=(f", {stage_message}"
if value.get("stage") in {"acquisition", "search", "refinement", "decision"}
diff --git a/src/dopplergeist/jobs.py b/src/dopplergeist/jobs.py
index 4f1edc3..16e5c95 100644
--- a/src/dopplergeist/jobs.py
+++ b/src/dopplergeist/jobs.py
@@ -17,6 +17,7 @@ import uuid
from .contracts import validate_request, validate_result
TERMINAL = {"needs_input", "succeeded", "inconclusive", "failed", "cancelled"}
+PROGRESS_STALE_AFTER_S = 60.0
def write_json(path, value):
@@ -30,6 +31,23 @@ def read_json(path):
return json.loads(Path(path).read_text())
+def status_for_display(job_dir, value=None, *, stale_after_s=PROGRESS_STALE_AFTER_S):
+ """Hide active-job progress percentages when the persisted status is stale."""
+ path = Path(job_dir) / "result.json"
+ shown = dict(read_json(path) if value is None else value)
+ shown["progress_stale"] = False
+ if shown.get("status") in {"queued", "running"}:
+ age = max(0.0, time.time() - path.stat().st_mtime)
+ shown["progress_age_seconds"] = age
+ shown["progress_stale"] = age > stale_after_s
+ if shown["progress_stale"]:
+ shown["progress"] = None
+ shown["message"] = (
+ f"Job remains {shown['status']}; saved progress is stale and its percentage is hidden."
+ )
+ return shown
+
+
def result(job_dir, status, **fields):
value = validate_result(dict(schema_version=1, job_id=Path(job_dir).name, status=status, **fields))
write_json(Path(job_dir) / "result.json", value)
diff --git a/src/dopplergeist/service.py b/src/dopplergeist/service.py
index 7a8521b..e4fbc1f 100644
--- a/src/dopplergeist/service.py
+++ b/src/dopplergeist/service.py
@@ -69,7 +69,9 @@ class Handler(BaseHTTPRequestHandler):
if len(parts) >= 3 and parts[:2] == ["api", "jobs"]:
job_id = parts[2]
if self.command == "GET" and len(parts) == 3:
- return self._reply(manager.get(job_id))
+ from .jobs import status_for_display
+ directory = manager.directory(job_id)
+ return self._reply(status_for_display(directory, manager.get(job_id)))
if self.command == "GET" and parts[3:] == ["guidance"]:
from .guidance import explain_job
return self._reply(explain_job(manager.directory(job_id)))
diff --git a/src/dopplergeist/tiled_search.py b/src/dopplergeist/tiled_search.py
index c7230eb..3c456a6 100644
--- a/src/dopplergeist/tiled_search.py
+++ b/src/dopplergeist/tiled_search.py
@@ -900,15 +900,20 @@ def search_national(indexes, terrain, events, measurements, *, time_range_s, out
for _, cells in itertools.islice(
grid_tiles(bounds, budget.spacing_m, budget.tile_cells, crs), budget.max_tiles))
last_progress = 0.0
+ last_progress_report = time.monotonic()
def report_search_progress(fraction, *, force=False):
- nonlocal last_progress
+ nonlocal last_progress, last_progress_report
if search_progress is None:
return
fraction = min(1.0, max(0.0, float(fraction)))
- if fraction > last_progress and (force or fraction - last_progress >= 0.025):
+ now = time.monotonic()
+ if fraction > last_progress and (
+ force or fraction - last_progress >= 0.025 or now - last_progress_report >= 15.0
+ ):
search_progress(fraction)
last_progress = fraction
+ last_progress_report = now
available = len(os.sched_getaffinity(0)) if hasattr(os, "sched_getaffinity") else (os.cpu_count() or 1)
if workers is None:
diff --git a/src/dopplergeist/web/app.js b/src/dopplergeist/web/app.js
index ad75460..c76cbc3 100644
--- a/src/dopplergeist/web/app.js
+++ b/src/dopplergeist/web/app.js
@@ -121,10 +121,21 @@ function render(value) {
$('job-id').textContent = `JOB ${value.job_id}`;
$('status').textContent = value.status.replaceAll('_', ' ');
$('stage').textContent = value.stage || '';
- $('progress').value = value.progress || (terminal.has(value.status) ? 1 : 0);
+ const progress = $('progress');
+ if (value.progress_stale) {
+ progress.removeAttribute('value');
+ progress.setAttribute('aria-label', 'Progress unavailable because the saved percentage is stale');
+ } else {
+ progress.value = Number.isFinite(value.progress) ? value.progress : (terminal.has(value.status) ? 1 : 0);
+ progress.setAttribute('aria-label', 'Analysis progress');
+ }
$('cancel').hidden = terminal.has(value.status);
$('resume').hidden = true;
- $('message').textContent = value.message || 'Analysis is running. You can return to this job using its saved link.';
+ const staleAge = Number.isFinite(value.progress_age_seconds)
+ ? ` Last progress update was ${Math.floor(value.progress_age_seconds)} seconds ago.` : '';
+ $('message').textContent = value.progress_stale
+ ? `${value.message || 'The saved percentage is stale and hidden.'}${staleAge}`
+ : (value.message || 'Analysis is running. You can return to this job using its saved link.');
$('required').hidden = !value.required_fields?.length;
$('required').textContent = value.required_fields?.length ? `Required input: ${value.required_fields.join(', ')}. Add the evidence to a new analysis; this run is preserved.` : '';
$('guidance').replaceChildren(); $('guidance').hidden = true;