File size: 1,256 Bytes
0f84a70
 
 
 
 
 
 
 
a5bc6a8
97e5d8d
0f84a70
9eecded
0f84a70
9eecded
0f84a70
 
 
9eecded
97e5d8d
0f84a70
 
 
 
 
 
9eecded
 
 
 
 
 
 
 
 
0f84a70
 
 
 
97e5d8d
49ae6ae
 
97e5d8d
49ae6ae
97e5d8d
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
import os
from huggingface_hub import HfApi
from tempfile import TemporaryDirectory
import importlib.util
import sys


def load_private_code():
    api = HfApi(token=os.environ["PRIVATE_REPOSITORY_HF_TOKEN"])

    with TemporaryDirectory() as tmp_dir:
        # γƒ—γƒ©γ‚€γƒ™γƒΌγƒˆγ‚ΉγƒšγƒΌγ‚Ήγ‹γ‚‰γƒ•γ‚‘γ‚€γƒ«γ‚’γƒ€γ‚¦γƒ³γƒ­γƒΌγƒ‰
        api.snapshot_download(
            repo_id="neoai-inc-private/pj-andromeda",
            repo_type="space",
            local_dir=tmp_dir
        )
        sys.path.append(tmp_dir)

        spec = importlib.util.spec_from_file_location(
            "private_app",
            os.path.join(tmp_dir, "app.py")
        )
        private_module = importlib.util.module_from_spec(spec)
        sys.modules["private_app"] = private_module
        
        try:
            spec.loader.exec_module(private_module)
        except ModuleNotFoundError as e:
            print(f"Error loading module: {e}")
            print(f"Current sys.path: {sys.path}")
            print(f"Contents of tmp_dir: {os.listdir(tmp_dir)}")
            raise
        
        return private_module


private_app = load_private_code()
app = private_app.app

app.launch(
    auth=(private_app.USERNAME, private_app.PASSWORD),
    ssr_mode=False
)