repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
graphrag
tests/integration/logging/test_standard_logging.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Tests for standard logging functionality.""" import logging import os import tempfile from pathlib import Path from graphrag.logger.standard_logging import DEFAULT_LOG_FILENAME, init_loggers from tests.unit.config.utils import get_defau...
136
4,226
graphrag
tests/integration/logging/test_factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """LoggerFactory Tests. These tests will test the LoggerFactory class and the creation of each reporting type that is natively supported. """ import logging import pytest from graphrag.config.enums import ReportingType from graphrag.logger....
63
2,453
graphrag
tests/integration/logging/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Tests for logger module."""
5
109
graphrag
tests/integration/cache/test_factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """CacheFactory Tests. These tests will test the CacheFactory() class and the creation of each cache type that is natively supported. """ import sys import pytest from graphrag_cache import Cache, CacheConfig, CacheType, create_cache, regis...
163
4,807
graphrag
tests/integration/vector_stores/test_factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """VectorStoreFactory Tests. These tests will test the VectorStoreFactory class and the creation of each vector store type that is natively supported. """ import pytest from graphrag_vectors import ( VectorStore, VectorStoreFactory, ...
172
5,199
graphrag
tests/integration/vector_stores/test_azure_ai_search.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Integration tests for Azure AI Search vector store implementation.""" import os from unittest.mock import MagicMock, patch import pytest from graphrag_vectors import ( VectorStoreDocument, ) from graphrag_vectors.azure_ai_search impo...
206
7,165
graphrag
tests/integration/vector_stores/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Integration tests for vector store implementations."""
5
136
graphrag
tests/integration/vector_stores/test_lancedb.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Integration tests for LanceDB vector store implementation.""" import shutil import tempfile import numpy as np import pytest from graphrag_vectors import ( VectorStoreDocument, ) from graphrag_vectors.filtering import F from graphrag...
608
21,358
graphrag
tests/integration/vector_stores/test_cosmosdb.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Integration tests for CosmosDB vector store implementation.""" import sys import numpy as np import pytest from graphrag_vectors import ( VectorStoreDocument, ) from graphrag_vectors.cosmosdb import CosmosDBVectorStore # cspell:disa...
144
4,293
graphrag
tests/verbs/test_generate_text_embeddings.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.config.embeddings import ( all_embeddings, ) from graphrag.index.workflows.generate_text_embeddings import ( run_workflow, ) from tests.unit.config.utils import get_default_graphrag_config from .util import ( creat...
54
1,489
graphrag
tests/verbs/test_create_community_reports.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.data_model.schemas import COMMUNITY_REPORTS_FINAL_COLUMNS from graphrag.index.operations.summarize_communities.community_reports_extractor import ( CommunityReportResponse, FindingModel, ) from graphrag.index.workflows....
71
2,160
graphrag
tests/verbs/util.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import pandas as pd from graphrag.index.run.utils import create_run_context from graphrag.index.typing.context import PipelineRunContext from pandas.testing import assert_series_equal pd.set_option("display.max_columns", None) async def cr...
67
2,471
graphrag
tests/verbs/test_extract_graph_nlp.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.index.workflows.extract_graph_nlp import run_workflow from tests.unit.config.utils import get_default_graphrag_config from .util import ( create_test_context, ) async def test_extract_graph_nlp(): context = await cre...
31
932
graphrag
tests/verbs/test_extract_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.index.workflows.extract_graph import run_workflow from tests.unit.config.utils import get_default_graphrag_config from .util import ( create_test_context, ) MOCK_LLM_ENTITY_RESPONSES = [ """ ("entity"<|>COMPANY_A<...
65
2,542
graphrag
tests/verbs/test_create_base_text_units.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.index.workflows.create_base_text_units import run_workflow from tests.unit.config.utils import get_default_graphrag_config from .util import ( compare_outputs, create_test_context, load_test_table, ) async def te...
36
870
graphrag
tests/verbs/test_prune_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.config.models.prune_graph_config import PruneGraphConfig from graphrag.index.workflows.prune_graph import run_workflow from tests.unit.config.utils import get_default_graphrag_config from .util import ( create_test_context...
29
769
graphrag
tests/verbs/test_create_final_text_units.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from typing import Any import pandas as pd from graphrag.data_model.row_transformers import ( transform_entity_row, transform_relationship_row, transform_text_unit_row, ) from graphrag.data_model.schemas import TEXT_UNITS_FINAL_C...
142
4,176
graphrag
tests/verbs/test_extract_covariates.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.data_model.schemas import COVARIATES_FINAL_COLUMNS from graphrag.index.workflows.extract_covariates import ( run_workflow, ) from graphrag_llm.config import LLMProviderType from pandas.testing import assert_series_equal fro...
74
3,144
graphrag
tests/verbs/test_pipeline_state.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Tests for pipeline state passthrough.""" from graphrag.config.models.graph_rag_config import GraphRagConfig from graphrag.index.run.utils import create_run_context from graphrag.index.typing.context import PipelineRunContext from graphrag...
55
1,754
graphrag
tests/verbs/test_update_text_embeddings.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """Verb test for the update_text_embeddings workflow.""" from unittest.mock import patch from graphrag.config.embeddings import all_embeddings from graphrag.index.workflows.update_text_embeddings import ( run_workflow, ) from tests.unit.config.util...
66
1,978
graphrag
tests/verbs/test_create_final_documents.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.data_model.schemas import DOCUMENTS_FINAL_COLUMNS from graphrag.index.workflows.create_final_documents import ( run_workflow, ) from tests.unit.config.utils import get_default_graphrag_config from .util import ( compar...
35
832
graphrag
tests/verbs/test_finalize_graph.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.data_model.schemas import ( ENTITIES_FINAL_COLUMNS, RELATIONSHIPS_FINAL_COLUMNS, ) from graphrag.index.workflows.finalize_graph import run_workflow from tests.unit.config.utils import get_default_graphrag_config from ....
47
1,490
graphrag
tests/verbs/test_create_communities.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.data_model.schemas import COMMUNITIES_FINAL_COLUMNS from graphrag.index.workflows.create_communities import ( run_workflow, ) from tests.unit.config.utils import get_default_graphrag_config from .util import ( compare_...
48
1,105
graphrag
tests/unit/graphs/nx_stable_lcc.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """NetworkX-based stable LCC utility, kept for side-by-side test comparisons. This was originally at graphrag.index.utils.stable_lcc and has been moved here because production code no longer uses it (superseded by the DataFrame-based graphra...
67
2,282
graphrag
tests/unit/graphs/test_connected_components.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Side-by-side tests comparing NetworkX connected components with DataFrame-based implementation.""" import json from pathlib import Path import networkx as nx import pandas as pd from graphrag.graphs.connected_components import ( conn...
167
5,364
graphrag
tests/unit/graphs/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Graph utility tests"""
5
104
graphrag
tests/unit/graphs/test_modularity.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Side-by-side tests for the DataFrame-based modularity utility.""" import json import math from collections import defaultdict from pathlib import Path from typing import Any import networkx as nx import pandas as pd from graphrag.graphs....
263
8,378
graphrag
tests/unit/graphs/test_compute_degree.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Side-by-side tests comparing NetworkX compute_degree with DataFrame-based compute_degree_df.""" import json from pathlib import Path import networkx as nx import pandas as pd from graphrag.graphs.compute_degree import compute_degree as c...
131
4,315
graphrag
tests/unit/graphs/test_stable_lcc.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Side-by-side tests for the DataFrame-based stable LCC utility.""" import json from pathlib import Path import networkx as nx import pandas as pd from graphrag.graphs.stable_lcc import stable_lcc from pandas.testing import assert_frame_eq...
214
6,681
graphrag
tests/unit/query/context_builder/test_entity_extraction.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from typing import Any from graphrag.data_model.entity import Entity from graphrag.query.context_builder.entity_extraction import ( EntityVectorStoreKey, map_query_to_entities, ) from graphrag_llm.config import LLMProviderType, Model...
167
4,700
graphrag
tests/unit/query/context_builder/dynamic_community_selection.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Tests for dynamic community selection with type handling.""" from unittest.mock import MagicMock from graphrag.data_model.community import Community from graphrag.data_model.community_report import CommunityReport from graphrag.query.con...
206
5,972
graphrag
tests/unit/query/input/retrieval/test_entities.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.data_model.entity import Entity from graphrag.query.input.retrieval.entities import ( get_entity_by_id, get_entity_by_key, ) def test_get_entity_by_id(): assert ( get_entity_by_id( { ...
168
5,096
graphrag
tests/unit/storage/test_parquet_table_provider.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import unittest from io import BytesIO import pandas as pd import pytest from graphrag_storage import ( StorageConfig, StorageType, create_storage, ) from graphrag_storage.tables.parquet_table_provider import ParquetTableProvider...
91
2,756
graphrag
tests/unit/storage/test_csv_table.py
.py
# Copyright (C) 2026 Microsoft """Tests for CSVTable temp-file write strategy and streaming behavior. When truncate=True, CSVTable writes to a temporary file and moves it over the original on close(). This allows safe concurrent reads from the original while writes are in progress — the pattern used by create_final_t...
239
7,774
graphrag
tests/unit/storage/test_csv_table_provider.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import unittest from io import StringIO import pandas as pd import pytest from graphrag_storage import ( StorageConfig, StorageType, create_storage, ) from graphrag_storage.tables.csv_table_provider import CSVTableProvider clas...
120
3,876
graphrag
tests/unit/chunking/test_chunker.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from typing import Any from unittest.mock import Mock, patch from graphrag.tokenizer.get_tokenizer import get_tokenizer from graphrag_chunking.bootstrap_nltk import bootstrap from graphrag_chunking.chunk_strategy_type import ChunkerType from...
191
5,696
graphrag
tests/unit/chunking/test_prepend_metadata.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_chunking.transformers import add_metadata def test_add_metadata_one_row(): """Test prepending metadata to chunks""" chunks = ["This is a test.", "Another sentence."] metadata = {"message": "hello"} transformer ...
45
1,821
graphrag
tests/unit/hasher/test_hasher.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test hasher""" from graphrag_common.hasher import hash_data def test_hash_data() -> None: """Test hash data function.""" # Test different types of data class TestClass: # noqa: B903 """Test hasher class.""" ...
105
3,147
graphrag
tests/unit/logger/test_blob_workflow_logger.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Unit tests for the BlobWorkflowLogger.""" import json from unittest.mock import MagicMock, patch import pytest from graphrag.logger.blob_workflow_logger import BlobWorkflowLogger @pytest.fixture def mock_blob_service(): """Create a...
164
5,380
graphrag
tests/unit/config/utils.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from dataclasses import asdict import graphrag.config.defaults as defs from graphrag.config.models.basic_search_config import BasicSearchConfig from graphrag.config.models.cluster_graph_config import ClusterGraphConfig from graphrag.config.m...
380
16,269
graphrag
tests/unit/config/test_rate_limit_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test rate limit configuration loading.""" import pytest from graphrag_llm.config import RateLimitConfig, RateLimitType def test_sliding_window_validation() -> None: """Test that missing required parameters raise validation errors.""...
67
1,932
graphrag
tests/unit/config/test_model_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test model configuration loading.""" import pytest from graphrag_llm.config import AuthMethod, LLMProviderType, ModelConfig from pydantic import ValidationError def test_litellm_provider_validation() -> None: """Test that missing re...
111
3,210
graphrag
tests/unit/config/test_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import os from pathlib import Path from unittest import mock from graphrag.config.load_config import load_config from graphrag.config.models.graph_rag_config import GraphRagConfig from tests.unit.config.utils import ( DEFAULT_COMPLETION...
61
1,868
graphrag
tests/unit/config/test_template_engine_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test metrics configuration loading.""" import pytest from graphrag_llm.config import ( TemplateEngineConfig, TemplateEngineType, TemplateManagerType, ) def test_template_engine_config_validation() -> None: """Test that m...
45
1,263
graphrag
tests/unit/config/test_metrics_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test metrics configuration loading.""" import pytest from graphrag_llm.config import ( MetricsConfig, MetricsWriterType, ) def test_file_metrics_writer_validation() -> None: """Test that missing required parameters raise val...
30
699
graphrag
tests/unit/config/test_retry_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test retry configuration loading.""" import pytest from graphrag_llm.config import RetryConfig, RetryType def test_exponential_backoff_validation() -> None: """Test that missing required parameters raise validation errors.""" w...
68
1,771
graphrag
tests/unit/config/test_tokenizer_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Test tokenizer configuration loading.""" import pytest from graphrag_llm.config import TokenizerConfig, TokenizerType def test_litellm_tokenizer_validation() -> None: """Test that missing required parameters raise validation errors....
40
1,016
graphrag
tests/unit/utils/test_encoding.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag.tokenizer.get_tokenizer import get_tokenizer def test_encode_basic(): tokenizer = get_tokenizer() result = tokenizer.encode("abc def") assert result == [26682, 1056], ( f"Encoding failed to return expected...
21
525
graphrag
tests/unit/language_model/test_cache_middleware.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Unit tests for the LLM cache middleware.""" import asyncio from collections.abc import Callable from typing import Any import pytest from graphrag_cache.memory_cache import MemoryCache from graphrag_llm.middleware.with_cache import with_...
119
4,074
graphrag
tests/unit/indexing/test_init_content.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import re from typing import Any, cast import yaml from graphrag.config.init_content import INIT_YAML from graphrag.config.models.graph_rag_config import GraphRagConfig def test_init_yaml(): data = yaml.load(INIT_YAML, Loader=yaml.Full...
30
948
graphrag
tests/unit/indexing/test_cluster_graph.py
.py
# Copyright (C) 2026 Microsoft """Tests for the cluster_graph operation. These tests pin down the behavior of cluster_graph and its internal _compute_leiden_communities function so that refactoring (vectorizing iterrows, reducing copies, etc.) can be verified against known output. """ import pandas as pd import pyte...
296
10,093
graphrag
tests/unit/indexing/test_profiling.py
.py
# Copyright (C) 2025 Microsoft # Licensed under the MIT License """Unit tests for WorkflowProfiler.""" import time from graphrag.index.run.profiling import WorkflowProfiler from graphrag.index.typing.stats import WorkflowMetrics class TestWorkflowProfiler: """Tests for the WorkflowProfiler context manager.""" ...
96
3,300
graphrag
tests/unit/indexing/test_finalize_graph.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """Tests for the finalize_graph streaming functions. Covers _build_degree_map, finalize_entities, finalize_relationships, and the orchestrating finalize_graph function. """ from typing import Any import pytest from graphrag.data_model.schemas import ( ...
445
15,738
graphrag
tests/unit/indexing/test_create_communities.py
.py
# Copyright (C) 2026 Microsoft """Tests for the create_communities pure function. These tests pin down the behavior of the create_communities function independently of the workflow runner, so that refactoring (vectorizing the per-level loop, streaming entity reads, streaming writes, etc.) can be verified against know...
621
22,070
graphrag
tests/unit/indexing/operations/test_extract_graph.py
.py
# Copyright (C) 2026 Microsoft Corporation. # Licensed under the MIT License """Tests for extract_graph merge and orphan-filtering operations. Validates that _merge_entities, _merge_relationships, and filter_orphan_relationships correctly aggregate per-text-unit extraction results and remove relationships whose sourc...
303
10,279
graphrag
tests/unit/indexing/operations/embed_text/test_embed_text.py
.py
# Copyright (C) 2026 Microsoft # Licensed under the MIT License """Unit tests for the streaming embed_text operation.""" from collections.abc import AsyncIterator from typing import Any from unittest.mock import AsyncMock, MagicMock, patch import numpy as np import pytest from graphrag.callbacks.noop_workflow_callba...
419
13,155
graphrag
tests/unit/indexing/input/test_text_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_input import InputConfig, InputType, create_input_reader from graphrag_storage import StorageConfig, create_storage async def test_text_loader_one_file(): config = InputConfig( type=InputType.Text, file_pat...
37
1,054
graphrag
tests/unit/indexing/input/test_csv_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_input import InputConfig, InputType, create_input_reader from graphrag_storage import StorageConfig, create_storage async def test_csv_loader_one_file(): config = InputConfig( type=InputType.Csv, file_patte...
80
2,478
graphrag
tests/unit/indexing/input/test_text_document.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import pytest from graphrag_input import get_property def test_get_property_single_level(): data = {"foo": "bar"} assert get_property(data, "foo") == "bar" def test_get_property_two_levels(): data = {"foo": {"bar": "baz"}} ...
77
1,876
graphrag
tests/unit/indexing/input/test_markitdown_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_input import InputConfig, InputType, create_input_reader from graphrag_storage import StorageConfig, create_storage # these tests just confirm we can load files with MarkItDown, # and use html specifically because it requires ...
27
987
graphrag
tests/unit/indexing/input/test_jsonl_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_input import InputConfig, InputType, create_input_reader from graphrag_storage import StorageConfig, create_storage async def test_jsonl_loader_one_file_multiple_objects(): config = InputConfig( type=InputType.Json...
60
1,814
graphrag
tests/unit/indexing/input/test_parquet_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_input import InputConfig, InputType, create_input_reader from graphrag_storage import StorageConfig, create_storage async def test_parquet_loader_one_file(): config = InputConfig( type=InputType.Parquet, fi...
62
1,855
graphrag
tests/unit/indexing/input/test_json_loader.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License from graphrag_input import InputConfig, InputType, create_input_reader from graphrag_storage import StorageConfig, create_storage async def test_json_loader_one_file_one_object(): config = InputConfig( type=InputType.Json, ...
72
2,093
graphrag
tests/unit/indexing/update/test_update_relationships.py
.py
# Copyright (C) 2026 Microsoft Corporation. # Licensed under the MIT License """Tests for incremental update merge operations. Covers _update_and_merge_relationships and orphan-filtering in the update pipeline, where old finalized data is merged with delta data from a new indexing run. """ import pandas as pd import...
229
8,257
graphrag
tests/unit/indexing/verbs/entities/extraction/strategies/graph_intelligence/test_gi_entity_extraction.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import unittest from graphrag.index.operations.extract_graph.extract_graph import _run_extract_graph from graphrag.prompts.index.extract_graph import GRAPH_EXTRACTION_PROMPT from graphrag_llm.completion import create_completion from graphrag_...
80
2,951
graphrag
tests/unit/indexing/cache/test_file_pipeline_cache.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import asyncio import os import unittest from graphrag_cache import CacheConfig, CacheType from graphrag_cache import create_cache as cc from graphrag_storage import StorageConfig, StorageType TEMP_DIR = "./.tmp" def create_cache(): re...
81
2,432
graphrag
tests/unit/indexing/graph/extractors/community_reports/test_sort_context.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import math import platform from graphrag.index.operations.summarize_communities.graph_context.sort_context import ( sort_context, ) from graphrag.tokenizer.get_tokenizer import get_tokenizer nan = math.nan context: list[dict] = [ {...
222
8,761
graphrag
tests/unit/indexing/graph/utils/test_stable_lcc.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import unittest import networkx as nx from tests.unit.graphs.nx_stable_lcc import stable_largest_connected_component class TestStableLCC(unittest.TestCase): def test_undirected_graph_run_twice_produces_same_graph(self): graph_i...
46
1,728
graphrag
tests/unit/load_config/test_load_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Unit tests for graphrag-config.load_config.""" import os from pathlib import Path import pytest from graphrag_common.config import ConfigParsingError, load_config from pydantic import ValidationError from .config import TestConfigModel ...
158
5,145
graphrag
tests/unit/load_config/config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Config models for load_config unit tests.""" from pydantic import BaseModel, ConfigDict, Field class TestNestedModel(BaseModel): """Test nested model.""" model_config = ConfigDict(extra="forbid") nested_str: str = Field(de...
28
827
graphrag
tests/unit/prompt_tune/__init__.py
.py
# Copyright (C) 2025 Microsoft # Licensed under the MIT License """Unit tests for prompt_tune module."""
5
106
graphrag
tests/unit/prompt_tune/test_load_docs_in_chunks.py
.py
# Copyright (C) 2025 Microsoft # Licensed under the MIT License """Unit tests for load_docs_in_chunks function.""" import logging from dataclasses import dataclass from typing import Any from unittest.mock import AsyncMock, MagicMock, patch import pytest from graphrag.prompt_tune.loader.input import load_docs_in_chu...
293
8,913
graphrag
tests/unit/vector_stores/test_filtering.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Unit tests for the filtering module (no backend required).""" import json from graphrag_vectors.filtering import ( AndExpr, Condition, F, FilterExpr, NotExpr, Operator, OrExpr, ) # ── Condition.evaluate ─────...
324
11,754
graphrag
tests/unit/vector_stores/test_timestamp.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Unit tests for the timestamp module (no backend required).""" import pytest from graphrag_vectors.timestamp import ( TIMESTAMP_FIELDS, _timestamp_fields_for, explode_timestamp, ) class TestExplodeTimestamp: """Tests for ...
113
3,399
graphrag
tests/unit/graphrag_factory/test_factory.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Unit tests for graphrag_factory package.""" from abc import ABC, abstractmethod from graphrag_common.factory import Factory class TestABC(ABC): """Test abstract base class.""" @abstractmethod def get_value(self) -> str: ...
67
1,768
graphrag
tests/smoke/test_fixtures.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import asyncio import json import logging import os import shutil import subprocess from collections.abc import Callable from functools import wraps from pathlib import Path from typing import Any, ClassVar from unittest import mock import pa...
273
9,724
graphrag
tests/notebook/test_notebooks.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License import subprocess from dataclasses import dataclass from pathlib import Path import nbformat import pytest @dataclass class NotebookDetails: dir: Path excluded_filenames: list[str] NOTEBOOKS: list[NotebookDetails] = [ Notebook...
81
1,855
graphrag
scripts/update_workspace_dependency_versions.py
.py
# Copyright (c) 2025 Microsoft Corporation. # Licensed under the MIT License """Update workspace dependency versions.""" import os import re import subprocess # noqa: S404 from pathlib import Path def _get_version() -> str: command = ["uv", "run", "semversioner", "current-version"] completion = subprocess....
59
2,013
graphrag
scripts/__init__.py
.py
# Copyright (c) 2025 Microsoft Corporation. # Licensed under the MIT License """GraphRAG Scripts module."""
6
110
graphrag
scripts/copy_build_assets.py
.py
# Copyright (c) 2025 Microsoft Corporation. # Licensed under the MIT License """Copy root build assets to package directories.""" import shutil from pathlib import Path def copy_build_assets(): """Copy root build assets to package build directories so files are included in pypi distributions.""" root_dir = ...
26
716
graphrag
unified-search-app/app/app_logic.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """App logic module.""" import asyncio import logging from typing import TYPE_CHECKING import graphrag.api as api import streamlit as st from knowledge_loader.data_sources.loader import ( create_datasource, load_dataset_listing, ) f...
368
11,742
graphrag
unified-search-app/app/home_page.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Home Page module.""" import asyncio import streamlit as st from app_logic import dataset_name, initialize, run_all_searches, run_generate_questions from rag.typing import SearchType from st_tabs import TabBar from state.session_variables...
252
8,981
graphrag
unified-search-app/app/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """App module."""
5
96
graphrag
unified-search-app/app/data_config.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Data config module.""" # This file is used to store configurations for the graph-indexed data and the LLM/embeddings models used in the app. # name of the table in the graph-indexed data where the communities are stored communities_table...
34
1,363
graphrag
unified-search-app/app/state/query_variable.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Query variable module.""" from typing import Any import streamlit as st class QueryVariable: """ Manage reading and writing variables from the URL query string. We handle translation between string values and bools, accoun...
46
1,349
graphrag
unified-search-app/app/state/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """App state module."""
5
102
graphrag
unified-search-app/app/state/session_variables.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Session variables module.""" from data_config import ( default_suggested_questions, ) from state.query_variable import QueryVariable from state.session_variable import SessionVariable class SessionVariables: """Define all the se...
43
1,730
graphrag
unified-search-app/app/state/session_variable.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Session variable module.""" import traceback from typing import Any import streamlit as st class SessionVariable: """Define the session variable structure that will be used in the app.""" def __init__(self, default: Any = "", ...
54
1,713
graphrag
unified-search-app/app/rag/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Rag module."""
5
96
graphrag
unified-search-app/app/rag/typing.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Typing module.""" from dataclasses import dataclass from enum import Enum import pandas as pd class SearchType(Enum): """SearchType class definition.""" Basic = "basic" Local = "local" Global = "global" Drift = "dr...
29
553
graphrag
unified-search-app/app/ui/questions_list.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Question list module.""" import streamlit as st from state.session_variables import SessionVariables def create_questions_list_ui(sv: SessionVariables): """Return question list UI component.""" selection = st.dataframe( ...
24
717
graphrag
unified-search-app/app/ui/sidebar.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Sidebar module.""" import streamlit as st from app_logic import dataset_name, load_dataset from state.session_variables import SessionVariables def reset_app(): """Reset app to its original state.""" st.cache_data.clear() st...
98
2,797
graphrag
unified-search-app/app/ui/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """App UI module."""
5
99
graphrag
unified-search-app/app/ui/report_list.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Report list module.""" import streamlit as st from state.session_variables import SessionVariables def create_report_list_ui(sv: SessionVariables): """Return report list UI component.""" selection = st.dataframe( sv.comm...
26
750
graphrag
unified-search-app/app/ui/report_details.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Report details module.""" import json import pandas as pd import streamlit as st from state.session_variables import SessionVariables from ui.search import ( display_graph_citations, format_response_hyperlinks, get_ids_per_ke...
100
3,822
graphrag
unified-search-app/app/ui/search.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Search module.""" import json import re from dataclasses import dataclass import pandas as pd import streamlit as st from rag.typing import SearchResult, SearchType from streamlit.delta_generator import DeltaGenerator def init_search_u...
286
9,704
graphrag
unified-search-app/app/knowledge_loader/model.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Model module.""" from dataclasses import dataclass import pandas as pd import streamlit as st from data_config import ( default_ttl, ) from knowledge_loader.data_prep import ( get_communities_data, get_community_report_data, ...
111
3,155
graphrag
unified-search-app/app/knowledge_loader/__init__.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Knowledge loader module."""
5
109
graphrag
unified-search-app/app/knowledge_loader/data_prep.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Data prep module.""" import logging import data_config as config import pandas as pd import streamlit as st from knowledge_loader.data_sources.typing import Datasource """ Contains functions to load and prep graph-indexed data from parq...
76
2,841
graphrag
unified-search-app/app/knowledge_loader/data_sources/default.py
.py
# Copyright (c) 2024 Microsoft Corporation. # Licensed under the MIT License """Data sources default module.""" import os container_name = "data" blob_container_name = os.getenv("BLOB_CONTAINER_NAME", container_name) blob_account_name = os.getenv("BLOB_ACCOUNT_NAME") local_data_root = os.getenv("DATA_ROOT") LISTIN...
21
549