Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,10 +45,18 @@ os.chdir(repo_dir)
|
|
| 45 |
sys.path.append(repo_dir)
|
| 46 |
|
| 47 |
# Now you can directly load and execute `app.py` from the snapshot directory
|
| 48 |
-
app_path = os.path.join(repo_dir, 'app.py')
|
| 49 |
|
| 50 |
-
#
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# Load and execute `app.py`
|
| 53 |
spec_app = importlib.util.spec_from_file_location("*", app_path)
|
| 54 |
app_module = importlib.util.module_from_spec(spec_app)
|
|
@@ -56,8 +64,6 @@ if os.path.exists(app_path):
|
|
| 56 |
|
| 57 |
# Now you can use functions from the app_module
|
| 58 |
result = app_module.main()
|
| 59 |
-
else:
|
| 60 |
-
print(f"Error: {app_path} does not exist.")
|
| 61 |
|
| 62 |
|
| 63 |
# Download specific files (if snapshot_download wasn't used)
|
|
|
|
| 45 |
sys.path.append(repo_dir)
|
| 46 |
|
| 47 |
# Now you can directly load and execute `app.py` from the snapshot directory
|
|
|
|
| 48 |
|
| 49 |
+
# List all files in the repo_dir to check where app.py is located
|
| 50 |
+
print(f"Files in downloaded repo directory: {os.listdir(repo_dir)}")
|
| 51 |
+
|
| 52 |
+
# Check if the app.py file exists
|
| 53 |
+
app_path = os.path.join(repo_dir, 'app.py')
|
| 54 |
+
if not os.path.exists(app_path):
|
| 55 |
+
print(f"Error: {app_path} does not exist.")
|
| 56 |
+
# You can also print out subdirectories if app.py is in a subfolder
|
| 57 |
+
subdirectories = [d for d in os.listdir(repo_dir) if os.path.isdir(os.path.join(repo_dir, d))]
|
| 58 |
+
print(f"Subdirectories in repo: {subdirectories}")
|
| 59 |
+
else:
|
| 60 |
# Load and execute `app.py`
|
| 61 |
spec_app = importlib.util.spec_from_file_location("*", app_path)
|
| 62 |
app_module = importlib.util.module_from_spec(spec_app)
|
|
|
|
| 64 |
|
| 65 |
# Now you can use functions from the app_module
|
| 66 |
result = app_module.main()
|
|
|
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
# Download specific files (if snapshot_download wasn't used)
|