Skip to content

Commit

Permalink
add --dryrun flag to inspect indexer configs
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Apr 4, 2024
1 parent 645420e commit 41141d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions graphrag/index/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
help="The data formats to emit, comma-separated. Valid values are 'parquet' and 'csv'. default='parquet,csv'",
type=str,
)
parser.add_argument(
"--dryrun",
help="Run the pipeline without actually executing any steps and inspect the configuration.",
action="store_true",
)
parser.add_argument("--nocache", help="Disable LLM cache.", action="store_true")
args = parser.parse_args()

Expand All @@ -61,5 +66,6 @@
reporter=args.reporter,
config=args.config,
emit=args.emit,
dryrun=args.dryrun,
cli=True,
)
13 changes: 9 additions & 4 deletions graphrag/index/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@ def index_cli(
config: str | None,
emit: str | None,
cli: bool = False,
dryrun: bool = False,
):
"""Run the pipeline with the given config."""
progress_reporter = _get_progress_reporter(reporter)
pipeline_config: str | PipelineConfig = config or _create_default_config(
root, verbose, progress_reporter
root, verbose, dryrun, progress_reporter
)
cache = NoopPipelineCache() if nocache else None
pipeline_emit = emit.split(",") if emit else None
Expand Down Expand Up @@ -133,7 +134,7 @@ async def execute():


def _create_default_config(
root: str, verbose: bool, reporter: ProgressReporter
root: str, verbose: bool, dryrun: bool, reporter: ProgressReporter
) -> PipelineConfig:
"""Create a default config if none is provided."""
import json
Expand All @@ -143,15 +144,19 @@ def _create_default_config(
raise ValueError(msg)

parameters = _read_config_parameters(root, reporter)
if verbose:
if verbose or dryrun:
reporter.info(
f"Using default configuration: {redact(json.dumps(parameters.to_dict(), indent=4))}"
)
result = default_config(parameters, verbose)
if verbose:
if verbose or dryrun:
reporter.info(
f"Final Config: {redact(json.dumps(result.model_dump(), indent=4))}"
)

if dryrun:
reporter.info("dry run complete, exiting...")
sys.exit(0)
return result


Expand Down

0 comments on commit 41141d1

Please sign in to comment.