LiamKhoaLe commited on
Commit
e22b331
·
1 Parent(s): 0bb2ccf

Migrate snapshot folder files to parent

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. download_model.py +8 -1
app.py CHANGED
@@ -61,7 +61,7 @@ os.environ["TOKENIZERS_PARALLELISM"] = "false"
61
  # 2. Setup Hugging Face Cloud project model cache
62
  MODEL_CACHE_DIR = "/app/model_cache"
63
  # Verify structure
64
- print("\n📂 LLM Model Structure:")
65
  for root, dirs, files in os.walk(MODEL_CACHE_DIR):
66
  print(f"📁 {root}/")
67
  for file in files:
 
61
  # 2. Setup Hugging Face Cloud project model cache
62
  MODEL_CACHE_DIR = "/app/model_cache"
63
  # Verify structure
64
+ print("\n📂 LLM Model Structure (Application Level):")
65
  for root, dirs, files in os.walk(MODEL_CACHE_DIR):
66
  print(f"📁 {root}/")
67
  for file in files:
download_model.py CHANGED
@@ -17,6 +17,13 @@ if os.path.exists(snapshots_dir):
17
  snapshot_folders = os.listdir(snapshots_dir)
18
  if snapshot_folders:
19
  snapshot_dir = os.path.join(snapshots_dir, snapshot_folders[0]) # Get first snapshot folder
 
 
 
 
 
 
 
20
  print(f"📂 Moving model files from {snapshot_dir} to {MODEL_CACHE_DIR}...")
21
  # Move all model files (including subdirectories)
22
  for item in os.listdir(snapshot_dir):
@@ -36,7 +43,7 @@ else:
36
  exit(1)
37
 
38
  # Verify structure
39
- print("\n📂 LLM Model Structure (Final):")
40
  for root, dirs, files in os.walk(MODEL_CACHE_DIR):
41
  print(f"📁 {root}/")
42
  for file in files:
 
17
  snapshot_folders = os.listdir(snapshots_dir)
18
  if snapshot_folders:
19
  snapshot_dir = os.path.join(snapshots_dir, snapshot_folders[0]) # Get first snapshot folder
20
+ # Move all files and directories from the snapshot folder to /app/model_cache
21
+ for item in os.listdir(snapshot_dir):
22
+ source_path = os.path.join(snapshot_dir, item)
23
+ dest_path = os.path.join(MODEL_CACHE_DIR, item)
24
+ if os.path.exists(dest_path):
25
+ shutil.rmtree(dest_path) if os.path.isdir(dest_path) else os.remove(dest_path)
26
+ shutil.move(source_path, dest_path)
27
  print(f"📂 Moving model files from {snapshot_dir} to {MODEL_CACHE_DIR}...")
28
  # Move all model files (including subdirectories)
29
  for item in os.listdir(snapshot_dir):
 
43
  exit(1)
44
 
45
  # Verify structure
46
+ print("\n📂 LLM Model Structure (Build Level):")
47
  for root, dirs, files in os.walk(MODEL_CACHE_DIR):
48
  print(f"📁 {root}/")
49
  for file in files: