File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 11import os
22from contextlib import asynccontextmanager
3+ from importlib .metadata import PackageNotFoundError , version
34
45from dotenv import dotenv_values
56from fastapi import FastAPI
@@ -74,7 +75,7 @@ async def lifespan(app: FastAPI):
7475
7576@app .get ("/" )
7677def public_route ():
77- return {"message" : "AAI Backend API" }
78+ return {"message" : "AAI Backend API" , "version" : SERVICE_VERSION }
7879
7980
8081app .include_router (admin .router )
@@ -85,3 +86,12 @@ def public_route():
8586app .include_router (sbp_register .router )
8687app .include_router (utils .router )
8788app .include_router (biocommons_groups .router )
89+ try :
90+ SERVICE_VERSION = version ("aai-backend" )
91+ except PackageNotFoundError :
92+ VERSION_FILE = os .path .join (os .path .dirname (__file__ ), "VERSION" )
93+ try :
94+ with open (VERSION_FILE , "r" , encoding = "utf-8" ) as version_fp :
95+ SERVICE_VERSION = version_fp .read ().strip ()
96+ except FileNotFoundError :
97+ SERVICE_VERSION = "unknown"
Original file line number Diff line number Diff line change 88def test_root (test_client ):
99 response = test_client .get ("/" )
1010 assert response .status_code == 200
11- assert response .json () == {"message" : "AAI Backend API" }
11+ assert response .json ()["message" ] == "AAI Backend API"
12+ assert response .json ().keys () == {"message" , "version" }
You can’t perform that action at this time.
0 commit comments