Spaces:
Running
on
Zero
Running
on
Zero
modify loader
Browse files
loader.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import sys
|
3 |
from huggingface_hub import hf_hub_download
|
|
|
4 |
|
5 |
def load_script(file_str: str):
|
6 |
"""
|
@@ -138,10 +139,13 @@ def load_scripts():
|
|
138 |
try:
|
139 |
with open(last_file_path, 'r') as f:
|
140 |
script_content = f.read()
|
141 |
-
|
|
|
|
|
142 |
print(f"Successfully executed '{last_file_path}'")
|
143 |
except Exception as e:
|
144 |
print(f"Error executing the last downloaded script '{last_file_path}': {e}")
|
|
|
145 |
else:
|
146 |
print("No files were downloaded to execute.")
|
147 |
|
|
|
1 |
import os
|
2 |
import sys
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
+
import traceback
|
5 |
|
6 |
def load_script(file_str: str):
|
7 |
"""
|
|
|
139 |
try:
|
140 |
with open(last_file_path, 'r') as f:
|
141 |
script_content = f.read()
|
142 |
+
globals_dict = globals()
|
143 |
+
globals_dict['__name__'] = '__main__'
|
144 |
+
exec(script_content, globals_dict)
|
145 |
print(f"Successfully executed '{last_file_path}'")
|
146 |
except Exception as e:
|
147 |
print(f"Error executing the last downloaded script '{last_file_path}': {e}")
|
148 |
+
print(traceback.format_exc())
|
149 |
else:
|
150 |
print("No files were downloaded to execute.")
|
151 |
|