Skip to content

Commit 22a57d1

Browse files
authored
Improve CLI speed with lazy imports (#1319)
1 parent 9b4f24e commit 22a57d1

File tree

237 files changed

+936
-1383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

237 files changed

+936
-1383
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "move import statements out of init files"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "patch",
3+
"description": "fix autocompletion of existing files/directory paths."
4+
}

docs/prompt_tuning/auto_prompt_tuning.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Before running auto tuning, ensure you have already initialized your workspace w
2020
You can run the main script from the command line with various options:
2121

2222
```bash
23-
graphrag prompt-tune [--root ROOT] [--domain DOMAIN] [--method METHOD] [--limit LIMIT] [--language LANGUAGE] \
23+
graphrag prompt-tune [--root ROOT] [--config CONFIG] [--domain DOMAIN] [--selection-method METHOD] [--limit LIMIT] [--language LANGUAGE] \
2424
[--max-tokens MAX_TOKENS] [--chunk-size CHUNK_SIZE] [--n-subset-max N_SUBSET_MAX] [--k K] \
25-
[--min-examples-required MIN_EXAMPLES_REQUIRED] [--no-entity-types] [--output OUTPUT]
25+
[--min-examples-required MIN_EXAMPLES_REQUIRED] [--discover-entity-types] [--output OUTPUT]
2626
```
2727

2828
## Command-Line Options
@@ -49,7 +49,7 @@ graphrag prompt-tune [--root ROOT] [--domain DOMAIN] [--method METHOD] [--limit
4949

5050
- `--min-examples-required` (optional): The minimum number of examples required for entity extraction prompts. Default is 2.
5151

52-
- `--no-entity-types` (optional): Use untyped entity extraction generation. We recommend using this when your data covers a lot of topics or it is highly randomized.
52+
- `--discover-entity-types` (optional): Allow the LLM to discover and extract entities automatically. We recommend using this when your data covers a lot of topics or it is highly randomized.
5353

5454
- `--output` (optional): The folder to save the generated prompts. Default is "prompts".
5555

examples/custom_input/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pandas as pd
77

8-
from graphrag.index import run_pipeline_with_config
8+
from graphrag.index.run import run_pipeline_with_config
99

1010
pipeline_file = os.path.join(
1111
os.path.dirname(os.path.abspath(__file__)), "./pipeline.yml"

examples/single_verb/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import pandas as pd
77

8-
from graphrag.index import run_pipeline, run_pipeline_with_config
9-
from graphrag.index.config import PipelineWorkflowReference
8+
from graphrag.index.config.workflow import PipelineWorkflowReference
9+
from graphrag.index.run import run_pipeline, run_pipeline_with_config
1010

1111
# our fake dataset
1212
dataset = pd.DataFrame([{"col1": 2, "col2": 4}, {"col1": 5, "col2": 10}])

examples/use_built_in_workflows/run.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import asyncio
44
import os
55

6-
from graphrag.index import run_pipeline, run_pipeline_with_config
7-
from graphrag.index.config import PipelineCSVInputConfig, PipelineWorkflowReference
8-
from graphrag.index.input import load_input
6+
from graphrag.index.config.input import PipelineCSVInputConfig
7+
from graphrag.index.config.workflow import PipelineWorkflowReference
8+
from graphrag.index.input.load_input import load_input
9+
from graphrag.index.run import run_pipeline, run_pipeline_with_config
910

1011
sample_data_dir = os.path.join(
1112
os.path.dirname(os.path.abspath(__file__)), "../_sample_data/"

graphrag/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
"""The GraphRAG package."""
55

6-
from .cli.main import app
6+
from graphrag.cli.main import app
77

88
app(prog_name="graphrag")

graphrag/api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
"""
99

1010
from graphrag.api.index import build_index
11-
from graphrag.api.prompt_tune import DocSelectionType, generate_indexing_prompts
11+
from graphrag.api.prompt_tune import generate_indexing_prompts
1212
from graphrag.api.query import (
1313
drift_search,
1414
global_search,
1515
global_search_streaming,
1616
local_search,
1717
local_search_streaming,
1818
)
19+
from graphrag.prompt_tune.types import DocSelectionType
1920

2021
__all__ = [ # noqa: RUF022
2122
# index API

graphrag/api/index.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111
from pathlib import Path
1212

13-
from graphrag.config import CacheType, GraphRagConfig
13+
from graphrag.config.enums import CacheType
14+
from graphrag.config.models.graph_rag_config import GraphRagConfig
1415
from graphrag.index.cache.noop_pipeline_cache import NoopPipelineCache
1516
from graphrag.index.create_pipeline_config import create_pipeline_config
1617
from graphrag.index.emit.types import TableEmitterType
1718
from graphrag.index.run import run_pipeline_with_config
1819
from graphrag.index.typing import PipelineRunResult
19-
from graphrag.logging import ProgressReporter
20+
from graphrag.logging.base import ProgressReporter
2021
from graphrag.vector_stores.factory import VectorStoreType
2122

2223

graphrag/api/prompt_tune.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,32 @@
1515
from pydantic import PositiveInt, validate_call
1616

1717
from graphrag.config.models.graph_rag_config import GraphRagConfig
18-
from graphrag.index.llm import load_llm
19-
from graphrag.logging import PrintProgressReporter
20-
from graphrag.prompt_tune.generator import (
21-
MAX_TOKEN_COUNT,
22-
create_community_summarization_prompt,
23-
create_entity_extraction_prompt,
24-
create_entity_summarization_prompt,
25-
detect_language,
18+
from graphrag.index.llm.load_llm import load_llm
19+
from graphrag.logging.print_progress import PrintProgressReporter
20+
from graphrag.prompt_tune.defaults import MAX_TOKEN_COUNT
21+
from graphrag.prompt_tune.generator.community_report_rating import (
2622
generate_community_report_rating,
23+
)
24+
from graphrag.prompt_tune.generator.community_report_summarization import (
25+
create_community_summarization_prompt,
26+
)
27+
from graphrag.prompt_tune.generator.community_reporter_role import (
2728
generate_community_reporter_role,
28-
generate_domain,
29+
)
30+
from graphrag.prompt_tune.generator.domain import generate_domain
31+
from graphrag.prompt_tune.generator.entity_extraction_prompt import (
32+
create_entity_extraction_prompt,
33+
)
34+
from graphrag.prompt_tune.generator.entity_relationship import (
2935
generate_entity_relationship_examples,
30-
generate_entity_types,
31-
generate_persona,
3236
)
33-
from graphrag.prompt_tune.loader import (
34-
MIN_CHUNK_SIZE,
35-
load_docs_in_chunks,
37+
from graphrag.prompt_tune.generator.entity_summarization_prompt import (
38+
create_entity_summarization_prompt,
3639
)
40+
from graphrag.prompt_tune.generator.entity_types import generate_entity_types
41+
from graphrag.prompt_tune.generator.language import detect_language
42+
from graphrag.prompt_tune.generator.persona import generate_persona
43+
from graphrag.prompt_tune.loader.input import MIN_CHUNK_SIZE, load_docs_in_chunks
3744
from graphrag.prompt_tune.types import DocSelectionType
3845

3946

0 commit comments

Comments
 (0)