File size: 1,114 Bytes
583ff4b
83fc116
583ff4b
 
cb63cd7
8e64bf5
cb63cd7
c1532cd
 
e7ea6d5
2ab1da6
c1532cd
 
2ab1da6
 
c1532cd
3bb74c5
f6a788f
c08b1f9
 
f6a788f
 
 
 
 
 
 
 
 
711c909
 
 
 
 
c08b1f9
711c909
 
 
83fc116
c08b1f9
83fc116
 
c08b1f9
83fc116
a27c3ee
 
0c3298f
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
47
48
import os
import sys
import subprocess
import importlib.util

os.environ["HF_HUB_DISABLE_PROGRESS_BARS"] = "1"

REPO_URL = os.environ.get("REPO_URL", "https://github.com/sitatec/turbogen.git")
CODE_FOLDER = "TurboGenDir"

subprocess.run(
    f"git clone {REPO_URL} {CODE_FOLDER}",
    shell=True,
    check=True,
)
os.chdir(CODE_FOLDER)

default_app_name = os.environ["SPACE_REPO_NAME"]
if not os.path.exists(f"apps/gradio_apps/{default_app_name}.py"):
    print(f"Path doesn't exist: apps/gradio_apps/{default_app_name}.py")
    default_app_name = None

SELECTED_APP_NAME = os.environ.get("APP_NAME", default_app_name)

if SELECTED_APP_NAME is None:
    raise ValueError(
        "No app found. Please set APP_NAME env var or ensure you space repo name is same as the app name"
    )

subprocess.run(
    [
        "pip",
        "install",
        "-r",
        "requirements.txt",
    ],
    check=True,
)


if __name__ == "__main__":
    sys.path.insert(0, ".")
    module = importlib.import_module(f"apps.gradio_apps.{SELECTED_APP_NAME}")

    demo = module.app

    demo.launch(debug=False, show_error=True)