Spaces:
Runtime error
Runtime error
Commit ·
e5cf5e6
1
Parent(s): b6d7575
Debugging to check embeddings path
Browse files- config.py +13 -4
- handler.py +10 -3
config.py
CHANGED
|
@@ -5,9 +5,9 @@ class Config:
|
|
| 5 |
"""Configuration class for FaceMatch application"""
|
| 6 |
|
| 7 |
# Azure Storage Configuration
|
| 8 |
-
AZURE_STORAGE_CONNECTION_STRING = os.getenv('AZURE_STORAGE_CONNECTION_STRING', '
|
| 9 |
-
AZURE_STORAGE_ACCOUNT_NAME = os.getenv('AZURE_STORAGE_ACCOUNT_NAME', '
|
| 10 |
-
AZURE_STORAGE_ACCOUNT_KEY = os.getenv('AZURE_STORAGE_ACCOUNT_KEY', '
|
| 11 |
AZURE_CONTAINER_NAME = os.getenv('AZURE_CONTAINER_NAME', 'koottu-media')
|
| 12 |
AZURE_PREFIX = os.getenv('AZURE_PREFIX', 'koottu-media/profile-media/')
|
| 13 |
AZURE_EMBEDDINGS_FOLDER = os.getenv('AZURE_EMBEDDINGS_FOLDER', 'koottu-media/embeddings/')
|
|
@@ -41,12 +41,21 @@ class Config:
|
|
| 41 |
@classmethod
|
| 42 |
def get_azure_config(cls) -> Dict[str, Any]:
|
| 43 |
"""Get Azure Storage configuration dictionary"""
|
| 44 |
-
|
| 45 |
'connection_string': cls.AZURE_STORAGE_CONNECTION_STRING,
|
| 46 |
'account_name': cls.AZURE_STORAGE_ACCOUNT_NAME,
|
| 47 |
'account_key': cls.AZURE_STORAGE_ACCOUNT_KEY,
|
| 48 |
'container_name': cls.AZURE_CONTAINER_NAME
|
| 49 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
@classmethod
|
| 52 |
def get_storage_config(cls) -> Dict[str, str]:
|
|
|
|
| 5 |
"""Configuration class for FaceMatch application"""
|
| 6 |
|
| 7 |
# Azure Storage Configuration
|
| 8 |
+
AZURE_STORAGE_CONNECTION_STRING = os.getenv('AZURE_STORAGE_CONNECTION_STRING', '')
|
| 9 |
+
AZURE_STORAGE_ACCOUNT_NAME = os.getenv('AZURE_STORAGE_ACCOUNT_NAME', '')
|
| 10 |
+
AZURE_STORAGE_ACCOUNT_KEY = os.getenv('AZURE_STORAGE_ACCOUNT_KEY', '')
|
| 11 |
AZURE_CONTAINER_NAME = os.getenv('AZURE_CONTAINER_NAME', 'koottu-media')
|
| 12 |
AZURE_PREFIX = os.getenv('AZURE_PREFIX', 'koottu-media/profile-media/')
|
| 13 |
AZURE_EMBEDDINGS_FOLDER = os.getenv('AZURE_EMBEDDINGS_FOLDER', 'koottu-media/embeddings/')
|
|
|
|
| 41 |
@classmethod
|
| 42 |
def get_azure_config(cls) -> Dict[str, Any]:
|
| 43 |
"""Get Azure Storage configuration dictionary"""
|
| 44 |
+
config = {
|
| 45 |
'connection_string': cls.AZURE_STORAGE_CONNECTION_STRING,
|
| 46 |
'account_name': cls.AZURE_STORAGE_ACCOUNT_NAME,
|
| 47 |
'account_key': cls.AZURE_STORAGE_ACCOUNT_KEY,
|
| 48 |
'container_name': cls.AZURE_CONTAINER_NAME
|
| 49 |
}
|
| 50 |
+
print("\n" + "="*80)
|
| 51 |
+
print("AZURE CONFIGURATION DEBUG")
|
| 52 |
+
print("="*80)
|
| 53 |
+
print(f"Account Name: {cls.AZURE_STORAGE_ACCOUNT_NAME or '(NOT SET)'}")
|
| 54 |
+
print(f"Container: {cls.AZURE_CONTAINER_NAME}")
|
| 55 |
+
print(f"Connection String: {'SET' if cls.AZURE_STORAGE_CONNECTION_STRING else '(NOT SET)'}")
|
| 56 |
+
print(f"Account Key: {'SET' if cls.AZURE_STORAGE_ACCOUNT_KEY else '(NOT SET)'}")
|
| 57 |
+
print("="*80 + "\n")
|
| 58 |
+
return config
|
| 59 |
|
| 60 |
@classmethod
|
| 61 |
def get_storage_config(cls) -> Dict[str, str]:
|
handler.py
CHANGED
|
@@ -94,10 +94,17 @@ class EndpointHandler:
|
|
| 94 |
print(f"Using cached embeddings (age: {int(current_time - self.cache_timestamp)}s)")
|
| 95 |
return self.embeddings_cache
|
| 96 |
|
| 97 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
try:
|
| 99 |
-
# Check if embeddings file exists in Azure - look in profile-media/embeddings/
|
| 100 |
-
blob_name = f'profile-media/embeddings/embeddings_db.json'
|
| 101 |
blob_client = self.container_client.get_blob_client(blob_name)
|
| 102 |
|
| 103 |
# Download the existing embeddings file if it exists
|
|
|
|
| 94 |
print(f"Using cached embeddings (age: {int(current_time - self.cache_timestamp)}s)")
|
| 95 |
return self.embeddings_cache
|
| 96 |
|
| 97 |
+
print("\n" + "="*80)
|
| 98 |
+
print("LOADING EMBEDDINGS FROM AZURE")
|
| 99 |
+
print("="*80)
|
| 100 |
+
blob_name = f'profile-media/embeddings/embeddings_db.json'
|
| 101 |
+
print(f"Account: {self.blob_service_client.account_name}")
|
| 102 |
+
print(f"Container: {self.container_name}")
|
| 103 |
+
print(f"Blob Path: {blob_name}")
|
| 104 |
+
print(f"Full URL: https://{self.blob_service_client.account_name}.blob.core.windows.net/{self.container_name}/{blob_name}")
|
| 105 |
+
print("="*80 + "\n")
|
| 106 |
+
|
| 107 |
try:
|
|
|
|
|
|
|
| 108 |
blob_client = self.container_client.get_blob_client(blob_name)
|
| 109 |
|
| 110 |
# Download the existing embeddings file if it exists
|