mutisya commited on
Commit
d7086f8
·
verified ·
1 Parent(s): 8dd852f

Deploy Polyglot backend with quantized models

Browse files
Files changed (2) hide show
  1. Dockerfile +4 -2
  2. download_code.py +9 -14
Dockerfile CHANGED
@@ -45,8 +45,10 @@ RUN mkdir -p $HF_HOME && chmod -R 777 $HF_HOME
45
  RUN mkdir -p $NLTK_DATA && chmod -R 777 $NLTK_DATA
46
  RUN mkdir -p $NUMBA_CACHE_DIR && chmod -R 777 $NUMBA_CACHE_DIR
47
 
48
- # Create app and data directories with write permissions for runtime code download
49
- RUN mkdir -p /app/app && chmod -R 777 /app/app
 
 
50
  RUN mkdir -p /app/data/learning/users && chmod -R 777 /app/data
51
 
52
  # Download models using HF token from environment
 
45
  RUN mkdir -p $NLTK_DATA && chmod -R 777 $NLTK_DATA
46
  RUN mkdir -p $NUMBA_CACHE_DIR && chmod -R 777 $NUMBA_CACHE_DIR
47
 
48
+ # Set write permissions on /app for runtime code download
49
+ RUN chmod -R 777 /app
50
+
51
+ # Create data directories for learning service
52
  RUN mkdir -p /app/data/learning/users && chmod -R 777 /app/data
53
 
54
  # Download models using HF token from environment
download_code.py CHANGED
@@ -34,27 +34,22 @@ def download_code(code_space_id, token):
34
 
35
  # Copy app directory
36
  if Path("/tmp/code_download/app").exists():
37
- # Remove existing app directory contents if present
38
- if Path("/app/app").exists() and list(Path("/app/app").iterdir()):
39
  shutil.rmtree("/app/app")
40
- Path("/app/app").mkdir(parents=True, exist_ok=True)
41
- shutil.copytree("/tmp/code_download/app", "/app/app", dirs_exist_ok=True)
42
  print("OK app/ directory copied")
43
  else:
44
  print("WARNING: app/ directory not found in code space")
45
 
46
  # Copy data directory
47
  if Path("/tmp/code_download/data").exists():
48
- # Remove existing data directory contents if present
49
- if Path("/app/data").exists() and list(Path("/app/data").iterdir()):
50
- # Preserve the learning/users directory structure
51
- for item in Path("/app/data").iterdir():
52
- if item.name != "learning":
53
- if item.is_dir():
54
- shutil.rmtree(item)
55
- else:
56
- item.unlink()
57
- shutil.copytree("/tmp/code_download/data", "/app/data", dirs_exist_ok=True)
58
  print("OK data/ directory copied")
59
  else:
60
  print("WARNING: data/ directory not found in code space")
 
34
 
35
  # Copy app directory
36
  if Path("/tmp/code_download/app").exists():
37
+ # Remove existing app directory if present
38
+ if Path("/app/app").exists():
39
  shutil.rmtree("/app/app")
40
+ # Copy the entire app directory
41
+ shutil.copytree("/tmp/code_download/app", "/app/app")
42
  print("OK app/ directory copied")
43
  else:
44
  print("WARNING: app/ directory not found in code space")
45
 
46
  # Copy data directory
47
  if Path("/tmp/code_download/data").exists():
48
+ # Remove existing data directory if present
49
+ if Path("/app/data").exists():
50
+ shutil.rmtree("/app/data")
51
+ # Copy the entire data directory
52
+ shutil.copytree("/tmp/code_download/data", "/app/data")
 
 
 
 
 
53
  print("OK data/ directory copied")
54
  else:
55
  print("WARNING: data/ directory not found in code space")