Spaces:
Paused
Paused
feat(download_model.py): remove download_model.py during build, it causing big image size
Browse files- .gitignore +2 -1
- Dockerfile +7 -1
- openai_compatible_api_server.py +10 -0
.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
.idea
|
|
|
|
1 |
+
.idea
|
2 |
+
dep_size.txt
|
Dockerfile
CHANGED
@@ -6,6 +6,8 @@ ENV PATH="/home/user/.local/bin:$PATH"
|
|
6 |
|
7 |
WORKDIR /app
|
8 |
|
|
|
|
|
9 |
COPY --chown=user ./requirements.txt requirements.txt
|
10 |
RUN pip install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu113
|
11 |
|
@@ -23,7 +25,11 @@ COPY --chown=user . /app
|
|
23 |
#
|
24 |
# AFTER TRIAL AND ERROR WE GOT 16GB (16431849854 bytes) OF LAYERS :(
|
25 |
#
|
26 |
-
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true HF_TOKEN=$(cat /run/secrets/HF_TOKEN) python /app/download_model.py
|
|
|
|
|
|
|
|
|
27 |
|
28 |
EXPOSE 7860
|
29 |
|
|
|
6 |
|
7 |
WORKDIR /app
|
8 |
|
9 |
+
# revent python from generating .pyc files you don't need
|
10 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
11 |
COPY --chown=user ./requirements.txt requirements.txt
|
12 |
RUN pip install --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu113
|
13 |
|
|
|
25 |
#
|
26 |
# AFTER TRIAL AND ERROR WE GOT 16GB (16431849854 bytes) OF LAYERS :(
|
27 |
#
|
28 |
+
# RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true HF_TOKEN=$(cat /run/secrets/HF_TOKEN) python /app/download_model.py
|
29 |
+
|
30 |
+
# Getting the biggest dependencies
|
31 |
+
# https://stackoverflow.com/a/78014074
|
32 |
+
RUN python -c "for d in __import__('importlib.metadata').metadata.distributions(): print('{:>12.3f} KiB {}'.format(sum(0 if not f.locate().is_file() else f.locate().stat().st_size for f in d.files) / 1024, d.name))" | sort > dep_sizes.txt
|
33 |
|
34 |
EXPOSE 7860
|
35 |
|
openai_compatible_api_server.py
CHANGED
@@ -287,6 +287,16 @@ def engine_client(request: Request) -> EngineClient:
|
|
287 |
return request.app.state.engine_client
|
288 |
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
@router.get("/health")
|
291 |
async def health(raw_request: Request) -> Response:
|
292 |
"""Health check."""
|
|
|
287 |
return request.app.state.engine_client
|
288 |
|
289 |
|
290 |
+
@router.get("/")
|
291 |
+
async def home(raw_request: Request) -> Response:
|
292 |
+
dep_sizes: str = ""
|
293 |
+
with open('/app/dep_sizes.txt', mode='r') as f:
|
294 |
+
dep_sizes = f.readline()
|
295 |
+
f.close()
|
296 |
+
|
297 |
+
return Response(status_code=200, content=dep_sizes)
|
298 |
+
|
299 |
+
|
300 |
@router.get("/health")
|
301 |
async def health(raw_request: Request) -> Response:
|
302 |
"""Health check."""
|