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

Commit ff5714a

Browse files
committed
update code references to new locations in graphrag library
1 parent 699bfa5 commit ff5714a

File tree

7 files changed

+92
-14
lines changed

7 files changed

+92
-14
lines changed

backend/src/api/query.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
APIRouter,
1717
HTTPException,
1818
)
19+
from graphrag.api.query import global_search, local_search
1920
from graphrag.config import create_graphrag_config
2021
from graphrag.model.types import TextEmbedder
21-
from graphrag.query.api import global_search, local_search
2222
from graphrag.vector_stores.base import (
2323
BaseVectorStore,
2424
VectorStoreDocument,
@@ -408,9 +408,9 @@ async def local_query(request: GraphRequest):
408408
parameters.embeddings.vector_store["index_names"] = sanitized_index_names
409409
# internally write over the get_embedding_description_store
410410
# method to use the multi-index collection.
411-
import graphrag.query.api
411+
import graphrag.api.query
412412

413-
graphrag.query.api._get_embedding_description_store = (
413+
graphrag.api.query._get_embedding_description_store = (
414414
_get_embedding_description_store
415415
)
416416
# perform async search

backend/src/api/query_streaming.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
HTTPException,
1414
)
1515
from fastapi.responses import StreamingResponse
16-
from graphrag.config import create_graphrag_config
17-
from graphrag.query.api import (
16+
from graphrag.api.query import (
1817
global_search_streaming as global_search_streaming_internal,
1918
)
20-
from graphrag.query.api import local_search_streaming as local_search_streaming_internal
19+
from graphrag.api.query import (
20+
local_search_streaming as local_search_streaming_internal,
21+
)
22+
from graphrag.config import create_graphrag_config
2123

2224
from src.api.azure_clients import AzureClientManager
2325
from src.api.common import (

backend/src/logger/load_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import List
77

88
from datashaper import WorkflowCallbacks, WorkflowCallbacksManager
9-
from graphrag.index.reporting import FileWorkflowCallbacks
9+
from graphrag.callbacks.file_workflow_callbacks import FileWorkflowCallbacks
1010

1111
from src.api.azure_clients import AzureClientManager
1212
from src.logger.application_insights_workflow_callbacks import (

backend/src/logger/typing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from enum import Enum
66
from typing import Literal
77

8-
from graphrag.index.config import (
8+
from graphrag.index.config.reporting import (
99
PipelineReportingConfig,
10-
reporting,
10+
PipelineReportingConfigTypes,
1111
)
1212
from pydantic import Field as pydantic_Field
1313

@@ -46,5 +46,5 @@ class PipelineAppInsightsReportingConfig(
4646

4747
# add the new type to the existing PipelineReportingConfigTypes
4848
PipelineReportingConfigTypes = (
49-
reporting.PipelineReportingConfigTypes | PipelineAppInsightsReportingConfig
49+
PipelineReportingConfigTypes | PipelineAppInsightsReportingConfig
5050
)

backend/src/typing/pipeline.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
from enum import Enum
55

66

7-
class PipelineJobState(Enum):
7+
class PipelineJobState(str, Enum):
88
SCHEDULED = "scheduled"
99
RUNNING = "running"
1010
FAILED = "failed"
1111
COMPLETE = "complete"
12+
13+
def __repr__(self):
14+
"""Get a string representation."""
15+
return f'"{self.value}"'

backend/tests/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
def blob_with_data_container_name(blob_service_client: BlobServiceClient):
1919
# create a storage container and upload some data
2020
container_name = "container-with-data"
21-
blob_service_client.create_container(container_name)
22-
blob_client = blob_service_client.get_blob_client(container_name, "data.txt")
21+
sanitized_name = sanitize_name(container_name)
22+
blob_service_client.create_container(sanitized_name)
23+
blob_client = blob_service_client.get_blob_client(sanitized_name, "data.txt")
2324
blob_client.upload_blob(data="Hello, World!", overwrite=True)
2425
yield container_name
2526
# cleanup
26-
blob_service_client.delete_container(container_name)
27+
blob_service_client.delete_container(sanitized_name)
2728

2829

2930
@pytest.fixture(scope="session")
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
"""
4+
Integration tests for the PipelineJob class.
5+
"""
6+
7+
from typing import Generator
8+
9+
import pytest
10+
11+
from src.typing.pipeline import PipelineJobState
12+
from src.utils.pipeline import PipelineJob
13+
14+
15+
@pytest.fixture()
16+
def cosmos_index_job_entry(cosmos_client) -> Generator[str, None, None]:
17+
"""Create an entry for an indexing job in the appropriate CosmosDB database and container
18+
that graphrag expects when first scheduling an indexing job."""
19+
20+
db_client = cosmos_client.get_database_client("graphrag")
21+
container_client = db_client.get_container_client("jobs")
22+
synthetic_job_entry = {
23+
"id": "testID",
24+
"epoch_request_time": 0,
25+
"human_readable_index_name": "test_human_readable_index_name",
26+
"sanitized_index_name": "test_sanitized_index_name",
27+
"human_readable_storage_name": "test_human_readable_storage_name",
28+
"sanitized_storage_name": "test_sanitized_storage_name",
29+
"all_workflows": ["workflow1", "workflow2"],
30+
"completed_workflows": ["workflow1"],
31+
"failed_workflows": ["workflow2"],
32+
"status": PipelineJobState.COMPLETE,
33+
"percent_complete": 50.0,
34+
"progress": "some progress",
35+
}
36+
container_client.upsert_item(synthetic_job_entry)
37+
yield synthetic_job_entry["id"]
38+
# teardown
39+
container_client.delete_item(
40+
synthetic_job_entry["id"], partition_key=synthetic_job_entry["id"]
41+
)
42+
43+
44+
def test_pipeline_job_interface(cosmos_index_job_entry):
45+
pipeline_job = PipelineJob()
46+
# test creating a new entry
47+
pipeline_job.create_item(
48+
id="synthetic_id",
49+
human_readable_index_name="test_human_readable_index_name",
50+
human_readable_storage_name="test_human_readable_storage_name",
51+
entity_extraction_prompt="fake entity extraction prompt",
52+
community_report_prompt="fake community report prompt",
53+
summarize_descriptions_prompt="fake summarize descriptions prompt",
54+
)
55+
assert pipeline_job.item_exist("synthetic_id")
56+
57+
# test loading an existing entry
58+
pipeline_job = pipeline_job.load_item(cosmos_index_job_entry)
59+
assert pipeline_job.id == "testID"
60+
assert pipeline_job.human_readable_index_name == "test_human_readable_index_name"
61+
assert pipeline_job.sanitized_index_name == "test_sanitized_index_name"
62+
assert (
63+
pipeline_job.human_readable_storage_name == "test_human_readable_storage_name"
64+
)
65+
assert pipeline_job.sanitized_storage_name == "test_sanitized_storage_name"
66+
assert pipeline_job.all_workflows == ["workflow1", "workflow2"]
67+
assert pipeline_job.completed_workflows == ["workflow1"]
68+
assert pipeline_job.failed_workflows == ["workflow2"]
69+
assert pipeline_job.status == PipelineJobState.COMPLETE
70+
assert pipeline_job.percent_complete == 50.0
71+
assert pipeline_job.progress == "some progress"

0 commit comments

Comments
 (0)