Skip to content

Commit

Permalink
Include rasterio.show_versions() output in healthz endpoint (#1056)
Browse files Browse the repository at this point in the history
* show rasterio versions in healthz endpoint

* simplify json versions returned

* adjust healtz test for new output

* fix tests

* update changelog

---------

Co-authored-by: vincentsarago <[email protected]>
  • Loading branch information
scottyhq and vincentsarago authored Dec 19, 2024
1 parent fb1bb1e commit 35b3a0b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
## Unreleased

### titiler.core

* Add layer control to map viewer template (author @hrodmn, https://github.com/developmentseed/titiler/pull/1051)

### titiler.application

* update `/healthz` endpoint to return dependencies versions (titiler, rasterio, gdal, ...) (author @scottyhq, https://github.com/developmentseed/titiler/pull/1056)

## 0.19.2 (2024-11-28)

### Misc
Expand Down
9 changes: 8 additions & 1 deletion src/titiler/application/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ def test_health(app):
"""Test /healthz endpoint."""
response = app.get("/healthz")
assert response.status_code == 200
assert response.json() == {"ping": "pong!"}
resp = response.json()
assert set(resp["versions"].keys()) == {
"titiler",
"gdal",
"geos",
"proj",
"rasterio",
}

response = app.get("/api")
assert response.status_code == 200
Expand Down
14 changes: 11 additions & 3 deletions src/titiler/application/titiler/application/main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""titiler app."""

import logging
import re

import jinja2
import rasterio
from fastapi import Depends, FastAPI, HTTPException, Security
from fastapi.security.api_key import APIKeyQuery
from rio_tiler.io import Reader, STACReader
Expand Down Expand Up @@ -213,9 +213,17 @@ def validate_access_token(access_token: str = Security(api_key_query)):
operation_id="healthCheck",
tags=["Health Check"],
)
def ping():
def application_health_check():
"""Health check."""
return {"ping": "pong!"}
return {
"versions": {
"titiler": titiler_version,
"rasterio": rasterio.__version__,
"gdal": rasterio.__gdal_version__,
"proj": rasterio.__proj_version__,
"geos": rasterio.__geos_version__,
}
}


@app.get("/", response_class=HTMLResponse, include_in_schema=False)
Expand Down

0 comments on commit 35b3a0b

Please sign in to comment.