diff --git a/api/app/routers/__pycache__/jobs.cpython-313.pyc b/api/app/routers/__pycache__/jobs.cpython-313.pyc index 134ea2f..9de8636 100644 Binary files a/api/app/routers/__pycache__/jobs.cpython-313.pyc and b/api/app/routers/__pycache__/jobs.cpython-313.pyc differ diff --git a/api/app/routers/jobs.py b/api/app/routers/jobs.py index f4d235c..93f2ff2 100644 --- a/api/app/routers/jobs.py +++ b/api/app/routers/jobs.py @@ -23,7 +23,9 @@ def _artifact_path(job_id: str) -> Path: status_code=status.HTTP_409_CONFLICT, detail={"code": "JOB_NOT_READY", "detail": "Job is not finished yet"}, ) - uri = (record.get("result") or {}).get("uri") + result = record.get("result") or {} + data = result.get("data") if isinstance(result.get("data"), dict) else {} + uri = result.get("uri") or data.get("uri") if not uri: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, diff --git a/api/tests/test_jobs_and_propagation.py b/api/tests/test_jobs_and_propagation.py index a0245e6..4075c86 100644 --- a/api/tests/test_jobs_and_propagation.py +++ b/api/tests/test_jobs_and_propagation.py @@ -1,6 +1,7 @@ from __future__ import annotations from pathlib import Path +from types import SimpleNamespace import pytest import rasterio @@ -8,6 +9,7 @@ import rasterio from app.core import coverage as coverage_core from app.core.antenna import AntennaPattern, gain from app.core.coverage import compute_coverage +from app.routers import jobs as jobs_router from app.core.surface import SurfaceProfile, SurfaceSample from app.core.vegetation import WORLDCOVER_P833, p833_coefficients_for_class from app.models.coverage import CoverageRequest @@ -24,6 +26,30 @@ def test_jobs_store_roundtrip() -> None: assert response.result == {"ok": True} +def test_job_artifact_path_supports_nested_coverage_uri( + monkeypatch: pytest.MonkeyPatch, + tmp_path: Path, +) -> None: + artifact = tmp_path / "coverage.png" + artifact.write_bytes(b"png") + job_id = jobs.create_job("coverage", {"model": "fspl"}) + jobs.update_job( + job_id, + status="done", + result={ + "kind": "coverage", + "data": {"kind": "coverage_raster", "uri": str(artifact)}, + }, + ) + monkeypatch.setattr( + jobs_router, + "get_settings", + lambda: SimpleNamespace(jobs_output_path=tmp_path), + ) + + assert jobs_router._artifact_path(job_id) == artifact.resolve() + + def test_coverage_fspl_geojson() -> None: request = _coverage_request(format="geojson", radius_m=5000, range_step_m=500) result = compute_coverage(request)