Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show app version #77

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading