Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,28 +1,60 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
-
import requests
|
4 |
import pandas as pd
|
|
|
5 |
import datetime
|
6 |
import pytz
|
7 |
-
from bs4 import BeautifulSoup
|
8 |
import math
|
9 |
import re
|
10 |
-
import
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
try:
|
13 |
-
|
14 |
-
print("---
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
except ImportError as ie:
|
20 |
-
print(f"---
|
21 |
raise
|
22 |
-
except Exception as
|
23 |
-
print(f"--- UNEXPECTED
|
24 |
raise
|
25 |
|
|
|
26 |
|
27 |
# (Keep Constants as is)
|
28 |
# --- Constants ---
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
|
|
3 |
import pandas as pd
|
4 |
+
from bs4 import BeautifulSoup
|
5 |
import datetime
|
6 |
import pytz
|
|
|
7 |
import math
|
8 |
import re
|
9 |
+
import requests # Ensure this is imported if needed
|
10 |
+
|
11 |
+
import sys # Import sys for path and module info
|
12 |
+
print(f"--- Python version: {sys.version} ---")
|
13 |
+
print(f"--- Python sys.path (module search paths): {sys.path} ---")
|
14 |
+
|
15 |
try:
|
16 |
+
import transformers
|
17 |
+
print(f"--- TRANSFORMERS VERSION: {transformers.__version__} ---")
|
18 |
+
# Try to get the file path of the loaded transformers module
|
19 |
+
if hasattr(transformers, '__file__') and transformers.__file__:
|
20 |
+
print(f"--- Transformers module loaded from: {transformers.__file__} ---")
|
21 |
+
else:
|
22 |
+
print("--- Transformers module location (__file__) not available. ---")
|
23 |
+
|
24 |
+
# List attributes of the transformers module to see if 'agents' is even recognized
|
25 |
+
print(f"--- Attributes of 'transformers' module (dir(transformers)): {dir(transformers)} ---")
|
26 |
+
|
27 |
+
if 'agents' in dir(transformers):
|
28 |
+
print("--- 'agents' IS listed in dir(transformers). This is unexpected given the error. ---")
|
29 |
+
print("--- Attempting to import transformers.agents directly... ---")
|
30 |
+
# Try to import the submodule itself
|
31 |
+
import transformers.agents
|
32 |
+
print(f"--- Successfully imported transformers.agents. Location: {transformers.agents.__file__} ---")
|
33 |
+
print(f"--- Contents of transformers.agents (dir(transformers.agents)): {dir(transformers.agents)} ---")
|
34 |
+
|
35 |
+
print("--- Attempting to import HfAgent from transformers.agents ---")
|
36 |
+
from transformers.agents import HfAgent
|
37 |
+
print(f"--- Successfully imported HfAgent: {HfAgent} ---")
|
38 |
+
else:
|
39 |
+
print("--- 'agents' IS NOT listed in dir(transformers). This confirms the submodule is not seen. ---")
|
40 |
+
# Attempt the import anyway to trigger the expected ModuleNotFoundError for complete logging
|
41 |
+
print("--- Attempting 'from transformers.agents import HfAgent' (expected to fail)... ---")
|
42 |
+
from transformers.agents import HfAgent # This line should now clearly fail if 'agents' wasn't in dir()
|
43 |
+
|
44 |
+
except ModuleNotFoundError as mnfe:
|
45 |
+
print(f"--- 최종 ModuleNotFoundError: {mnfe} ---") # "Final ModuleNotFoundError"
|
46 |
+
# If transformers was imported, print its path again to be sure
|
47 |
+
if 'transformers' in sys.modules and hasattr(sys.modules['transformers'], '__file__'):
|
48 |
+
print(f"--- Re-check Transformers module location at error: {sys.modules['transformers'].__file__} ---")
|
49 |
+
raise # Re-raise to ensure the app stops and logs the error
|
50 |
except ImportError as ie:
|
51 |
+
print(f"--- 최종 ImportError: {ie} ---") # "Final ImportError"
|
52 |
raise
|
53 |
+
except Exception as e:
|
54 |
+
print(f"--- 최종 UNEXPECTED error: {e} ---") # "Final UNEXPECTED error"
|
55 |
raise
|
56 |
|
57 |
+
print("--- If no errors above, imports were successful. Proceeding with rest of app. ---")
|
58 |
|
59 |
# (Keep Constants as is)
|
60 |
# --- Constants ---
|