Spaces:
Runtime error
Runtime error
Update dockerfile
Browse files- Dockerfile +8 -10
- app.py +21 -1
Dockerfile
CHANGED
@@ -9,6 +9,8 @@ RUN apt-get update && \
|
|
9 |
wget \
|
10 |
curl \
|
11 |
# python build dependencies \
|
|
|
|
|
12 |
build-essential \
|
13 |
libssl-dev \
|
14 |
zlib1g-dev \
|
@@ -29,18 +31,14 @@ ENV HOME=/home/user \
|
|
29 |
PATH=/home/user/.local/bin:${PATH}
|
30 |
WORKDIR ${HOME}/app
|
31 |
|
32 |
-
RUN
|
33 |
-
ENV PATH=${HOME}/.pyenv/shims:${HOME}/.pyenv/bin:${PATH}
|
34 |
-
ARG PYTHON_VERSION=3.10.13
|
35 |
-
RUN pyenv install ${PYTHON_VERSION} && \
|
36 |
-
pyenv global ${PYTHON_VERSION} && \
|
37 |
-
pyenv rehash && \
|
38 |
-
pip install --no-cache-dir -U pip setuptools wheel && \
|
39 |
-
pip install "huggingface-hub" "hf-transfer" "gradio[oauth]>=4.28.0" "gradio_huggingfacehub_search==0.0.7" "APScheduler"
|
40 |
|
41 |
COPY --chown=1000 . ${HOME}/app
|
42 |
RUN git clone https://github.com/ggerganov/llama.cpp
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
ENV PYTHONPATH=${HOME}/app \
|
46 |
PYTHONUNBUFFERED=1 \
|
@@ -54,4 +52,4 @@ ENV PYTHONPATH=${HOME}/app \
|
|
54 |
SYSTEM=spaces
|
55 |
|
56 |
|
57 |
-
|
|
|
9 |
wget \
|
10 |
curl \
|
11 |
# python build dependencies \
|
12 |
+
python3 \
|
13 |
+
pip \
|
14 |
build-essential \
|
15 |
libssl-dev \
|
16 |
zlib1g-dev \
|
|
|
31 |
PATH=/home/user/.local/bin:${PATH}
|
32 |
WORKDIR ${HOME}/app
|
33 |
|
34 |
+
RUN pip3 install huggingface_hub transformers sentencepiece hf-transfer gradio[oauth]>=4.28.0 gradio_huggingfacehub_search==0.0.7 APScheduler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
COPY --chown=1000 . ${HOME}/app
|
37 |
RUN git clone https://github.com/ggerganov/llama.cpp
|
38 |
+
|
39 |
+
RUN cd llama.cpp && \
|
40 |
+
pip3 install -r requirements.txt && \
|
41 |
+
make -j
|
42 |
|
43 |
ENV PYTHONPATH=${HOME}/app \
|
44 |
PYTHONUNBUFFERED=1 \
|
|
|
52 |
SYSTEM=spaces
|
53 |
|
54 |
|
55 |
+
CMD ["python", "app.py"]
|
app.py
CHANGED
@@ -1,7 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
|
|
3 |
|
4 |
from huggingface_hub import HfApi, snapshot_download
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
api = HfApi()
|
7 |
|
@@ -12,7 +18,7 @@ def process_model(model_id: str, file_path: str, key: str, value: str, hf_token)
|
|
12 |
|
13 |
FILE_NAME = file_path.split("/")[-1]
|
14 |
|
15 |
-
snapshot_download(
|
16 |
repo_id=model_id,
|
17 |
allow_patterns=file_path,
|
18 |
local_dir=f"{MODEL_NAME}",
|
@@ -50,3 +56,17 @@ iface = gr.Interface(
|
|
50 |
|
51 |
# Launch the interface
|
52 |
iface.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import subprocess
|
3 |
+
import os
|
4 |
|
5 |
from huggingface_hub import HfApi, snapshot_download
|
6 |
+
from gradio_huggingfacehub_search import HuggingfaceHubSearch
|
7 |
+
|
8 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
9 |
+
|
10 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
11 |
|
12 |
api = HfApi()
|
13 |
|
|
|
18 |
|
19 |
FILE_NAME = file_path.split("/")[-1]
|
20 |
|
21 |
+
api.snapshot_download(
|
22 |
repo_id=model_id,
|
23 |
allow_patterns=file_path,
|
24 |
local_dir=f"{MODEL_NAME}",
|
|
|
56 |
|
57 |
# Launch the interface
|
58 |
iface.launch(debug=True)
|
59 |
+
|
60 |
+
|
61 |
+
def restart_space():
|
62 |
+
HfApi().restart_space(
|
63 |
+
repo_id="bartowski/gguf-metadata-updated", token=HF_TOKEN, factory_reboot=True
|
64 |
+
)
|
65 |
+
|
66 |
+
|
67 |
+
scheduler = BackgroundScheduler()
|
68 |
+
scheduler.add_job(restart_space, "interval", seconds=21600)
|
69 |
+
scheduler.start()
|
70 |
+
|
71 |
+
# Launch the interface
|
72 |
+
demo.queue(default_concurrency_limit=1, max_size=5).launch(debug=True, show_api=False)
|