diff --git a/horao/__init__.py b/horao/__init__.py index d7d0243..48c8783 100644 --- a/horao/__init__.py +++ b/horao/__init__.py @@ -9,6 +9,7 @@ """ import logging import os +from pathlib import Path from typing import Optional from opentelemetry import metrics, trace # type: ignore @@ -95,6 +96,14 @@ metrics.set_meter_provider(meter_provider) +def get_project_root() -> Path: + """ + Get the project root + :return: path to project root + """ + return Path(__file__).parent + + def init(authorization: Optional[AuthenticationBackend] = None) -> Starlette: """ Initialize the API @@ -149,7 +158,7 @@ def init(authorization: Optional[AuthenticationBackend] = None) -> Starlette: title="Horao", specification_url="/spec/", redoc_url="/docs/", - template="openapi/openapi.yml", + template=str(Path.joinpath(get_project_root(), "openapi/openapi.yml")), ) apiman.init_app(app) if os.getenv("TELEMETRY", "ON") == "OFF": diff --git a/horao/api/user_actions.py b/horao/api/user_actions.py index 962a23d..d8874d6 100644 --- a/horao/api/user_actions.py +++ b/horao/api/user_actions.py @@ -132,7 +132,7 @@ async def create_reservation(request: Request) -> JSONResponse: "500": description: Error processing reservation """ - logging.debug(f"Calling Reservations ({request})") + logging.debug(f"Creating Reservation ({request})") try: data = await request.json() claim = json.loads(data, cls=HoraoDecoder) diff --git a/horao/controllers/synchronization.py b/horao/controllers/synchronization.py index 5a9f552..bbe3d1e 100644 --- a/horao/controllers/synchronization.py +++ b/horao/controllers/synchronization.py @@ -62,7 +62,7 @@ def synchronize(self, changes: Optional[List] = None) -> datetime | None: will only call synchronize if there are any changes if the timer expires note: currently only the infrastructure is tracked, changes to claims and constraints are not tracked :param changes: optional list of changes - :return: None + :return: None (if nothing happened) or datetime if synchronized """ if not self.peers: return None