Spaces:
Running
Running
th Claude Sonnet 4.5 commited on
Commit Β·
f994dd9
1
Parent(s): f760f4a
debug: Add startup diagnostics to debug import issue
Browse files- Added startup event to log directory contents and import status
- Created test_import.py for manual testing
- Will help identify why birthday_fortune_service cannot be imported
π¦ Generated with Sisi
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- app.py +15 -0
- test_import.py +29 -0
app.py
CHANGED
|
@@ -33,6 +33,21 @@ def verify_api_key(x_api_key: Optional[str] = Header(None)):
|
|
| 33 |
|
| 34 |
app = FastAPI(title="Sisi Astrology API", version="1.0.0")
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
def to_ascii_safe(name: str) -> str:
|
| 37 |
"""
|
| 38 |
Convert any name to ASCII-safe version for SVG generation
|
|
|
|
| 33 |
|
| 34 |
app = FastAPI(title="Sisi Astrology API", version="1.0.0")
|
| 35 |
|
| 36 |
+
@app.on_event("startup")
|
| 37 |
+
async def startup_event():
|
| 38 |
+
"""Log diagnostic information on startup"""
|
| 39 |
+
import os
|
| 40 |
+
logger.info(f"π Current working directory: {os.getcwd()}")
|
| 41 |
+
logger.info(f"π Files in directory: {os.listdir('.')}")
|
| 42 |
+
logger.info(f"π Python path: {__import__('sys').path[:3]}")
|
| 43 |
+
|
| 44 |
+
# Test birthday fortune service import
|
| 45 |
+
try:
|
| 46 |
+
import birthday_fortune_service
|
| 47 |
+
logger.info(f"β
birthday_fortune_service imported successfully from {birthday_fortune_service.__file__}")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
logger.error(f"β Failed to import birthday_fortune_service: {e}")
|
| 50 |
+
|
| 51 |
def to_ascii_safe(name: str) -> str:
|
| 52 |
"""
|
| 53 |
Convert any name to ASCII-safe version for SVG generation
|
test_import.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Test script to diagnose birthday_fortune_service import
|
| 3 |
+
"""
|
| 4 |
+
import sys
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
print("Python version:", sys.version)
|
| 8 |
+
print("Current directory:", os.getcwd())
|
| 9 |
+
print("Files in directory:", os.listdir('.'))
|
| 10 |
+
print("\nAttempting import...")
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
import birthday_fortune_service
|
| 14 |
+
print("β
Successfully imported birthday_fortune_service")
|
| 15 |
+
print("Module location:", birthday_fortune_service.__file__)
|
| 16 |
+
print("Module attributes:", dir(birthday_fortune_service))
|
| 17 |
+
|
| 18 |
+
# Test the function
|
| 19 |
+
from birthday_fortune_service import get_birthday_fortune
|
| 20 |
+
result = get_birthday_fortune(12, 18, 'en')
|
| 21 |
+
print("β
Successfully called get_birthday_fortune")
|
| 22 |
+
print("Result keys:", list(result.keys()))
|
| 23 |
+
except ImportError as e:
|
| 24 |
+
print(f"β Import Error: {e}")
|
| 25 |
+
print("sys.path:", sys.path)
|
| 26 |
+
except Exception as e:
|
| 27 |
+
print(f"β Other Error: {e}")
|
| 28 |
+
import traceback
|
| 29 |
+
traceback.print_exc()
|