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

Add debug flag #69

Merged
merged 2 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions backend/src/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def validate_index_file_exist(index_name: str, file_name: str):
)
container_store_client.read_item(index_name, index_name)
except Exception:
raise ValueError(
f"Container {index_name} is not a valid index."
)
raise ValueError(f"Container {index_name} is not a valid index.")
# check for file existence
index_container_client = blob_service_client.get_container_client(index_name)
if not index_container_client.exists():
Expand Down
4 changes: 1 addition & 3 deletions backend/src/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ async def upload_files(
)
return BaseResponse(status="File upload successful.")
except Exception:
reporter.on_error(
"Error uploading files.", details={"files": files}
)
reporter.on_error("Error uploading files.", details={"files": files})
raise HTTPException(
status_code=500,
detail=f"Error uploading files to container '{storage_name}'.",
Expand Down
4 changes: 4 additions & 0 deletions backend/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT License.

import os
import traceback

from fastapi import (
Depends,
Expand Down Expand Up @@ -37,6 +38,9 @@ async def catch_all_exceptions_middleware(request: Request, call_next):
try:
return await call_next(request)
except Exception:
# only print stacktrace if developer has enabled debug mode
if os.getenv("DEBUG_MODE") == "on": # possible values: on, off
print(traceback.format_exc())
return Response("Unexpected internal server error", status_code=500)


Expand Down
10 changes: 6 additions & 4 deletions infra/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,10 @@ installGraphRAGHelmChart () {
--set "graphragConfig.AI_SEARCH_URL=https://$aiSearchName.$AISEARCH_ENDPOINT_SUFFIX" \
--set "graphragConfig.AI_SEARCH_AUDIENCE=$AISEARCH_AUDIENCE" \
--set "graphragConfig.COSMOS_URI_ENDPOINT=$cosmosEndpoint" \
--set "graphragConfig.DEBUG_MODE=$DEBUG_MODE" \
--set "graphragConfig.GRAPHRAG_API_BASE=$GRAPHRAG_API_BASE" \
--set "graphragConfig.GRAPHRAG_API_VERSION=$GRAPHRAG_API_VERSION" \
--set "graphragConfig.GRAPHRAG_COGNITIVE_SERVICES_ENDPOINT=$GRAPHRAG_COGNITIVE_SERVICES_ENDPOINT" \
--set "graphragConfig.GRAPHRAG_COGNITIVE_SERVICES_ENDPOINT=$GRAPHRAG_COGNITIVE_SERVICES_ENDPOINT" \
--set "graphragConfig.GRAPHRAG_LLM_MODEL=$GRAPHRAG_LLM_MODEL" \
--set "graphragConfig.GRAPHRAG_LLM_DEPLOYMENT_NAME=$GRAPHRAG_LLM_DEPLOYMENT_NAME" \
--set "graphragConfig.GRAPHRAG_EMBEDDING_MODEL=$GRAPHRAG_EMBEDDING_MODEL" \
Expand Down Expand Up @@ -522,8 +523,7 @@ createAcrIfNotExists() {
exitIfCommandFailed $? "Error creating container registry, exiting..."
CONTAINER_REGISTRY_SERVER=$(jq -r .properties.outputs.loginServer.value <<< $AZURE_ACR_DEPLOY_RESULT)
exitIfValueEmpty "$CONTAINER_REGISTRY_SERVER" "Unable to parse container registry login server from deployment, exiting..."
echo "Container registry '$CONTAINER_REGISTRY_SERVER' created."
printf "Done.\n"
printf "container registry '$CONTAINER_REGISTRY_SERVER' created.\n"
}

deployDockerImageToACR() {
Expand All @@ -544,14 +544,15 @@ usage() {
echo "options:"
echo " -h Print this help menu."
echo " -d Disable private endpoint usage."
echo " -g Developer user only. Grants deployer of this script access to Azure Storage, AI Search, and CosmosDB. Will also disable private endpoints (-d)."
echo " -g Developer use only. Grants deployer of this script access to Azure Storage, AI Search, and CosmosDB. Will disable private endpoints (-d) and enable debug mode."
echo " -p A JSON file containing the deployment parameters (deploy.parameters.json)."
echo
}
# print usage if no arguments are supplied
[ $# -eq 0 ] && usage && exit 0
# parse arguments
ENABLE_PRIVATE_ENDPOINTS=true
DEBUG_MODE=off
GRANT_DEV_ACCESS=0 # false
PARAMS_FILE=""
while getopts ":dgp:h" option; do
Expand All @@ -562,6 +563,7 @@ while getopts ":dgp:h" option; do
g)
ENABLE_PRIVATE_ENDPOINTS=false
GRANT_DEV_ACCESS=1 # true
DEBUG_MODE=on
;;
p)
PARAMS_FILE=${OPTARG}
Expand Down
1 change: 1 addition & 0 deletions infra/helm/graphrag/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ingress:
graphragConfig:
APIM_GATEWAY_URL: ""
COSMOS_URI_ENDPOINT: ""
DEBUG_MODE: "off"
GRAPHRAG_API_BASE: ""
GRAPHRAG_API_VERSION: ""
GRAPHRAG_COGNITIVE_SERVICES_ENDPOINT: "https://cognitiveservices.azure.com/.default"
Expand Down
5 changes: 4 additions & 1 deletion notebooks/2-Advanced_Getting_Started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@
"source": [
"response = list_files()\n",
"print(response)\n",
"pprint(response.json())"
"if response.ok:\n",
" pprint(response.json())\n",
"else:\n",
" pprint(response.text)"
]
},
{
Expand Down
Loading