paavan commited on
Commit
c662cd5
·
1 Parent(s): d447961

Updated app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -12
app.py CHANGED
@@ -9,32 +9,48 @@ HF_TOKEN = os.getenv("HF_TOKEN")
9
  if not HF_TOKEN:
10
  raise Exception("HF_TOKEN secret missing")
11
 
12
- print("Downloading private repo...")
13
 
14
  download_path = snapshot_download(
15
  repo_id=PRIVATE_REPO,
16
  repo_type="space",
17
- token=HF_TOKEN
 
18
  )
19
 
20
- print("Downloaded to:", download_path)
21
 
22
- # Clean runtime directory
23
- RUNTIME_DIR = "/app/private_runtime"
 
 
 
 
 
 
 
 
24
 
 
 
25
  if os.path.exists(RUNTIME_DIR):
26
  shutil.rmtree(RUNTIME_DIR)
27
-
28
  shutil.copytree(download_path, RUNTIME_DIR)
 
29
 
30
- print("Copied private app to:", RUNTIME_DIR)
 
 
 
 
 
 
31
 
32
- # Run actual Home.py
33
  subprocess.run([
34
- "streamlit",
35
- "run",
36
  f"{RUNTIME_DIR}/Home.py",
37
  "--server.port=7860",
38
  "--server.address=0.0.0.0",
39
- "--server.headless=true"
40
- ])
 
9
  if not HF_TOKEN:
10
  raise Exception("HF_TOKEN secret missing")
11
 
12
+ print("Downloading private repo (including LFS files)...")
13
 
14
  download_path = snapshot_download(
15
  repo_id=PRIVATE_REPO,
16
  repo_type="space",
17
+ token=HF_TOKEN,
18
+ ignore_patterns=["*.git", ".git/*"],
19
  )
20
 
21
+ print(f"Downloaded to: {download_path}")
22
 
23
+ # Log what was actually downloaded so we can debug
24
+ print("=== Files in downloaded repo ===")
25
+ for root, dirs, files in os.walk(download_path):
26
+ dirs[:] = [d for d in dirs if d != ".git"]
27
+ for f in files:
28
+ full = os.path.join(root, f)
29
+ rel = os.path.relpath(full, download_path)
30
+ size = os.path.getsize(full)
31
+ print(f" {rel} ({size} bytes)")
32
+ print("=== End file listing ===")
33
 
34
+ # Clean and copy runtime directory
35
+ RUNTIME_DIR = "/app/private_runtime"
36
  if os.path.exists(RUNTIME_DIR):
37
  shutil.rmtree(RUNTIME_DIR)
 
38
  shutil.copytree(download_path, RUNTIME_DIR)
39
+ print(f"Copied private app to: {RUNTIME_DIR}")
40
 
41
+ # Verify data files landed
42
+ data_dir = os.path.join(RUNTIME_DIR, "data")
43
+ if os.path.exists(data_dir):
44
+ data_files = os.listdir(data_dir)
45
+ print(f"data/ contents: {data_files}")
46
+ else:
47
+ print("WARNING: data/ directory not found in runtime!")
48
 
49
+ # Run private Home.py
50
  subprocess.run([
51
+ "streamlit", "run",
 
52
  f"{RUNTIME_DIR}/Home.py",
53
  "--server.port=7860",
54
  "--server.address=0.0.0.0",
55
+ "--server.headless=true",
56
+ ])