ghodrat commited on
Commit
ece7f95
·
verified ·
1 Parent(s): 563d7af

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +23 -1
src/streamlit_app.py CHANGED
@@ -3,11 +3,33 @@ import importlib
3
 
4
  from pathlib import Path
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # snapshot_downloading your private space
7
  snapshot_download(
8
  repo_id="ghodrat/app",
9
  repo_type="space",
10
- cache_dir="cache-dir"
11
  )
12
  # calling the app code
13
  app = hf_hub_download(
 
3
 
4
  from pathlib import Path
5
 
6
+ fs = HfFileSystem()
7
+ def setup_cache_directory():
8
+ """Setup and return cache directory for private space files"""
9
+ cache_dir = Path("private_space_cache")
10
+ cache_dir.mkdir(exist_ok=True)
11
+ return cache_dir
12
+
13
+ def download_private_assets(cache_dir):
14
+ """Download necessary files from private space"""
15
+ try:
16
+ # Download entire repository snapshot for directory structure
17
+ snapshot_download(
18
+ repo_id="ghodrat/app",
19
+ repo_type="space",
20
+ local_dir=cache_dir,
21
+ )
22
+ return True
23
+ except Exception as e:
24
+ st.error(f"Error downloading private assets: {str(e)}")
25
+ return False
26
+
27
+
28
  # snapshot_downloading your private space
29
  snapshot_download(
30
  repo_id="ghodrat/app",
31
  repo_type="space",
32
+ cache_dir="private_space_cache"
33
  )
34
  # calling the app code
35
  app = hf_hub_download(