Skip to content

Commit b059e04

Browse files
fix: fix version in health check (#68)
Adapt the `/health` health check endpoint logic to display the version used in dynamic versioning instead of the one previously hardcoded in `pyproject.toml`.
1 parent 60bac05 commit b059e04

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

api_tabular/utils.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import tomllib
21
from collections import defaultdict
2+
from importlib.metadata import version
33

44
import yaml
55
from aiohttp.web_request import Request
@@ -103,15 +103,11 @@ def is_aggregation_allowed(resource_id: str):
103103

104104

105105
async def get_app_version() -> str:
106-
"""Parse pyproject.toml and return the version or an error."""
106+
"""Get the version from the installed package metadata."""
107107
try:
108-
with open("pyproject.toml", "rb") as f:
109-
pyproject = tomllib.load(f)
110-
return pyproject.get("project", {}).get("version", "unknown")
111-
except FileNotFoundError:
112-
return "unknown (pyproject.toml not found)"
113-
except Exception as e:
114-
return f"unknown ({str(e)})"
108+
return version("udata-hydra-csvapi")
109+
except Exception:
110+
return "unknown"
115111

116112

117113
def build_sql_query_string(

0 commit comments

Comments
 (0)