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

Commit 5d2ab18

Browse files
Add a managed app deployment as an option (#268)
Co-authored-by: harjitdotsingh <singh.harjit@gmail.com>
1 parent 942b2c6 commit 5d2ab18

39 files changed

+8505
-1514
lines changed

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# These owners will be the default owners for everything in
2+
# the repo. Unless a later match takes precedence,
3+
# @graphrag-core-team and @societal-resilience-graphrag will be requested for
4+
# review when someone opens a pull request.
5+
* @Azure-Samples/graphrag-core-team @Azure-Samples/societal-resilience-graphrag

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# ignore temporary artifact files that users may create
2+
infra/managed-app/artifacts/graphrag/
3+
openapi.json
4+
15
# ignore vscode config files
26
.vscode/
37

CODEOWNERS

Lines changed: 0 additions & 6 deletions
This file was deleted.

backend/graphrag_app/api/data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Licensed under the MIT License.
33

44
import asyncio
5+
import os
56
import re
67
import traceback
78
from math import ceil
@@ -26,12 +27,15 @@
2627
get_blob_container_client,
2728
get_cosmos_container_store_client,
2829
sanitize_name,
30+
subscription_key_check,
2931
)
3032

3133
data_route = APIRouter(
3234
prefix="/data",
3335
tags=["Data Management"],
3436
)
37+
if os.getenv("KUBERNETES_SERVICE_HOST"):
38+
data_route.dependencies.append(Depends(subscription_key_check))
3539

3640

3741
@data_route.get(

backend/graphrag_app/api/graph.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
import os
45
import traceback
56

67
from fastapi import (
@@ -14,13 +15,16 @@
1415
from graphrag_app.utils.azure_clients import AzureClientManager
1516
from graphrag_app.utils.common import (
1617
sanitize_name,
18+
subscription_key_check,
1719
validate_index_file_exist,
1820
)
1921

2022
graph_route = APIRouter(
2123
prefix="/graph",
2224
tags=["Graph Operations"],
2325
)
26+
if os.getenv("KUBERNETES_SERVICE_HOST"):
27+
graph_route.dependencies.append(Depends(subscription_key_check))
2428

2529

2630
@graph_route.get(

backend/graphrag_app/api/index.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@
3333
delete_storage_container_if_exist,
3434
get_cosmos_container_store_client,
3535
sanitize_name,
36+
subscription_key_check,
3637
)
3738
from graphrag_app.utils.pipeline import PipelineJob
3839

3940
index_route = APIRouter(
4041
prefix="/index",
4142
tags=["Index Operations"],
4243
)
44+
if os.getenv("KUBERNETES_SERVICE_HOST"):
45+
index_route.dependencies.append(Depends(subscription_key_check))
4346

4447

4548
@index_route.post(

backend/graphrag_app/api/prompt_tuning.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
import os
45
import traceback
56
from pathlib import Path
67

@@ -15,9 +16,11 @@
1516

1617
from graphrag_app.logger.load_logger import load_pipeline_logger
1718
from graphrag_app.utils.azure_clients import AzureClientManager
18-
from graphrag_app.utils.common import sanitize_name
19+
from graphrag_app.utils.common import sanitize_name, subscription_key_check
1920

2021
prompt_tuning_route = APIRouter(prefix="/index/config", tags=["Prompt Tuning"])
22+
if os.getenv("KUBERNETES_SERVICE_HOST"):
23+
prompt_tuning_route.dependencies.append(Depends(subscription_key_check))
2124

2225

2326
@prompt_tuning_route.get(

backend/graphrag_app/api/query.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4+
import os
45
import traceback
56
from pathlib import Path
67

78
import yaml
89
from fastapi import (
910
APIRouter,
11+
Depends,
1012
HTTPException,
1113
)
1214
from graphrag.api.query import global_search, local_search
@@ -22,6 +24,7 @@
2224
from graphrag_app.utils.common import (
2325
get_df,
2426
sanitize_name,
27+
subscription_key_check,
2528
validate_index_file_exist,
2629
)
2730
from graphrag_app.utils.pipeline import PipelineJob
@@ -30,6 +33,8 @@
3033
prefix="/query",
3134
tags=["Query Operations"],
3235
)
36+
if os.getenv("KUBERNETES_SERVICE_HOST"):
37+
query_route.dependencies.append(Depends(subscription_key_check))
3338

3439

3540
@query_route.post(

backend/graphrag_app/api/query_streaming.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import yaml
1111
from fastapi import (
1212
APIRouter,
13+
Depends,
1314
HTTPException,
1415
)
1516
from fastapi.responses import StreamingResponse
@@ -28,6 +29,7 @@
2829
from graphrag_app.utils.common import (
2930
get_df,
3031
sanitize_name,
32+
subscription_key_check,
3133
validate_index_file_exist,
3234
)
3335

@@ -37,6 +39,8 @@
3739
prefix="/query/streaming",
3840
tags=["Query Streaming Operations"],
3941
)
42+
if os.getenv("KUBERNETES_SERVICE_HOST"):
43+
query_streaming_route.dependencies.append(Depends(subscription_key_check))
4044

4145

4246
@query_streaming_route.post(

backend/graphrag_app/api/source.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT License.
33

4-
4+
import os
55
import traceback
66

77
import pandas as pd
@@ -18,6 +18,7 @@
1818
from graphrag_app.utils.common import (
1919
pandas_storage_options,
2020
sanitize_name,
21+
subscription_key_check,
2122
validate_index_file_exist,
2223
)
2324

@@ -26,6 +27,9 @@
2627
tags=["Sources"],
2728
)
2829

30+
if os.getenv("KUBERNETES_SERVICE_HOST"):
31+
source_route.dependencies.append(Depends(subscription_key_check))
32+
2933

3034
COMMUNITY_REPORT_TABLE = "output/create_final_community_reports.parquet"
3135
COVARIATES_TABLE = "output/create_final_covariates.parquet"

0 commit comments

Comments
 (0)