Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25c3fe6730 | ||
|
|
d637ad39e4 | ||
|
|
5addd6a49b | ||
|
|
95f006078f | ||
|
|
4bb9251d7d | ||
|
|
6c6b175a28 | ||
|
|
c39646ceaa | ||
|
|
52c9284f85 | ||
|
|
419508dd5e | ||
|
|
689452cf4c | ||
|
|
e600d6cf7d | ||
|
|
10aa315e40 | ||
|
|
e3443e9f9f | ||
|
|
274d27c5bc | ||
|
|
f17e4f6c39 |
+3
-11
@@ -1,12 +1,5 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
ENV HOME=/app \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
STREAMLIT_SERVER_PORT=8501 \
|
||||
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
|
||||
STREAMLIT_SERVER_HEADLESS=true \
|
||||
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Systeem-dependency voor de HEALTHCHECK hieronder
|
||||
@@ -18,9 +11,8 @@ RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN chgrp -R 0 /app && chmod -R g=u /app
|
||||
|
||||
USER 1001
|
||||
EXPOSE 8501
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
||||
CMD ["streamlit", "run", "app.py"]
|
||||
|
||||
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
||||
|
||||
Vendored
-103
@@ -1,103 +0,0 @@
|
||||
pipeline {
|
||||
agent {
|
||||
label 'ssh-agent'
|
||||
}
|
||||
|
||||
|
||||
environment {
|
||||
REGISTRY = 'gitea.zb-kw.duckdns.org'
|
||||
IMAGE = "${REGISTRY}/willemjan/glucose-dashboard"
|
||||
OC_SERVER = 'https://api.rm1.0a51.p1.openshiftapps.com:6443'
|
||||
OC_PROJECT = 'wulsspaans-dev'
|
||||
}
|
||||
|
||||
options {
|
||||
buildDiscarder(logRotator(numToKeepStr: '20'))
|
||||
timeout(time: 20, unit: 'MINUTES')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
checkout scm
|
||||
script {
|
||||
env.TAG = sh(script: 'git rev-parse --short HEAD',
|
||||
returnStdout: true).trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh '''
|
||||
pip install --break-system-packages --no-warn-script-location -q -r requirements.txt
|
||||
python -m pytest -q --junitxml=report.xml
|
||||
'''
|
||||
}
|
||||
post {
|
||||
always { junit allowEmptyResults: true, testResults: 'report.xml' }
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build & push image') {
|
||||
steps {
|
||||
withCredentials([usernamePassword(
|
||||
credentialsId: 'gitea_user',
|
||||
usernameVariable: 'REG_USER',
|
||||
passwordVariable: 'REG_PASS')]) {
|
||||
sh '''
|
||||
echo "$REG_PASS" | docker login $REGISTRY -u "$REG_USER" --password-stdin
|
||||
docker build -t $IMAGE:$TAG -t $IMAGE:latest .
|
||||
docker push $IMAGE:$TAG
|
||||
docker push $IMAGE:latest
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Scan') {
|
||||
steps {
|
||||
sh '''
|
||||
docker run --rm \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v trivy-cache:/root/.cache/trivy \
|
||||
aquasec/trivy:latest image \
|
||||
--severity HIGH,CRITICAL \
|
||||
--ignore-unfixed \
|
||||
--exit-code 0 \
|
||||
$IMAGE:$TAG
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to OpenShift') {
|
||||
steps {
|
||||
withCredentials([string(
|
||||
credentialsId: 'openshift-token',
|
||||
variable: 'OC_TOKEN')]) {
|
||||
sh '''
|
||||
oc login --token="$OC_TOKEN" --server="$OC_SERVER"
|
||||
oc project $OC_PROJECT
|
||||
|
||||
oc apply -f openshift/service.yaml
|
||||
oc apply -f openshift/route.yaml
|
||||
oc apply -f openshift/configmap.yaml
|
||||
oc apply -f openshift/deployment.yaml
|
||||
|
||||
oc set image deployment/glucose-dashboard \
|
||||
glucose-dashboard=$IMAGE:$TAG
|
||||
|
||||
oc rollout status deployment/glucose-dashboard --timeout=5m
|
||||
'''
|
||||
}
|
||||
}
|
||||
post {
|
||||
always { sh 'oc logout || true' }
|
||||
success {
|
||||
sh 'echo "Deployed: $(oc get route glucose-dashboard -o jsonpath={.spec.host})" || true'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: glucose-dashboard-config
|
||||
data:
|
||||
NIGHTSCOUT_URL: "https://zb-ns.duckdns.org"
|
||||
@@ -1,35 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: glucose-dashboard
|
||||
labels:
|
||||
app: glucose-dashboard
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: glucose-dashboard
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: glucose-dashboard
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: gitea-registry
|
||||
containers:
|
||||
- name: glucose-dashboard
|
||||
image: PLACEHOLDER
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: glucose-dashboard-config
|
||||
ports:
|
||||
- containerPort: 8501
|
||||
resources:
|
||||
requests: { cpu: 100m, memory: 256Mi }
|
||||
limits: { cpu: 500m, memory: 512Mi }
|
||||
readinessProbe:
|
||||
httpGet: { path: /_stcore/health, port: 8501 }
|
||||
initialDelaySeconds: 10
|
||||
livenessProbe:
|
||||
httpGet: { path: /_stcore/health, port: 8501 }
|
||||
initialDelaySeconds: 30
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: route.openshift.io/v1
|
||||
kind: Route
|
||||
metadata:
|
||||
name: glucose-dashboard
|
||||
spec:
|
||||
to:
|
||||
kind: Service
|
||||
name: glucose-dashboard
|
||||
port:
|
||||
targetPort: 8501
|
||||
tls:
|
||||
termination: edge
|
||||
insecureEdgeTerminationPolicy: Redirect
|
||||
@@ -1,10 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: glucose-dashboard
|
||||
spec:
|
||||
selector:
|
||||
app: glucose-dashboard
|
||||
ports:
|
||||
- port: 8501
|
||||
targetPort: 8501
|
||||
@@ -4,7 +4,6 @@ import streamlit as st
|
||||
from auth import require_auth
|
||||
from nightscout_client import NightscoutConfigError
|
||||
from reporting import (
|
||||
gmi_mmol_per_mol,
|
||||
gmi_percent,
|
||||
percent_cv,
|
||||
sensor_active_percent,
|
||||
@@ -44,7 +43,6 @@ active_pct = sensor_active_percent(glucose, start, end)
|
||||
|
||||
mean_mmol = glucose["mmol"].mean()
|
||||
gmi = gmi_percent(mean_mmol)
|
||||
gmi_mmol_mol = gmi_mmol_per_mol(gmi)
|
||||
cv = percent_cv(glucose)
|
||||
tir = tir_breakdown_5band(glucose)
|
||||
|
||||
@@ -52,11 +50,7 @@ st.subheader("Kerncijfers")
|
||||
col1, col2, col3, col4 = st.columns(4)
|
||||
col1.metric("Sensordekking", f"{active_pct:.0f}%", help="Streefwaarde: ≥70%")
|
||||
col2.metric("Gemiddelde glucose", f"{mean_mmol:.1f} mmol/L")
|
||||
col3.metric(
|
||||
"Geschat HbA1c (GMI)",
|
||||
f"{gmi:.1f}% ({gmi_mmol_mol:.0f} mmol/mol)",
|
||||
help="Bergenstal et al. 2018 — geen labwaarde",
|
||||
)
|
||||
col3.metric("Geschat HbA1c (GMI)", f"{gmi:.1f}%", help="Bergenstal et al. 2018 — geen labwaarde")
|
||||
col4.metric("Variabiliteit (%CV)", f"{cv:.0f}%", help="Streefwaarde: ≤36%")
|
||||
|
||||
st.subheader("Tijd in bereik (5 klinische banden)")
|
||||
|
||||
+1
-3
@@ -28,7 +28,6 @@ from reporting import (
|
||||
agp_percentile_bands,
|
||||
completeness_warning,
|
||||
detect_events,
|
||||
gmi_mmol_per_mol,
|
||||
gmi_percent,
|
||||
percent_cv,
|
||||
sensor_active_percent,
|
||||
@@ -179,8 +178,7 @@ def _add_summary_section(pdf: FPDF, glucose: pd.DataFrame, start, end) -> None:
|
||||
pdf.set_font("Helvetica", "", 11)
|
||||
pdf.cell(0, 6, f"Sensordekking: {active_pct:.0f}%", **_LINE_KWARGS)
|
||||
pdf.cell(0, 6, f"Gemiddelde glucose: {mean_mmol:.1f} mmol/L", **_LINE_KWARGS)
|
||||
gmi = gmi_percent(mean_mmol)
|
||||
pdf.cell(0, 6, f"Geschat HbA1c (GMI): {gmi:.1f}% ({gmi_mmol_per_mol(gmi):.0f} mmol/mol)", **_LINE_KWARGS)
|
||||
pdf.cell(0, 6, f"Geschat HbA1c (GMI): {gmi_percent(mean_mmol):.1f}%", **_LINE_KWARGS)
|
||||
pdf.cell(0, 6, f"Variabiliteit (%CV): {percent_cv(glucose):.0f}%", **_LINE_KWARGS)
|
||||
pdf.ln(2)
|
||||
pdf.cell(0, 6, f"Zeer laag (<3.0 mmol/L): {tir['very_low']:.0f}%", **_LINE_KWARGS)
|
||||
|
||||
@@ -36,17 +36,6 @@ def gmi_percent(mean_mmol: float) -> float:
|
||||
return round(3.31 + 0.4311 * mean_mmol, 1)
|
||||
|
||||
|
||||
def gmi_mmol_per_mol(gmi_pct: float) -> int:
|
||||
"""Zet een GMI-percentage (DCCT/NGSP) om naar IFCC mmol/mol.
|
||||
|
||||
mmol/mol = 10.929 x (% - 2.15) — de standaard IFCC-omrekening
|
||||
(Hoelzel et al. 2004, Clin Chem 50(1):166-174), gangbare eenheid in
|
||||
Nederlandse labuitslagen naast het %-getal (gitea #25). Bijv. 6.5% =
|
||||
48 mmol/mol, de bekende diagnostische drempel.
|
||||
"""
|
||||
return round(10.929 * (gmi_pct - 2.15))
|
||||
|
||||
|
||||
GMI_TREND_COLUMNS = ["date", "gmi", "rolling_avg", "trend", "trend_lower", "trend_upper"]
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ from reporting import (
|
||||
daily_gmi,
|
||||
day_of_week_pattern,
|
||||
detect_events,
|
||||
gmi_mmol_per_mol,
|
||||
gmi_percent,
|
||||
gmi_trend,
|
||||
minutes_per_day,
|
||||
@@ -36,12 +35,6 @@ def test_gmi_percent_matches_bergenstal_formula():
|
||||
assert gmi_percent(7.0) == pytest.approx(6.3, abs=0.05)
|
||||
|
||||
|
||||
def test_gmi_mmol_per_mol_matches_known_ifcc_reference_values():
|
||||
# 6.5% is de bekende diagnostische drempel = 48 mmol/mol (IFCC).
|
||||
assert gmi_mmol_per_mol(6.5) == 48
|
||||
assert gmi_mmol_per_mol(7.0) == 53
|
||||
|
||||
|
||||
def test_daily_gmi_aggregates_per_calendar_day():
|
||||
glucose = _series(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user