MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / bundle_import

Function bundle_import

src/codegraphcontext/cli/main.py:682–731  ·  view source on GitHub ↗

Import a .cgc bundle into the current database. Loads a pre-indexed graph snapshot into your database. Use --clear to replace all existing data with the bundle contents. Examples: cgc bundle import numpy.cgc cgc bundle import my-project.cgc --clear --yes

(
    bundle_file: str = typer.Argument(..., help="Path to the .cgc bundle file to import"),
    clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before importing"),
    yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation when using --clear"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)

Source from the content-addressed store, hash-verified

680
681@bundle_app.command("import")
682def bundle_import(
683 bundle_file: str = typer.Argument(..., help="Path to the .cgc bundle file to import"),
684 clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before importing"),
685 yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation when using --clear"),
686 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
687):
688 """
689 Import a .cgc bundle into the current database.
690
691 Loads a pre-indexed graph snapshot into your database. Use --clear to
692 replace all existing data with the bundle contents.
693
694 Examples:
695 cgc bundle import numpy.cgc
696 cgc bundle import my-project.cgc --clear --yes
697 """
698 _load_credentials()
699 from codegraphcontext.core.cgc_bundle import CGCBundle
700
701 services = _initialize_services(context)
702 if not all(services[:3]):
703 raise typer.Exit(code=1)
704 db_manager, graph_builder, code_finder = services[:3]
705
706 try:
707 bundle_path = Path(bundle_file)
708
709 if not bundle_path.exists():
710 console.print(f"[bold red]Bundle file not found: {bundle_path}[/bold red]")
711 raise typer.Exit(code=1)
712
713 if not _confirm_bundle_clear(clear, yes):
714 return
715
716 console.print(f"[cyan]Importing bundle from {bundle_path}...[/cyan]")
717
718 bundle = CGCBundle(db_manager)
719 success, message = bundle.import_from_bundle(
720 bundle_path,
721 clear_existing=clear
722 )
723
724 if success:
725 console.print(f"[bold green]{message}[/bold green]")
726 else:
727 console.print(f"[bold red]Import failed: {message}[/bold red]")
728 raise typer.Exit(code=1)
729
730 finally:
731 db_manager.close_driver()
732
733@bundle_app.command("load")
734def bundle_load(

Callers 2

bundle_loadFunction · 0.85
registry_downloadFunction · 0.85

Calls 7

import_from_bundleMethod · 0.95
CGCBundleClass · 0.90
_load_credentialsFunction · 0.85
_initialize_servicesFunction · 0.85
_confirm_bundle_clearFunction · 0.85
printMethod · 0.80
close_driverMethod · 0.45

Tested by

no test coverage detected