Skip to content

Commit

Permalink
Show app version (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
swo authored Jan 14, 2025
1 parent de3c0ae commit c28cc73
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RUN apt-get update \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*

COPY . .
Expand Down
22 changes: 22 additions & 0 deletions ngm/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import subprocess
from typing import Optional

import altair as alt
import numpy as np
import polars as pl
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c28cc73

Please sign in to comment.