Manish Kumar commited on
Commit
94de5c6
·
1 Parent(s): d51f47c

hf chnages new

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -11
  2. scripts/setup_model.py +28 -0
Dockerfile CHANGED
@@ -22,17 +22,8 @@ COPY backend/ ./backend/
22
  COPY --from=frontend-builder /frontend/dist ./frontend/dist
23
 
24
  # Pre-download model so container starts fast (avoids HF Spaces startup timeout)
25
- RUN python -c "
26
- import os
27
- os.makedirs('models', exist_ok=True)
28
- from huggingface_hub import hf_hub_download
29
- hf_hub_download(
30
- repo_id='bartowski/Qwen2.5-Coder-0.5B-Instruct-GGUF',
31
- filename='Qwen2.5-Coder-0.5B-Instruct-Q4_K_M.gguf',
32
- local_dir='models',
33
- local_dir_use_symlinks=False
34
- )
35
- "
36
 
37
  ENV PORT=8000 HOST=0.0.0.0 PYTHONPATH=/app
38
 
 
22
  COPY --from=frontend-builder /frontend/dist ./frontend/dist
23
 
24
  # Pre-download model so container starts fast (avoids HF Spaces startup timeout)
25
+ COPY scripts/setup_model.py /tmp/setup_model.py
26
+ RUN python /tmp/setup_model.py && rm /tmp/setup_model.py
 
 
 
 
 
 
 
 
 
27
 
28
  ENV PORT=8000 HOST=0.0.0.0 PYTHONPATH=/app
29
 
scripts/setup_model.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ def download_model():
6
+ """Download the required model for the application."""
7
+ try:
8
+ print("Creating models directory...")
9
+ os.makedirs('models', exist_ok=True)
10
+
11
+ print("Downloading model from Hugging Face...")
12
+ hf_hub_download(
13
+ repo_id='bartowski/Qwen2.5-Coder-0.5B-Instruct-GGUF',
14
+ filename='Qwen2.5-Coder-0.5B-Instruct-Q4_K_M.gguf',
15
+ local_dir='models',
16
+ local_dir_use_symlinks=False
17
+ )
18
+
19
+ print("Model downloaded successfully!")
20
+ return True
21
+
22
+ except Exception as e:
23
+ print(f"Error downloading model: {e}", file=sys.stderr)
24
+ return False
25
+
26
+ if __name__ == "__main__":
27
+ success = download_model()
28
+ sys.exit(0 if success else 1)