Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 1e53475

Browse files
committed
cleanup webapp initialization code
1 parent 3ed6a8a commit 1e53475

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

backend/graphrag_app/main.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from pathlib import Path
88

99
import yaml
10-
11-
# from azure.cosmos import PartitionKey, ThroughputProperties
10+
from azure.cosmos import PartitionKey, ThroughputProperties
1211
from fastapi import (
1312
FastAPI,
1413
Request,
@@ -29,8 +28,7 @@
2928
from graphrag_app.api.query import query_route
3029
from graphrag_app.api.source import source_route
3130
from 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

3634
async 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

Comments
 (0)