Skip to content

Commit

Permalink
feat: add current PAPI branch+commit in the docs' description
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnacioHeredia committed Aug 19, 2024
1 parent 6964cbe commit c5bca42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions ai4papi/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pathlib import Path
from string import Template
import subprocess

import yaml

Expand Down Expand Up @@ -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
6 changes: 5 additions & 1 deletion ai4papi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
"<br><br>"

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

@asynccontextmanager
Expand Down

0 comments on commit c5bca42

Please sign in to comment.