Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload folder using huggingface_hub
Browse files- app.py +6 -0
- typing_patch.py +24 -0
app.py
CHANGED
@@ -7,6 +7,12 @@ All dependencies should be installed via requirements.txt.
|
|
7 |
import os
|
8 |
import sys
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# Simple startup message
|
11 |
if os.getenv("SPACE_ID"):
|
12 |
print("🤗 Running on Hugging Face Spaces...")
|
|
|
7 |
import os
|
8 |
import sys
|
9 |
|
10 |
+
# Apply typing compatibility patch for Python 3.11 BEFORE any other imports
|
11 |
+
from datetime import datetime
|
12 |
+
print(f"\n===== Application Startup at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} =====\n")
|
13 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
14 |
+
import typing_patch
|
15 |
+
|
16 |
# Simple startup message
|
17 |
if os.getenv("SPACE_ID"):
|
18 |
print("🤗 Running on Hugging Face Spaces...")
|
typing_patch.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Patch typing module for Python 3.11 compatibility.
|
3 |
+
The 'override' decorator was added in Python 3.12.
|
4 |
+
For Python 3.11, we need to use typing_extensions.
|
5 |
+
"""
|
6 |
+
|
7 |
+
import sys
|
8 |
+
import typing
|
9 |
+
|
10 |
+
# Check if override is already available (Python 3.12+)
|
11 |
+
if not hasattr(typing, 'override'):
|
12 |
+
try:
|
13 |
+
# Try to import from typing_extensions
|
14 |
+
from typing_extensions import override
|
15 |
+
# Monkey-patch it into typing module
|
16 |
+
typing.override = override
|
17 |
+
print("✅ Patched typing.override from typing_extensions")
|
18 |
+
except ImportError:
|
19 |
+
# If typing_extensions is not available, create a dummy decorator
|
20 |
+
def override(func):
|
21 |
+
"""Dummy override decorator for compatibility."""
|
22 |
+
return func
|
23 |
+
typing.override = override
|
24 |
+
print("⚠️ Created dummy typing.override decorator")
|