Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,9 +44,14 @@ 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 |
-
#
|
| 48 |
-
app_path =
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
raise FileNotFoundError(f"app.py not found in {repo_dir}")
|
| 51 |
|
| 52 |
# Load and execute `app.py`
|
|
@@ -57,6 +62,9 @@ if spec_app is None or spec_app.loader is None:
|
|
| 57 |
app_module = importlib.util.module_from_spec(spec_app)
|
| 58 |
spec_app.loader.exec_module(app_module)
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
|
| 62 |
# Download specific files (if snapshot_download wasn't used)
|
|
|
|
| 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 app_path is None:
|
| 55 |
raise FileNotFoundError(f"app.py not found in {repo_dir}")
|
| 56 |
|
| 57 |
# Load and execute `app.py`
|
|
|
|
| 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)
|