Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,39 +44,17 @@ os.chdir(repo_dir)
|
|
| 44 |
# # Add repo directory to sys.path so Python can find modules inside it
|
| 45 |
sys.path.append(repo_dir)
|
| 46 |
|
| 47 |
-
# Recursively search for app.py
|
| 48 |
-
app_path = None
|
| 49 |
-
for root, dirs, files in os.walk(repo_dir):
|
| 50 |
-
if "app.py" in files:
|
| 51 |
-
app_path = os.path.join(root, "app.py")
|
| 52 |
-
break
|
| 53 |
|
| 54 |
-
if
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# Load and execute `app.py`
|
| 58 |
-
spec_app = importlib.util.spec_from_file_location("
|
| 59 |
-
if spec_app is None or spec_app.loader is None:
|
| 60 |
-
raise ImportError(f"Could not load module from {app_path}")
|
| 61 |
-
|
| 62 |
app_module = importlib.util.module_from_spec(spec_app)
|
| 63 |
spec_app.loader.exec_module(app_module)
|
| 64 |
-
|
| 65 |
-
# Now you can use functions from app_module
|
| 66 |
result = app_module.main()
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
# Download specific files (if snapshot_download wasn't used)
|
| 71 |
-
# app_path = hf_hub_download(
|
| 72 |
-
# repo_id=REPO_ID,
|
| 73 |
-
# filename="app.py",
|
| 74 |
-
# repo_type=REPO_TYPE
|
| 75 |
-
# )
|
| 76 |
-
|
| 77 |
-
# # Load and execute `app.py`
|
| 78 |
-
# spec_app = importlib.util.spec_from_file_location("*", repo_dir)
|
| 79 |
-
# app_module = importlib.util.module_from_spec(spec_app)
|
| 80 |
-
# spec_app.loader.exec_module(app_module)
|
| 81 |
-
# # Now you can use functions from utils_module
|
| 82 |
-
# result = app_module.main()
|
|
|
|
| 44 |
# # Add repo directory to sys.path so Python can find modules inside it
|
| 45 |
sys.path.append(repo_dir)
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
# Download specific files (if snapshot_download wasn't used)
|
| 49 |
+
app_path = hf_hub_download(
|
| 50 |
+
repo_id=REPO_ID,
|
| 51 |
+
filename="app.py",
|
| 52 |
+
repo_type=REPO_TYPE
|
| 53 |
+
)
|
| 54 |
|
| 55 |
# Load and execute `app.py`
|
| 56 |
+
spec_app = importlib.util.spec_from_file_location("*", repo_dir)
|
|
|
|
|
|
|
|
|
|
| 57 |
app_module = importlib.util.module_from_spec(spec_app)
|
| 58 |
spec_app.loader.exec_module(app_module)
|
| 59 |
+
# Now you can use functions from utils_module
|
|
|
|
| 60 |
result = app_module.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|