Spaces:
Runtime error
Runtime error
| 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, | |
| ) | |
| subprocess.run(["pip", "install", "bitsandbytes>=0.46.1"], 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) | |