File size: 1,310 Bytes
563d7af
69daa2a
5887a00
563d7af
 
ece7f95
c6dc4a1
 
 
 
 
ece7f95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c6dc4a1
a99be11
ece7f95
69daa2a
 
af52642
69daa2a
ece7f95
69daa2a
 
 
af52642
8a073ea
69daa2a
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from huggingface_hub import hf_hub_download , snapshot_download , HfFileSystem
import importlib

from pathlib import Path

fs = HfFileSystem()
#def setup_cache_directory():
#    """Setup and return cache directory for private space files"""
#cache_dir = Path("private_space_cache")
 #   cache_dir.mkdir(exist_ok=True)
  #  return cache_dir

def download_private_assets(cache_dir):
    """Download necessary files from private space"""
    try:
        # Download entire repository snapshot for directory structure
        snapshot_download(
            repo_id="ghodrat/app",
            repo_type="space",
            local_dir=cache_dir,
        )
        return True
    except Exception as e:
        st.error(f"Error downloading private assets: {str(e)}")
        return False

#setup_cache_directory()
download_private_assets("private_space_cache")

# snapshot_downloading your private space
snapshot_download(
    repo_id="ghodrat/app",
    repo_type="space",
    cache_dir="private_space_cache"
)
# calling the app code
app = hf_hub_download(
    repo_id="ghodrat/app",
    filename="src/streamlit_app.py",
    repo_type="space"
)

# executing the app file 
spec_app = importlib.util.spec_from_file_location("*",app_path)
app = importlib.util.module_from_spec(spec_app)
spec_app.loader.exec_module(app)