mohanz commited on
Commit
a8e6d06
·
1 Parent(s): acf163c

add cleanup and storage

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -1
  2. start.sh +45 -0
Dockerfile CHANGED
@@ -60,6 +60,10 @@ ENV PYTHONPATH=${HOME}/app \
60
  TQDM_MININTERVAL=1 \
61
  SYSTEM=spaces \
62
  LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} \
63
- PATH=/usr/local/nvidia/bin:${PATH}
 
 
 
 
64
 
65
  CMD ["/bin/bash", "start.sh"]
 
60
  TQDM_MININTERVAL=1 \
61
  SYSTEM=spaces \
62
  LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH} \
63
+ PATH=/usr/local/nvidia/bin:${PATH} \
64
+ # Storage management
65
+ HF_HUB_CACHE=/tmp/huggingface \
66
+ TRANSFORMERS_CACHE=/tmp/transformers \
67
+ TORCH_HOME=/tmp/torch
68
 
69
  CMD ["/bin/bash", "start.sh"]
start.sh CHANGED
@@ -1,5 +1,18 @@
1
  #!/bin/bash
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  if [ ! -d "llama.cpp" ]; then
4
  # only run in dev env
5
  git clone https://github.com/ggerganov/llama.cpp
@@ -18,4 +31,36 @@ cp ./build/bin/llama-* .
18
  rm -rf build
19
 
20
  cd ..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  python app.py
 
1
  #!/bin/bash
2
 
3
+ # Set up cache directories
4
+ export HF_HUB_CACHE=/tmp/huggingface
5
+ export TRANSFORMERS_CACHE=/tmp/transformers
6
+ export TORCH_HOME=/tmp/torch
7
+
8
+ # Clean up old cache files
9
+ echo "Cleaning up cache directories..."
10
+ rm -rf /tmp/huggingface/* /tmp/transformers/* /tmp/torch/* 2>/dev/null || true
11
+
12
+ # Clean up system temp files
13
+ echo "Cleaning up system temporary files..."
14
+ rm -rf /tmp/*.log /tmp/*.tmp /tmp/*.cache 2>/dev/null || true
15
+
16
  if [ ! -d "llama.cpp" ]; then
17
  # only run in dev env
18
  git clone https://github.com/ggerganov/llama.cpp
 
31
  rm -rf build
32
 
33
  cd ..
34
+
35
+ # Comprehensive cleanup before starting
36
+ echo "Performing comprehensive cleanup..."
37
+ # Clean Python cache files
38
+ find . -type f -name "*.pyc" -delete
39
+ find . -type f -name "*.pyo" -delete
40
+ find . -type f -name "*.pyd" -delete
41
+ find . -type d -name "__pycache__" -exec rm -r {} + 2>/dev/null || true
42
+ find . -type d -name ".pytest_cache" -exec rm -r {} + 2>/dev/null || true
43
+ find . -type d -name ".coverage" -exec rm -r {} + 2>/dev/null || true
44
+
45
+ # Clean temporary files
46
+ find . -type f -name "*.tmp" -delete
47
+ find . -type f -name "*.temp" -delete
48
+ find . -type f -name "*.log" -delete
49
+ find . -type f -name "*.cache" -delete
50
+
51
+ # Clean build artifacts
52
+ find . -type d -name "build" -exec rm -r {} + 2>/dev/null || true
53
+ find . -type d -name "dist" -exec rm -r {} + 2>/dev/null || true
54
+ find . -type d -name "*.egg-info" -exec rm -r {} + 2>/dev/null || true
55
+
56
+ # Clean downloads directory if it exists
57
+ if [ -d "downloads" ]; then
58
+ echo "Cleaning downloads directory..."
59
+ find downloads -type f -mtime +1 -delete 2>/dev/null || true
60
+ fi
61
+
62
+ # Clean up any remaining temporary files in the current directory
63
+ rm -f *.log *.tmp *.temp 2>/dev/null || true
64
+
65
+ echo "Cleanup completed. Starting application..."
66
  python app.py