test(deploy): scan ENV lines only in MLflow kill-switch guard (avoid comment false-positive)
Browse files
tests/deploy/test_dockerfile_hf.py
CHANGED
|
@@ -62,14 +62,29 @@ class TestDockerfileHF:
|
|
| 62 |
)
|
| 63 |
|
| 64 |
def test_dockerfile_does_not_disable_mlflow(self, dockerfile_text):
|
| 65 |
-
"""The kill-switch
|
| 66 |
-
is built into the image and is safe to expose
|
| 67 |
-
demo. Re-introducing the kill-switch would
|
| 68 |
-
Experiments tab and the BBB provenance strip.
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
)
|
|
|
|
| 62 |
)
|
| 63 |
|
| 64 |
def test_dockerfile_does_not_disable_mlflow(self, dockerfile_text):
|
| 65 |
+
"""The MLflow kill-switch must be absent from the Dockerfile —
|
| 66 |
+
file-store mlruns/ is built into the image and is safe to expose
|
| 67 |
+
on the read-only demo. Re-introducing the kill-switch would
|
| 68 |
+
silently kill the Experiments tab and the BBB provenance strip.
|
| 69 |
+
|
| 70 |
+
Scan ENV lines only, not comment lines, so a future docstring or
|
| 71 |
+
comment that cites the env name does not false-positive.
|
| 72 |
+
"""
|
| 73 |
+
import re
|
| 74 |
+
|
| 75 |
+
env_lines = [
|
| 76 |
+
line
|
| 77 |
+
for line in dockerfile_text.splitlines()
|
| 78 |
+
if re.match(
|
| 79 |
+
r"\s*(ENV\s+)?NEUROBRIDGE_DISABLE_MLFLOW\s*=\s*1",
|
| 80 |
+
line,
|
| 81 |
+
re.IGNORECASE,
|
| 82 |
+
)
|
| 83 |
+
]
|
| 84 |
+
assert not env_lines, (
|
| 85 |
+
"Dockerfile must NOT set NEUROBRIDGE_DISABLE_MLFLOW=1 — that "
|
| 86 |
+
"empties the Experiments tab and blanks the BBB provenance "
|
| 87 |
+
"strip. If you need to disable MLflow at runtime, set the env "
|
| 88 |
+
"manually on the Space, do not bake it into the image. "
|
| 89 |
+
f"Offending lines: {env_lines}"
|
| 90 |
)
|