Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ frontend:
cd $(FRONTEND_DIR) && pnpm dev

export-schema:
cd $(BACKEND_DIR) && uv run python export_openapi.py
cd $(BACKEND_DIR) && uv run python -m scripts.export_openapi

generate-client: $(OPENAPI_JSON)
cd $(FRONTEND_DIR) && pnpm generate-client

openapi: export-schema generate-client
$(OPENAPI_JSON): $(BACKEND_DIR)/app/main.py $(BACKEND_DIR)/scripts/export_openapi.py
cd $(BACKEND_DIR) && uv run python -m scripts.export_openapi

$(OPENAPI_JSON): $(BACKEND_DIR)/app/main.py $(BACKEND_DIR)/export_openapi.py
cd $(BACKEND_DIR) && uv run python export_openapi.py
openapi: export-schema generate-client

install-backend:
cd $(BACKEND_DIR) && uv sync
Expand Down
18 changes: 14 additions & 4 deletions backend/app/route_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from geojson_pydantic import LineString as PydanticLineString
from geojson_pydantic import Point as PydanticPoint
from geojson_pydantic.types import Position2D, Position3D
from networkx.exception import NetworkXNoPath

from app.costs import (
FALLBACK_EDGE_COST,
Expand Down Expand Up @@ -54,6 +53,10 @@
type NearestNodeFunction = Callable[..., int]


class ParetoSearchLimitExceededError(RuntimeError):
"""Raised when bounded Pareto search exhausts its label budget."""


@dataclass(frozen=True, slots=True)
class RouteCandidate:
"""A fully resolved route candidate ready for response serialization."""
Expand Down Expand Up @@ -580,7 +583,12 @@ def _build_pareto_route_candidates(
)

if not destination_label_ids:
raise NetworkXNoPath
error_message = (
"Bounded Pareto search did not find a destination label before reaching "
"the configured label limit."
)

raise ParetoSearchLimitExceededError(error_message)

ranked_label_ids = sorted(
destination_label_ids,
Expand Down Expand Up @@ -826,8 +834,10 @@ def build_route_feature_collection(
destination_node_id,
route_options,
)
except NetworkXNoPath:
raise HTTPException(status_code=500, detail="No path found.") from None
except ParetoSearchLimitExceededError as exception:
raise HTTPException(
status_code=500, detail=f"Path calculation failed: {exception}"
) from None
except Exception as exception: # pragma: no cover - library failure path
raise HTTPException(
status_code=500,
Expand Down
8 changes: 6 additions & 2 deletions backend/notebooks/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,19 @@
"cell_type": "code",
"id": "786fa2b4142c599f",
"metadata": {},
"source": "fig, ax = ox.plot.plot_graph(GRAPH_CYCLING)",
"source": [
"fig, ax = ox.plot.plot_graph(GRAPH_CYCLING)"
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"id": "ebb5dc7e6caf7817",
"metadata": {},
"source": "list(GRAPH_CYCLING.edges(keys=True, data=True))[34]",
"source": [
"list(GRAPH_CYCLING.edges(keys=True, data=True))[34]"
],
"outputs": [],
"execution_count": null
},
Expand Down
3 changes: 2 additions & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies = [
dev = [
"basedpyright>=1.38.2",
"jupyterlab>=4.5.4",
"matplotlib>=3.10.9",
"pytest>=9.0.2",
"pytest-cov>=7.0.0",
"ruff>=0.15.0",
Expand Down Expand Up @@ -50,7 +51,7 @@ convention = "google"

[tool.basedpyright]
typeCheckingMode = "all"
include = ["app", "tests", "export_openapi.py"]
include = ["app", "tests", "scripts"]
exclude = ["notebooks"]
venvPath = "."
venv = ".venv"
Expand Down
1 change: 1 addition & 0 deletions backend/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Evaluation scripts."""
File renamed without changes.
Loading
Loading