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

Commit 680cfc0

Browse files
jgbradley1dorbaker
andauthored
Update frontend UI app (#174)
Co-authored-by: dorbaker <[email protected]>
1 parent 38096c8 commit 680cfc0

19 files changed

+3660
-703
lines changed

.devcontainer/devcontainer.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
],
1313
"remoteUser": "vscode",
1414
"remoteEnv": {
15-
// We add the .venv to the beginning of the path env in the Dockerfile
16-
// so that we use the proper python, however vscode rewrites/overwrites
17-
// the PATH in the image and puts /usr/local/bin in front of our .venv
18-
// path. This fixes that issue.
19-
"PATH": "${containerEnv:PATH}",
20-
// Add src folder to PYTHONPATH so that we can import modules that
21-
// are in the source dir
22-
"PYTHONPATH": "/graphrag-accelerator/backend/:$PATH"
23-
},
15+
// We add the .venv to the beginning of the path env in the Dockerfile
16+
// so that we use the proper python, however vscode rewrites/overwrites
17+
// the PATH in the image and puts /usr/local/bin in front of our .venv
18+
// path. This fixes that issue.
19+
"PATH": "${containerEnv:PATH}",
20+
// Add src folder to PYTHONPATH so that we can import modules that
21+
// are in the source dir
22+
"PYTHONPATH": "/graphrag-accelerator/backend/:$PATH",
23+
"AZURE_CLI_DISABLE_CONNECTION_VERIFICATION": "1"
24+
},
2425
"mounts": [
2526
// NOTE: we reference both HOME and USERPROFILE environment variables to simultaneously support both Windows and Unix environments
2627
// in most default situations, only one variable will exist (Windows has USERPROFILE and unix has HOME) and a reference to the other variable will result in an empty string

backend/manage-indexing-jobs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
client,
1717
config,
1818
)
19+
1920
from src.api.azure_clients import AzureStorageClientManager
2021
from src.api.common import sanitize_name
2122
from src.models import PipelineJob

poetry.lock renamed to backend/poetry.lock

Lines changed: 346 additions & 611 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml renamed to backend/pyproject.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ authors = [
99
"Gabriel Nieves <[email protected]>",
1010
"Douglas Orbaker <[email protected]>",
1111
"Chris Sanchez <[email protected]>",
12-
"Katy Smith <[email protected]>",
1312
"Shane Solomon <[email protected]>",
1413
]
1514
readme = "README.md"
@@ -33,7 +32,7 @@ pytest = ">=8.2.1"
3332
wikipedia = ">=1.4.0"
3433

3534
[tool.poetry.group.backend.dependencies]
36-
adlfs = ">=2023.10.0"
35+
adlfs = ">=2024.7.0"
3736
applicationinsights = ">=0.11.10"
3837
attrs = ">=23.2.0"
3938
azure-core = ">=1.30.1"
@@ -66,12 +65,6 @@ tiktoken = ">=0.6.0"
6665
uvicorn = ">=0.23.2"
6766
urllib3 = ">=2.2.2"
6867

69-
[tool.poetry.group.frontend.dependencies]
70-
python-dotenv = ">=0.19.1"
71-
requests = "*"
72-
streamlit = ">=0.88.0"
73-
streamlit-nested-layout = "==0.1.3"
74-
7568
[tool.ruff]
7669
target-version = "py310"
7770
line-length = 88

backend/src/api/index.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ async def setup_indexing_pipeline(
127127
)
128128
# if indexing job is in a failed state, delete the associated K8s job and pod to allow for a new job to be scheduled
129129
if PipelineJobState(existing_job.status) == PipelineJobState.FAILED:
130-
_delete_k8s_job(f"indexing-job-{sanitized_index_name}", os.environ["AKS_NAMESPACE"])
130+
_delete_k8s_job(
131+
f"indexing-job-{sanitized_index_name}", os.environ["AKS_NAMESPACE"]
132+
)
131133
# reset the pipeline job details
132134
existing_job._status = PipelineJobState.SCHEDULED
133135
existing_job._percent_complete = 0

backend/src/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ async def lifespan(app: FastAPI):
6868
] = pod.spec.service_account_name
6969
# retrieve list of existing cronjobs
7070
batch_v1 = client.BatchV1Api()
71-
namespace_cronjobs = batch_v1.list_namespaced_cron_job(namespace=os.environ["AKS_NAMESPACE"])
71+
namespace_cronjobs = batch_v1.list_namespaced_cron_job(
72+
namespace=os.environ["AKS_NAMESPACE"]
73+
)
7274
cronjob_names = [cronjob.metadata.name for cronjob in namespace_cronjobs.items]
7375
# create cronjob if it does not exist
7476
if manifest["metadata"]["name"] not in cronjob_names:
75-
batch_v1.create_namespaced_cron_job(namespace=os.environ["AKS_NAMESPACE"], body=manifest)
77+
batch_v1.create_namespaced_cron_job(
78+
namespace=os.environ["AKS_NAMESPACE"], body=manifest
79+
)
7680
except Exception as e:
7781
print("Failed to create graphrag cronjob.")
7882
reporter = ReporterSingleton().get_instance()

backend/src/tests/api/test_azure_clients.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from azure.storage.blob import BlobServiceClient
1212
from azure.storage.blob.aio import BlobServiceClient as BlobServiceClientAsync
13+
1314
from src.api.azure_clients import AzureStorageClientManager
1415

1516

docker/Dockerfile-backend

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1
1111
ENV SETUPTOOLS_USE_DISTUTILS=stdlib
1212
ENV PYTHONPATH=/backend
1313

14-
COPY poetry.lock pyproject.toml /
1514
COPY backend /backend
16-
RUN pip install poetry \
15+
RUN cd backend \
16+
&& pip install poetry \
1717
&& poetry config virtualenvs.create false \
18-
&& poetry install --without frontend
18+
&& poetry install
1919

2020
# download all nltk data that graphrag requires
2121
RUN python -m nltk.downloader punkt averaged_perceptron_tagger maxent_ne_chunker words wordnet

docker/Dockerfile-frontend

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ ENV PIP_ROOT_USER_ACTION=ignore
77
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
88
ENV SETUPTOOLS_USE_DISTUTILS=stdlib
99

10-
COPY poetry.lock pyproject.toml /
1110
COPY frontend /frontend
12-
RUN pip install poetry \
11+
RUN cd frontend \
12+
&& pip install poetry \
1313
&& poetry config virtualenvs.create false \
14-
&& poetry install --without backend
14+
&& poetry install
1515

1616
WORKDIR /frontend
1717
EXPOSE 8080

frontend/app.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55

66
import streamlit as st
7+
78
from src.components import tabs
89
from src.components.index_pipeline import IndexPipeline
910
from src.enums import EnvVars
@@ -16,29 +17,28 @@
1617

1718

1819
def graphrag_app(initialized: bool):
19-
# main entry point for app interface
2020
st.title("Microsoft GraphRAG Copilot")
21-
main_tab, prompt_gen_tab, prompt_edit_tab, index_tab, query_tab = st.tabs(
22-
[
23-
"**Intro**",
24-
"**1. Prompt Generation**",
25-
"**2. Prompt Configuration**",
26-
"**3. Index**",
27-
"**4. Query**",
28-
]
29-
)
21+
main_tab, prompt_gen_tab, prompt_edit_tab, index_tab, query_tab = st.tabs([
22+
"**Intro**",
23+
"**1. Prompt Generation**",
24+
"**2. Prompt Configuration**",
25+
"**3. Index**",
26+
"**4. Query**",
27+
])
28+
# display only the main tab if a connection to an existing APIM has not been initialized
3029
with main_tab:
3130
tabs.get_main_tab(initialized)
32-
33-
# if not initialized, only main tab is displayed
3431
if initialized:
35-
# assign API request information
32+
# setup API request information
3633
COLUMN_WIDTHS = [0.275, 0.45, 0.275]
37-
api_url = st.session_state[EnvVars.DEPLOYMENT_URL.value]
34+
apim_url = st.session_state[EnvVars.DEPLOYMENT_URL.value]
3835
apim_key = st.session_state[EnvVars.APIM_SUBSCRIPTION_KEY.value]
39-
client = GraphragAPI(api_url, apim_key)
36+
# perform health check to verify connectivity
37+
client = GraphragAPI(apim_url, apim_key)
38+
if not client.health_check_passed():
39+
st.error("APIM Connection Error")
40+
st.stop()
4041
indexPipe = IndexPipeline(client, COLUMN_WIDTHS)
41-
4242
# display tabs
4343
with prompt_gen_tab:
4444
tabs.get_prompt_generation_tab(client, COLUMN_WIDTHS)
@@ -48,9 +48,7 @@ def graphrag_app(initialized: bool):
4848
tabs.get_index_tab(indexPipe)
4949
with query_tab:
5050
tabs.get_query_tab(client)
51-
5251
deployer_email = os.getenv("DEPLOYER_EMAIL", "[email protected]")
53-
5452
footer = f"""
5553
<div class="footer">
5654
<p> Responses may be inaccurate; please review all responses for accuracy. Learn more about Azure OpenAI code of conduct <a href="https://learn.microsoft.com/en-us/legal/cognitive-services/openai/code-of-conduct"> here</a>. </br> For feedback, email us at <a href="mailto:{deployer_email}">{deployer_email}</a>.</p>

0 commit comments

Comments
 (0)