1616
1717
1818def download_embeddings_from_azure (
19- connection_string : str ,
20- container_name : str ,
21- blob_name : str ,
22- local_path : Path
19+ connection_string : str , container_name : str , blob_name : str , local_path : Path
2320) -> None :
2421 """
2522 Download pre-computed embeddings from Azure Blob Storage.
26-
23+
2724 Args:
2825 connection_string: Azure Storage connection string
2926 container_name: Name of the blob container
@@ -34,28 +31,29 @@ def download_embeddings_from_azure(
3431 logger .info (f" Container: { container_name } " )
3532 logger .info (f" Blob: { blob_name } " )
3633 logger .info (f" Local path: { local_path } " )
37-
34+
3835 try :
3936 # Create BlobServiceClient
40- blob_service_client = BlobServiceClient .from_connection_string (connection_string )
41-
37+ blob_service_client = BlobServiceClient .from_connection_string (
38+ connection_string
39+ )
40+
4241 # Get blob client
4342 blob_client = blob_service_client .get_blob_client (
44- container = container_name ,
45- blob = blob_name
43+ container = container_name , blob = blob_name
4644 )
47-
45+
4846 # Ensure parent directory exists
4947 local_path .parent .mkdir (parents = True , exist_ok = True )
50-
48+
5149 # Download the blob
5250 with open (local_path , "wb" ) as download_file :
5351 download_stream = blob_client .download_blob ()
5452 download_file .write (download_stream .readall ())
55-
53+
5654 file_size_kb = local_path .stat ().st_size / 1024
5755 logger .info (f"✓ Downloaded embeddings successfully ({ file_size_kb :.2f} KB)" )
58-
56+
5957 except Exception as e :
6058 logger .error (f"Failed to download embeddings from Azure: { e } " )
6159 raise
@@ -144,10 +142,10 @@ def start(self) -> None:
144142 """Start all test containers and bootstrap Vault"""
145143 logger .info ("Starting RAG Stack testcontainers..." )
146144 os .environ ["EVAL_MODE" ] = "true"
147-
145+
148146 # Download embeddings from Azure before starting containers
149147 self ._download_embeddings_from_azure ()
150-
148+
151149 # Prepare Vault Agent directories
152150 agent_in = self .project_root / "test-vault" / "agents" / "llm"
153151 agent_out = self .project_root / "test-vault" / "agent-out"
@@ -212,33 +210,33 @@ def _download_embeddings_from_azure(self) -> None:
212210 connection_string = os .getenv ("AZURE_STORAGE_CONNECTION_STRING" )
213211 container_name = os .getenv ("AZURE_STORAGE_CONTAINER_NAME" , "test-embeddings" )
214212 blob_name = os .getenv ("AZURE_STORAGE_BLOB_NAME" , "test_embeddings.json" )
215-
213+
216214 # Local path where embeddings should be saved
217215 embeddings_file = self .project_root / "tests" / "data" / "test_embeddings.json"
218-
216+
219217 # Skip if embeddings already exist locally (for local development)
220- #if embeddings_file.exists():
218+ # if embeddings_file.exists():
221219 # logger.info("Embeddings file already exists locally, skipping Azure download")
222220 # return
223-
221+
224222 # Require Azure configuration for CI/CD
225223 if not connection_string :
226224 raise ValueError (
227225 "AZURE_STORAGE_CONNECTION_STRING is required to download embeddings. "
228226 "Either set this environment variable or ensure test_embeddings.json "
229227 f"exists at { embeddings_file } "
230228 )
231-
229+
232230 logger .info ("=" * 80 )
233231 logger .info ("DOWNLOADING EMBEDDINGS FROM AZURE BLOB STORAGE" )
234232 logger .info ("=" * 80 )
235-
233+
236234 try :
237235 download_embeddings_from_azure (
238236 connection_string = connection_string ,
239237 container_name = container_name ,
240238 blob_name = blob_name ,
241- local_path = embeddings_file
239+ local_path = embeddings_file ,
242240 )
243241 logger .info ("Embeddings download complete" )
244242 except Exception as e :
@@ -797,8 +795,9 @@ def orchestration_client(rag_stack: RAGStackTestContainers):
797795 Function-scoped fixture that provides the orchestration service URL.
798796 Tests can use either requests (sync) or httpx (async).
799797 """
798+
800799 class OrchestrationClient :
801800 def __init__ (self , base_url : str ):
802801 self .base_url = base_url
803-
804- return OrchestrationClient (rag_stack .get_orchestration_service_url ())
802+
803+ return OrchestrationClient (rag_stack .get_orchestration_service_url ())
0 commit comments