Sam commited on
Commit
7127ef3
·
1 Parent(s): 52319cd

Remove root app.py shim; force --only-binary for torch install

Browse files

The root app.py was a workaround for an analyzer issue. The real entry
point is still server/app.py and the Dockerfile starts it via uvicorn.
Forcing --only-binary=:all: on the torch install prevents pep 517 source
builds that depend on flit_core<4,>=3.11 (unavailable in the HF build
env). Also pins typing-extensions>=4.10.0 to a version with a properly
named prebuilt wheel.

Files changed (3) hide show
  1. Dockerfile +4 -4
  2. README.md +1 -1
  3. app.py +0 -33
Dockerfile CHANGED
@@ -13,11 +13,11 @@ curl \
13
 
14
  # Pin torch to CPU-only slim wheel FIRST — prevents pip from pulling the 2.4 GB CUDA build.
15
  # Must be installed before sentence-transformers / bert-score resolve their torch dep.
16
- # 2.4.0 ships prebuilt metadata for the modern PEP 517 build flow; 2.2.2+cpu fails because
17
- # its build deps require flit_core<4,>=3.11 which is no longer resolvable in the current
18
- # HF build environment.
19
- RUN pip install --no-cache-dir \
20
  torch==2.4.0+cpu \
 
21
  --index-url https://download.pytorch.org/whl/cpu
22
 
23
  # Install remaining dependencies
 
13
 
14
  # Pin torch to CPU-only slim wheel FIRST — prevents pip from pulling the 2.4 GB CUDA build.
15
  # Must be installed before sentence-transformers / bert-score resolve their torch dep.
16
+ # --only-binary=:all: forces pip to use prebuilt wheels only; this avoids the PEP 517 source
17
+ # build path that pulls flit_core<4,>=3.11 (unresolved in modern HF build envs).
18
+ RUN pip install --no-cache-dir --only-binary=:all: \
 
19
  torch==2.4.0+cpu \
20
+ typing-extensions>=4.10.0 \
21
  --index-url https://download.pytorch.org/whl/cpu
22
 
23
  # Install remaining dependencies
README.md CHANGED
@@ -5,7 +5,7 @@ colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
  app_port: 7860
8
- app_file: app.py
9
  pinned: true
10
  tags:
11
  - openenv
 
5
  colorTo: green
6
  sdk: docker
7
  app_port: 7860
8
+
9
  pinned: true
10
  tags:
11
  - openenv
app.py DELETED
@@ -1,33 +0,0 @@
1
- """Root-level app entry point for HF Spaces.
2
-
3
- The actual FastAPI application lives in `server/app.py`. This shim re-exports
4
- the `app` object so HF Spaces (which expects `app.py` at the repo root) can
5
- discover the entry point. The Dockerfile starts the server with:
6
-
7
- uvicorn server.app:app --host 0.0.0.0 --port 7860
8
-
9
- so this file is only used by the HF Space UI's static analyzer.
10
-
11
- Note: this file intentionally does NOT import `server.app` at module load.
12
- Importing it eagerly would load the dataset loader and ML models at build
13
- time, which is unnecessary and slow. The Dockerfile already starts the real
14
- app via uvicorn.
15
- """
16
-
17
- import sys
18
- import os
19
-
20
- # Allow `from server.app import app` to work when uvicorn mirrors this file
21
- sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
22
-
23
- __all__ = ["app"]
24
-
25
-
26
- def __getattr__(name):
27
- # Lazy re-export so that static analyzers (e.g. HF Space scanner) see
28
- # `app` here, but the heavy module only loads when something actually
29
- # imports it. `uvicorn server.app:app` does the real work.
30
- if name == "app":
31
- from server.app import app # noqa: WPS433
32
- return app
33
- raise AttributeError(f"module 'app' has no attribute {name!r}")