diff --git a/ai4papi/conf.py b/ai4papi/conf.py index b4d784c..09fa7a4 100644 --- a/ai4papi/conf.py +++ b/ai4papi/conf.py @@ -4,6 +4,7 @@ from pathlib import Path from string import Template +import subprocess import yaml @@ -79,3 +80,19 @@ def load_yaml_conf(fpath): 'values': yml[1], } } + + +# Retrieve git info from PAPI, to show current version in the docs +papi_commit = subprocess.run( + ['git', 'log', '-1', '--format=%H'], + stdout=subprocess.PIPE, + text=True, + cwd=main_path, + ).stdout.strip() +papi_branch = subprocess.run( + ['git', 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'], + stdout=subprocess.PIPE, + text=True, + cwd=main_path, + ).stdout.strip() +papi_branch = papi_branch.split('/')[-1] # remove the "origin/" part diff --git a/ai4papi/main.py b/ai4papi/main.py index 1bc94c9..89cbe2e 100644 --- a/ai4papi/main.py +++ b/ai4papi/main.py @@ -6,7 +6,7 @@ import fastapi import uvicorn -from ai4papi.conf import MAIN_CONF, paths +from ai4papi.conf import MAIN_CONF, paths, papi_branch, papi_commit from fastapi.responses import FileResponse from ai4papi.routers import v1 from ai4papi.routers.v1.stats.deployments import get_cluster_stats_bg @@ -39,7 +39,11 @@ "This work is co-funded by [AI4EOSC](https://ai4eosc.eu/) project that has " "received funding from the European Union's Horizon Europe 2022 research and " "innovation programme under agreement No 101058593" + "

" + "PAPI version:" + f"[`ai4-papi/{papi_branch}@{papi_commit[:5]}`]" + f"(https://github.com/ai4os/ai4-papi/tree/{papi_commit})" ) @asynccontextmanager