Spaces:
Running
Running
AAAS commited on
Commit Β·
a964887
0
Parent(s):
Initial commit
Browse files- .dockerignore +9 -0
- Dockerfile +46 -0
- README.md +18 -0
- bootstrap.py +51 -0
- requirements.txt +52 -0
.dockerignore
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
.gitignore
|
| 3 |
+
.dockerignore
|
| 4 |
+
README.md
|
| 5 |
+
__pycache__/
|
| 6 |
+
*.pyc
|
| 7 |
+
*.pyo
|
| 8 |
+
*.pyd
|
| 9 |
+
.DS_Store
|
Dockerfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ββ Base image ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
+
FROM python:3.10.12-slim-bookworm
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
|
| 6 |
+
# ββ System dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 7 |
+
# build toolchain for packages with C/Fortran extensions; OpenMP and BLAS for
|
| 8 |
+
# the numerical stack; pango/cairo/gdk-pixbuf/fontconfig for the PDF engine β
|
| 9 |
+
# without these the PDF renderer fails to import and downloads degrade to
|
| 10 |
+
# Markdown; curl for the health check; git for the hub client.
|
| 11 |
+
RUN apt-get update && apt-get install -y \
|
| 12 |
+
build-essential \
|
| 13 |
+
libgomp1 \
|
| 14 |
+
libopenblas-dev \
|
| 15 |
+
gfortran \
|
| 16 |
+
curl \
|
| 17 |
+
git \
|
| 18 |
+
libpango-1.0-0 \
|
| 19 |
+
libpangoft2-1.0-0 \
|
| 20 |
+
libpangocairo-1.0-0 \
|
| 21 |
+
libcairo2 \
|
| 22 |
+
libgdk-pixbuf-2.0-0 \
|
| 23 |
+
shared-mime-info \
|
| 24 |
+
fontconfig \
|
| 25 |
+
fonts-dejavu-core \
|
| 26 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 27 |
+
|
| 28 |
+
# ββ Python dependencies βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 29 |
+
# pip check fails the build on a dependency conflict; the version assert fails
|
| 30 |
+
# it if the base image is ever not exactly 3.10.12.
|
| 31 |
+
COPY requirements.txt .
|
| 32 |
+
RUN python -m pip install --no-cache-dir --default-timeout=120 -r requirements.txt \
|
| 33 |
+
&& python -m pip check \
|
| 34 |
+
&& python -c "import sys; assert sys.version_info[:3] == (3, 10, 12), sys.version; print('Verified Python:', sys.version)"
|
| 35 |
+
|
| 36 |
+
# ββ Bootstrap βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 37 |
+
# Only the launcher is baked into the image. The application and its artefacts
|
| 38 |
+
# are fetched at runtime from private repositories identified by secrets.
|
| 39 |
+
COPY bootstrap.py .
|
| 40 |
+
|
| 41 |
+
EXPOSE 8501
|
| 42 |
+
|
| 43 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
|
| 44 |
+
CMD curl --fail http://localhost:8501/_stcore/health || exit 1
|
| 45 |
+
|
| 46 |
+
ENTRYPOINT ["python", "bootstrap.py"]
|
README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Audit Accrual Anomaly Screening System
|
| 3 |
+
emoji: π¦
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
python_version: 3.10.12
|
| 8 |
+
app_port: 8501
|
| 9 |
+
pinned: false
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# AAAS β Accrual Anomaly Audit Screening
|
| 13 |
+
|
| 14 |
+
Forensic screening for audit prioritisation.
|
| 15 |
+
|
| 16 |
+
*Screening signals only β not audit evidence. Human review required.*
|
| 17 |
+
|
| 18 |
+
https://cappross.com
|
bootstrap.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import contextlib
|
| 2 |
+
import io
|
| 3 |
+
import logging
|
| 4 |
+
import os
|
| 5 |
+
import sys
|
| 6 |
+
from urllib.parse import quote
|
| 7 |
+
|
| 8 |
+
# Silence the HTTP stack before it is imported. It does not print by default β
|
| 9 |
+
# urllib3 logs at DEBUG and the root logger sits at WARNING β but any dependency
|
| 10 |
+
# that calls logging.basicConfig() at DEBUG or INFO turns that on, and what it
|
| 11 |
+
# then emits is the full request URL, which carries the private repository path.
|
| 12 |
+
# Space container logs are public on a public Space, so this cannot rest on a
|
| 13 |
+
# default staying put.
|
| 14 |
+
for _n in ("urllib3", "requests", "urllib3.connectionpool", "charset_normalizer"):
|
| 15 |
+
logging.getLogger(_n).setLevel(logging.CRITICAL)
|
| 16 |
+
logging.getLogger(_n).propagate = False
|
| 17 |
+
|
| 18 |
+
import requests
|
| 19 |
+
|
| 20 |
+
try:
|
| 21 |
+
token = os.environ["HF_TOKEN"]
|
| 22 |
+
source = os.environ["AAAS_SOURCE"]
|
| 23 |
+
revision = os.environ.get("AAAS_SOURCE_REVISION", "main")
|
| 24 |
+
|
| 25 |
+
url = (
|
| 26 |
+
f"https://huggingface.co/datasets/{quote(source, safe='/')}"
|
| 27 |
+
f"/resolve/{quote(revision, safe='')}/start.py"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# The request is made with stdout and stderr captured. Nothing the HTTP
|
| 31 |
+
# stack writes is safe to forward to a public log: on a failed lookup it can
|
| 32 |
+
# carry the full request URL, and that URL contains the private repository
|
| 33 |
+
# path. Anything captured here is discarded, not printed.
|
| 34 |
+
_sink_out, _sink_err = io.StringIO(), io.StringIO()
|
| 35 |
+
with contextlib.redirect_stdout(_sink_out), contextlib.redirect_stderr(_sink_err):
|
| 36 |
+
response = requests.get(
|
| 37 |
+
url,
|
| 38 |
+
headers={"Authorization": f"Bearer {token}"},
|
| 39 |
+
timeout=60,
|
| 40 |
+
)
|
| 41 |
+
response.raise_for_status()
|
| 42 |
+
|
| 43 |
+
path = "/tmp/.aaas_start.py"
|
| 44 |
+
with open(path, "wb") as f:
|
| 45 |
+
f.write(response.content)
|
| 46 |
+
|
| 47 |
+
os.execve(sys.executable, [sys.executable, path], os.environ.copy())
|
| 48 |
+
|
| 49 |
+
except Exception:
|
| 50 |
+
print("ERROR: application bootstrap unavailable.", flush=True)
|
| 51 |
+
sys.exit(1)
|
requirements.txt
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AAAS β runtime deps for the inference app.
|
| 2 |
+
# FULLY PINNED to the verified reference environment. Do not unpin: an unpinned
|
| 3 |
+
# file was the root cause of local-vs-deployment drift, because every rebuild
|
| 4 |
+
# silently installed different latest versions.
|
| 5 |
+
# The previous unpinned file was the root cause of the local-vs-Space drift:
|
| 6 |
+
# every rebuild silently installed different latest versions. Do not unpin.
|
| 7 |
+
|
| 8 |
+
# ββ UI (pin => identical widget DOM + CSS behaviour to local) ββββββββββββββββ
|
| 9 |
+
streamlit==1.50.0
|
| 10 |
+
|
| 11 |
+
# ββ numerics / ML (training stack; unpickle-compatible with the models) ββββββ
|
| 12 |
+
numpy==1.26.4
|
| 13 |
+
pandas==2.3.3
|
| 14 |
+
scikit-learn==1.7.2
|
| 15 |
+
xgboost==2.1.4
|
| 16 |
+
optbinning==0.20.1
|
| 17 |
+
|
| 18 |
+
# ββ optbinning / mathematical optimization chain
|
| 19 |
+
# Verified in the working Python 3.10.12 reference environment
|
| 20 |
+
ropwr==1.1.0
|
| 21 |
+
cvxpy==1.6.5
|
| 22 |
+
scipy==1.11.4
|
| 23 |
+
ortools==9.9.3963
|
| 24 |
+
|
| 25 |
+
# ββ CVXPY solver stack
|
| 26 |
+
clarabel==0.10.0
|
| 27 |
+
osqp==1.0.3
|
| 28 |
+
scs==3.2.7.post2
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
minisom==2.3.6
|
| 32 |
+
joblib==1.4.2
|
| 33 |
+
|
| 34 |
+
# ββ Arrow (21.0.0 verified with numpy 1.26.4; pyarrow 25.x SEGFAULTS in the
|
| 35 |
+
# st.dataframe conversion under numpy 1.26 β never unpin) ββββββββββββββββββ
|
| 36 |
+
pyarrow==21.0.0
|
| 37 |
+
|
| 38 |
+
# ββ plotting / runtime shims βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 39 |
+
matplotlib==3.7.3
|
| 40 |
+
ipython==8.36.0
|
| 41 |
+
|
| 42 |
+
# ββ Advisory Report PDF engine (was MISSING β "PDF engine unavailable") ββββββ
|
| 43 |
+
weasyprint==66.0 # requires the pango/cairo system libs (see Dockerfile)
|
| 44 |
+
markdown==3.8
|
| 45 |
+
reportlab==4.4.5 # secondary path; markdown download is the last resort
|
| 46 |
+
|
| 47 |
+
# ββ runtime artefact download from the private HF repos ββββββββββββββββββββββ
|
| 48 |
+
huggingface_hub==0.34.4
|
| 49 |
+
# bootstrap.py imports requests directly. It is also a dependency of
|
| 50 |
+
# huggingface_hub, so it installs today either way β pinned here so a future
|
| 51 |
+
# rebuild cannot drop it and leave the loader failing on an import.
|
| 52 |
+
requests==2.32.3
|