Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
98fc3b8
refactor of bicep variable names to be more generic and pytest cleanup
jgbradley1 Jan 2, 2025
2b41976
add RBAC reader role assignment to cosmosdb bicep deployment
jgbradley1 Jan 2, 2025
699bfa5
update dependabot settings
jgbradley1 Jan 2, 2025
ff5714a
update code references to new locations in graphrag library
jgbradley1 Jan 3, 2025
0252646
refactor variable names to be more generic and add integration tests
jgbradley1 Jan 3, 2025
fbbad71
add new pytests
jgbradley1 Jan 3, 2025
2f744c1
ruff format updates
jgbradley1 Jan 3, 2025
4e1b1ba
revert bicep api version changes to a working condition
jgbradley1 Jan 3, 2025
44d7859
fix bad import
jgbradley1 Jan 3, 2025
97d8b52
temporary move of import statement
jgbradley1 Jan 4, 2025
3c96059
update synthetic index dataset
jgbradley1 Jan 4, 2025
96dcd95
refactor bicep to be cleaner and remove ssh public key generation for…
jgbradley1 Jan 4, 2025
8d448f8
update common bicep variable name
jgbradley1 Jan 4, 2025
863bff3
add aoai to bicep deployment
jgbradley1 Jan 6, 2025
f068846
cleanup bicep variable names
jgbradley1 Jan 6, 2025
743d587
cleanup optional parameters and define default values in helm chart
jgbradley1 Jan 6, 2025
b6153f3
auto-format bicep code
jgbradley1 Jan 7, 2025
5f78d37
auto format code
jgbradley1 Jan 7, 2025
bc24bfa
fix aoai deployment issue
jgbradley1 Jan 7, 2025
ca0c489
working version of a managed app
jgbradley1 Jan 8, 2025
25be69f
Merge branch 'main' into joshbradley/convert-to-managed-app
jgbradley1 Jan 30, 2025
24df161
fix changes after merge with main
jgbradley1 Jan 31, 2025
871b192
fix synthetic dataset after merge with main
jgbradley1 Jan 31, 2025
846e20d
remove duplication after merge from main
jgbradley1 Feb 3, 2025
453e4c3
remove unused variables from params file
jgbradley1 Feb 4, 2025
82871df
updated for build
harjitdotsingh Feb 5, 2025
964b536
updated for build
harjitdotsingh Feb 11, 2025
6364389
ManagedAPP
harjitdotsingh Feb 11, 2025
b687cc0
Updated URL
harjitdotsingh Feb 11, 2025
a4dede0
updated README
harjitdotsingh Feb 11, 2025
9656f87
updated Config
harjitdotsingh Feb 12, 2025
53a7a4e
Merge branch 'main' into joshbradley/convert-to-managed-app
jgbradley1 Mar 12, 2025
2cc588e
code update
jgbradley1 Mar 14, 2025
9e4b1b9
code cleanup
jgbradley1 Mar 17, 2025
ba2a999
doc update
jgbradley1 Mar 17, 2025
98af26f
Merge branch 'harjit-managed-app' into joshbradley/convert-to-managed…
jgbradley1 Mar 17, 2025
3996f3f
code cleanup after merge
jgbradley1 Mar 17, 2025
484e601
doc update
jgbradley1 Mar 17, 2025
e309631
code cleanup and some variable renaming
jgbradley1 Mar 18, 2025
fa95c06
remove unnecessary scripts
jgbradley1 Mar 18, 2025
6a93876
more code cleanup
jgbradley1 Mar 18, 2025
24e8108
update gitignore
jgbradley1 Mar 18, 2025
1f49938
update gitignore
jgbradley1 Mar 18, 2025
205c05d
remove temporary file
jgbradley1 Mar 18, 2025
0b69a28
readme update
jgbradley1 Mar 18, 2025
459b666
revert APIM bicep module versions
jgbradley1 Mar 19, 2025
4370b0c
code cleanup
jgbradley1 Mar 19, 2025
a06deb1
some shell code cleanup and variable renaming for better clarity
jgbradley1 Mar 21, 2025
7236cb6
add TODO comment
jgbradley1 Mar 21, 2025
8ebcbf1
remove unnecessary variable reference
jgbradley1 Mar 21, 2025
bd6af77
doc update
jgbradley1 Mar 21, 2025
19588f0
update portal ui experience
jgbradley1 Mar 21, 2025
a2f191b
code cleanup and removal of unnecessary variables
jgbradley1 Mar 24, 2025
1b507e5
commit checkpoint
jgbradley1 Mar 25, 2025
3f73d60
code cleanup
jgbradley1 Mar 25, 2025
ecbb7c6
more code cleanup
jgbradley1 Mar 25, 2025
6367f24
add support for image pull secrets to helm chart
jgbradley1 Mar 26, 2025
4c11923
update sample ARM template
jgbradley1 Mar 26, 2025
2801d40
add new doc
jgbradley1 Mar 26, 2025
1d611de
working checkpoint commit
jgbradley1 Mar 26, 2025
9c53125
attempt to support use of existing AOAI resources instead of new in m…
jgbradley1 Mar 26, 2025
7a2a8ca
doc update
jgbradley1 Mar 26, 2025
825ff4a
move AOAI rbac role assignment to bicep and support multiple scopes
jgbradley1 Mar 27, 2025
ecbdee7
fix typo
jgbradley1 Mar 27, 2025
8855708
add cluster admin assignment of deployer back
jgbradley1 Mar 27, 2025
dfe8ac3
ensure unique rbac name assignment
jgbradley1 Mar 27, 2025
1ab61db
managed app ui update and doc update
jgbradley1 Mar 29, 2025
31d077e
revert use of fastapi-offline to fastapi
jgbradley1 Mar 31, 2025
dd5123c
add apim subscription key back to swagger page
jgbradley1 Apr 1, 2025
cb48a7d
update managed app UX
jgbradley1 Apr 1, 2025
b6c6d0e
fix pytest
jgbradley1 Apr 2, 2025
6531515
update docs with correct links and remove unnecessary zip file
jgbradley1 Apr 2, 2025
711d913
fix codeowners file
jgbradley1 Apr 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @graphrag-core-team and @societal-resilience-graphrag will be requested for
# review when someone opens a pull request.
* @Azure-Samples/graphrag-core-team @Azure-Samples/societal-resilience-graphrag
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ignore temporary artifact files that users may create
infra/managed-app/artifacts/graphrag/
openapi.json

# ignore vscode config files
.vscode/

Expand Down
6 changes: 0 additions & 6 deletions CODEOWNERS

This file was deleted.

4 changes: 4 additions & 0 deletions backend/graphrag_app/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

import asyncio
import os
import re
import traceback
from math import ceil
Expand All @@ -26,12 +27,15 @@
get_blob_container_client,
get_cosmos_container_store_client,
sanitize_name,
subscription_key_check,
)

data_route = APIRouter(
prefix="/data",
tags=["Data Management"],
)
if os.getenv("KUBERNETES_SERVICE_HOST"):
data_route.dependencies.append(Depends(subscription_key_check))


@data_route.get(
Expand Down
4 changes: 4 additions & 0 deletions backend/graphrag_app/api/graph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import os
import traceback

from fastapi import (
Expand All @@ -14,13 +15,16 @@
from graphrag_app.utils.azure_clients import AzureClientManager
from graphrag_app.utils.common import (
sanitize_name,
subscription_key_check,
validate_index_file_exist,
)

graph_route = APIRouter(
prefix="/graph",
tags=["Graph Operations"],
)
if os.getenv("KUBERNETES_SERVICE_HOST"):
graph_route.dependencies.append(Depends(subscription_key_check))


@graph_route.get(
Expand Down
3 changes: 3 additions & 0 deletions backend/graphrag_app/api/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@
delete_storage_container_if_exist,
get_cosmos_container_store_client,
sanitize_name,
subscription_key_check,
)
from graphrag_app.utils.pipeline import PipelineJob

index_route = APIRouter(
prefix="/index",
tags=["Index Operations"],
)
if os.getenv("KUBERNETES_SERVICE_HOST"):
index_route.dependencies.append(Depends(subscription_key_check))


@index_route.post(
Expand Down
5 changes: 4 additions & 1 deletion backend/graphrag_app/api/prompt_tuning.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import os
import traceback
from pathlib import Path

Expand All @@ -15,9 +16,11 @@

from graphrag_app.logger.load_logger import load_pipeline_logger
from graphrag_app.utils.azure_clients import AzureClientManager
from graphrag_app.utils.common import sanitize_name
from graphrag_app.utils.common import sanitize_name, subscription_key_check

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


@prompt_tuning_route.get(
Expand Down
5 changes: 5 additions & 0 deletions backend/graphrag_app/api/query.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import os
import traceback
from pathlib import Path

import yaml
from fastapi import (
APIRouter,
Depends,
HTTPException,
)
from graphrag.api.query import global_search, local_search
Expand All @@ -22,6 +24,7 @@
from graphrag_app.utils.common import (
get_df,
sanitize_name,
subscription_key_check,
validate_index_file_exist,
)
from graphrag_app.utils.pipeline import PipelineJob
Expand All @@ -30,6 +33,8 @@
prefix="/query",
tags=["Query Operations"],
)
if os.getenv("KUBERNETES_SERVICE_HOST"):
query_route.dependencies.append(Depends(subscription_key_check))


@query_route.post(
Expand Down
4 changes: 4 additions & 0 deletions backend/graphrag_app/api/query_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import yaml
from fastapi import (
APIRouter,
Depends,
HTTPException,
)
from fastapi.responses import StreamingResponse
Expand All @@ -28,6 +29,7 @@
from graphrag_app.utils.common import (
get_df,
sanitize_name,
subscription_key_check,
validate_index_file_exist,
)

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


@query_streaming_route.post(
Expand Down
6 changes: 5 additions & 1 deletion backend/graphrag_app/api/source.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.


import os
import traceback

import pandas as pd
Expand All @@ -18,6 +18,7 @@
from graphrag_app.utils.common import (
pandas_storage_options,
sanitize_name,
subscription_key_check,
validate_index_file_exist,
)

Expand All @@ -26,6 +27,9 @@
tags=["Sources"],
)

if os.getenv("KUBERNETES_SERVICE_HOST"):
source_route.dependencies.append(Depends(subscription_key_check))


COMMUNITY_REPORT_TABLE = "output/create_final_community_reports.parquet"
COVARIATES_TABLE = "output/create_final_covariates.parquet"
Expand Down
15 changes: 13 additions & 2 deletions backend/graphrag_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import yaml
from azure.cosmos import PartitionKey, ThroughputProperties
from fastapi import (
Depends,
FastAPI,
Request,
status,
)
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import Response
from fastapi_offline import FastAPIOffline
from kubernetes import (
client,
config,
Expand All @@ -29,6 +29,7 @@
from graphrag_app.api.source import source_route
from graphrag_app.logger.load_logger import load_pipeline_logger
from graphrag_app.utils.azure_clients import AzureClientManager
from graphrag_app.utils.common import subscription_key_check


async def catch_all_exceptions_middleware(request: Request, call_next):
Expand Down Expand Up @@ -96,12 +97,19 @@ async def lifespan(app: FastAPI):
ROOT_DIR = Path(__file__).resolve().parent.parent
with (ROOT_DIR / "manifests/cronjob.yaml").open("r") as f:
manifest = yaml.safe_load(f)
# set docker image name
manifest["spec"]["jobTemplate"]["spec"]["template"]["spec"]["containers"][0][
"image"
] = pod.spec.containers[0].image
# set service account name
manifest["spec"]["jobTemplate"]["spec"]["template"]["spec"][
"serviceAccountName"
] = pod.spec.service_account_name
# set image pull secrets only if they were provided as part of the deployment.
if hasattr(pod.spec, "image_pull_secrets"):
manifest["spec"]["jobTemplate"]["spec"]["template"]["spec"][
"imagePullSecrets"
] = pod.spec.image_pull_secrets
# retrieve list of existing cronjobs
batch_v1 = client.BatchV1Api()
namespace_cronjobs = batch_v1.list_namespaced_cron_job(
Expand All @@ -125,7 +133,7 @@ async def lifespan(app: FastAPI):
# shutdown/garbage collection code goes here


app = FastAPIOffline(
app = FastAPI(
docs_url="/manpage/docs",
openapi_url="/manpage/openapi.json",
root_path=os.getenv("API_ROOT_PATH", ""),
Expand Down Expand Up @@ -157,6 +165,9 @@ async def lifespan(app: FastAPI):
@app.get(
"/health",
summary="API health check",
dependencies=[Depends(subscription_key_check)]
if os.getenv("KUBERNETES_SERVICE_HOST")
else None,
)
def health_check():
"""Returns a 200 response to indicate the API is healthy."""
Expand Down
19 changes: 18 additions & 1 deletion backend/graphrag_app/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import hashlib
import os
import traceback
from typing import Annotated

import pandas as pd
from azure.core.exceptions import ResourceNotFoundError
from azure.cosmos import ContainerProxy, exceptions
from azure.identity import DefaultAzureCredential
from azure.storage.blob.aio import ContainerClient
from fastapi import HTTPException
from fastapi import Header, HTTPException

from graphrag_app.logger.load_logger import load_pipeline_logger
from graphrag_app.utils.azure_clients import AzureClientManager
Expand Down Expand Up @@ -189,3 +190,19 @@ def desanitize_name(sanitized_container_name: str) -> str | None:
raise HTTPException(
status_code=500, detail="Error retrieving original container name."
)


async def subscription_key_check(
Ocp_Apim_Subscription_Key: Annotated[str, Header()],
):
"""
Verifies if user has passed the Ocp_Apim_Subscription_Key (APIM subscription key) in the request header.
If it is not present, an HTTPException with a 400 status code is raised.
Note: this check is unnecessary (APIM validates subscription keys automatically), but this will add the key
as a required parameter in the swagger docs page, enabling users to send requests using the swagger docs "Try it out" feature.
"""
if not Ocp_Apim_Subscription_Key:
raise HTTPException(
status_code=400, detail="Ocp-Apim-Subscription-Key required"
)
return Ocp_Apim_Subscription_Key
Loading
Loading