Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,57 +1,33 @@
|
|
|
|
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
|
10 |
|
11 |
-
import sys
|
12 |
print(f"--- Python version: {sys.version} ---")
|
13 |
-
print(f"--- Python sys.path (module search paths): {sys.path} ---")
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
try:
|
16 |
-
import
|
17 |
-
print(
|
18 |
-
|
19 |
-
|
20 |
-
|
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
|
54 |
-
print(f"---
|
55 |
raise
|
56 |
|
57 |
print("--- If no errors above, imports were successful. Proceeding with rest of app. ---")
|
|
|
1 |
+
# app.py
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
+
from bs4 import BeautifulSoup # Keep this if your tools use it
|
6 |
import datetime
|
7 |
import pytz
|
8 |
import math
|
9 |
import re
|
10 |
+
import requests
|
11 |
|
12 |
+
import sys
|
13 |
print(f"--- Python version: {sys.version} ---")
|
14 |
+
# print(f"--- Python sys.path (module search paths): {sys.path} ---") # Optional now
|
15 |
+
|
16 |
+
import transformers
|
17 |
+
print(f"--- Expected Transformers Version: 4.36.0 ---")
|
18 |
+
print(f"--- Actual Transformers Version: {transformers.__version__} ---")
|
19 |
+
# print(f"--- Transformers module loaded from: {transformers.__file__} ---") # Optional now
|
20 |
+
# print(f"--- Attributes of 'transformers' module (dir(transformers)): {dir(transformers)} ---") # Optional now
|
21 |
|
22 |
try:
|
23 |
+
from transformers import HfAgent # <<< --- THE CORRECT IMPORT!
|
24 |
+
print("--- Successfully imported HfAgent directly from transformers! ---")
|
25 |
+
except ImportError as e:
|
26 |
+
print(f"--- FAILED to import HfAgent directly from transformers: {e} ---")
|
27 |
+
# This should ideally not happen now
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
raise
|
29 |
+
except Exception as e_gen:
|
30 |
+
print(f"--- Some other UNEXPECTED error during HfAgent import: {e_gen} ---")
|
31 |
raise
|
32 |
|
33 |
print("--- If no errors above, imports were successful. Proceeding with rest of app. ---")
|