diff --git a/Dockerfile b/Dockerfile index 3389a9a..0290680 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN apt-get update \ build-essential \ curl \ software-properties-common \ + git \ && rm -rf /var/lib/apt/lists/* COPY . . diff --git a/ngm/app.py b/ngm/app.py index fdf9c53..272e76c 100644 --- a/ngm/app.py +++ b/ngm/app.py @@ -1,3 +1,6 @@ +import subprocess +from typing import Optional + import altair as alt import numpy as np import polars as pl @@ -198,6 +201,21 @@ def summarize_scenario( c.altair_chart(chart, use_container_width=True) +def get_commit(length: int = 15) -> Optional[str]: + try: + x = subprocess.run( + ["git", "rev-parse", f"--short={length}", "HEAD"], capture_output=True + ) + if x.returncode == 0: + commit = x.stdout.decode().strip() + assert len(commit) == length + return commit + else: + return None + except FileNotFoundError: + return None + + def app(): st.info( "This interactive application is a prototype designed for software testing and educational purposes." @@ -275,6 +293,10 @@ def app(): help="Values are reported only to this many significant figures.", ) + commit = get_commit() + if commit is not None: + st.caption(f"App version: {commit}") + # # make and run scenarios ------------------------------------------------------------ group_names = params["Group name"] N = params["Pop. size"].to_numpy()