77from pathlib import Path
88
99import yaml
10-
11- # from azure.cosmos import PartitionKey, ThroughputProperties
10+ from azure .cosmos import PartitionKey , ThroughputProperties
1211from fastapi import (
1312 FastAPI ,
1413 Request ,
2928from graphrag_app .api .query import query_route
3029from graphrag_app .api .source import source_route
3130from graphrag_app .logger .load_logger import load_pipeline_logger
32-
33- # from graphrag_app.utils.azure_clients import AzureClientManager
31+ from graphrag_app .utils .azure_clients import AzureClientManager
3432
3533
3634async def catch_all_exceptions_middleware (request : Request , call_next ):
@@ -48,19 +46,25 @@ async def catch_all_exceptions_middleware(request: Request, call_next):
4846 return Response ("Unexpected internal server error." , status_code = 500 )
4947
5048
51- # def intialize_cosmosdb_setup():
52- # """Initialise database setup (if necessary) and configure CosmosDB containers that are expected at startup time if they do not exist."""
53- # azure_client_manager = AzureClientManager()
54- # client = azure_client_manager.get_cosmos_client()
55- # db_client = client.create_database_if_not_exists("graphrag")
56- # # create containers with default settings
57- # db_client.create_container_if_not_exists(
58- # id="jobs", partition_key=PartitionKey(path="/id")
59- # )
60- # db_client.create_container_if_not_exists(
61- # id="container-store",
62- # partition_key=PartitionKey(path="/id"),
63- # )
49+ # NOTE: this function is not currently used, but it is a placeholder for future use once RBAC issues have been resolved
50+ def intialize_cosmosdb_setup ():
51+ """Initialise database setup (if necessary) and configure CosmosDB containers that are expected at startup time if they do not exist."""
52+ azure_client_manager = AzureClientManager ()
53+ client = azure_client_manager .get_cosmos_client ()
54+ throughput = ThroughputProperties (
55+ auto_scale_max_throughput = 1000 , auto_scale_increment_percent = 1
56+ )
57+ db_client = client .create_database_if_not_exists (
58+ "graphrag" , offer_throughput = throughput
59+ )
60+ # create containers with default settings
61+ db_client .create_container_if_not_exists (
62+ id = "jobs" , partition_key = PartitionKey (path = "/id" )
63+ )
64+ db_client .create_container_if_not_exists (
65+ id = "container-store" ,
66+ partition_key = PartitionKey (path = "/id" ),
67+ )
6468
6569
6670@asynccontextmanager
0 commit comments