Spaces:
Running on Zero
Running on Zero
Michael Stattelman commited on
Commit ·
abdbb98
1
Parent(s): 9607e60
Added Nano Renemed
Browse files- .dockerignore +2 -1
- README.md +1 -1
- app/main.py +1 -1
- tests/test_space.py +21 -0
.dockerignore
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
|
|
|
|
|
| 1 |
**/__pycache__
|
| 2 |
**/*.pyc
|
| 3 |
.git
|
| 4 |
-
models/
|
| 5 |
.env
|
| 6 |
.env.*
|
| 7 |
!.env.example
|
|
|
|
| 1 |
+
# Do NOT list models/ here: a Gradio Space is built with Docker from this repo, so that would keep the Space's
|
| 2 |
+
# local models out of its image. The container's Dockerfile copies only app/ and tests/, so weights never enter it.
|
| 3 |
**/__pycache__
|
| 4 |
**/*.pyc
|
| 5 |
.git
|
|
|
|
| 6 |
.env
|
| 7 |
.env.*
|
| 8 |
!.env.example
|
README.md
CHANGED
|
@@ -81,7 +81,7 @@ cd <your-space>
|
|
| 81 |
git lfs install
|
| 82 |
# copy the contents of this DecisionLab folder into it (not the folder itself), then:
|
| 83 |
git add .
|
| 84 |
-
git commit -m "DecisionLab 2.2.
|
| 85 |
git push
|
| 86 |
```
|
| 87 |
|
|
|
|
| 81 |
git lfs install
|
| 82 |
# copy the contents of this DecisionLab folder into it (not the folder itself), then:
|
| 83 |
git add .
|
| 84 |
+
git commit -m "DecisionLab 2.2.1"
|
| 85 |
git push
|
| 86 |
```
|
| 87 |
|
app/main.py
CHANGED
|
@@ -27,7 +27,7 @@ MAX_BODY_BYTES = int(os.getenv("MAX_BODY_BYTES", str(256 * 1024)))
|
|
| 27 |
DECIDE_SLOTS = Gate(int(os.getenv("MAX_PENDING_DECIDES", "4"))) # DL-SA-004
|
| 28 |
|
| 29 |
# DL-SA-007: no /docs, /redoc or /openapi.json
|
| 30 |
-
VERSION = "2.2.
|
| 31 |
PAGE = stamp_assets((STATIC / "index.html").read_text(encoding="utf-8"), VERSION)
|
| 32 |
|
| 33 |
|
|
|
|
| 27 |
DECIDE_SLOTS = Gate(int(os.getenv("MAX_PENDING_DECIDES", "4"))) # DL-SA-004
|
| 28 |
|
| 29 |
# DL-SA-007: no /docs, /redoc or /openapi.json
|
| 30 |
+
VERSION = "2.2.1"
|
| 31 |
PAGE = stamp_assets((STATIC / "index.html").read_text(encoding="utf-8"), VERSION)
|
| 32 |
|
| 33 |
|
tests/test_space.py
CHANGED
|
@@ -107,3 +107,24 @@ class SpacePackagingTest(unittest.TestCase):
|
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
if __name__ == "__main__":
|
| 109 |
unittest.main()
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
@unittest.skipUnless((ROOT / "Dockerfile").is_file(), "packaging files are not in the image")
|
| 113 |
+
class ModelsFolderReachesTheSpaceTest(unittest.TestCase):
|
| 114 |
+
"""A Gradio Space is built with Docker from this repo, so .dockerignore applies to it. Excluding models/ there
|
| 115 |
+
kept the Space's local models out of its image (2.2.0, 2026-09-30)."""
|
| 116 |
+
|
| 117 |
+
def ignored(self):
|
| 118 |
+
return [l.strip() for l in (ROOT / ".dockerignore").read_text().splitlines() if l.strip() and not l.startswith("#")]
|
| 119 |
+
|
| 120 |
+
def test_dockerignore_does_not_exclude_the_models_folder(self):
|
| 121 |
+
for pattern in self.ignored():
|
| 122 |
+
with self.subTest(pattern=pattern):
|
| 123 |
+
self.assertFalse(pattern.rstrip("/").lstrip("./") in ("models", "models/*", "models/**"))
|
| 124 |
+
|
| 125 |
+
def test_the_container_image_still_leaves_models_out(self):
|
| 126 |
+
copies = [l for l in (ROOT / "Dockerfile").read_text().splitlines() if l.startswith(("COPY", "ADD"))]
|
| 127 |
+
for line in copies:
|
| 128 |
+
with self.subTest(line=line):
|
| 129 |
+
self.assertNotRegex(line, r"^(COPY|ADD)\s+(--\S+\s+)*\.\s") # no "COPY . ..."
|
| 130 |
+
self.assertNotIn("models", line)
|