MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / bundle_import

Function bundle_import

src/codegraphcontext/cli/main.py:618–669  ·  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

(
    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"),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)

Source from the content-addressed store, hash-verified

616
617@bundle_app.command("import")
618def bundle_import(
619 bundle_file: str = typer.Argument(..., help="Path to the .cgc bundle file to import"),
620 clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before importing"),
621 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
622):
623 """
624 Import a .cgc bundle into the current database.
625
626 Loads a pre-indexed graph snapshot into your database. Use --clear to
627 replace all existing data with the bundle contents.
628
629 Examples:
630 cgc bundle import numpy.cgc
631 cgc bundle import my-project.cgc --clear
632 """
633 _load_credentials()
634 from codegraphcontext.core.cgc_bundle import CGCBundle
635
636 services = _initialize_services(context)
637 if not all(services[:3]):
638 return
639 db_manager, graph_builder, code_finder = services[:3]
640
641 try:
642 bundle_path = Path(bundle_file)
643
644 if not bundle_path.exists():
645 console.print(f"[bold red]Bundle file not found: {bundle_path}[/bold red]")
646 raise typer.Exit(code=1)
647
648 if clear:
649 console.print("[yellow]⚠️ Warning: This will clear all existing graph data![/yellow]")
650 if not typer.confirm("Are you sure you want to continue?", default=False):
651 console.print("[yellow]Import cancelled[/yellow]")
652 return
653
654 console.print(f"[cyan]Importing bundle from {bundle_path}...[/cyan]")
655
656 bundle = CGCBundle(db_manager)
657 success, message = bundle.import_from_bundle(
658 bundle_path,
659 clear_existing=clear
660 )
661
662 if success:
663 console.print(f"[bold green]{message}[/bold green]")
664 else:
665 console.print(f"[bold red]Import failed: {message}[/bold red]")
666 raise typer.Exit(code=1)
667
668 finally:
669 db_manager.close_driver()
670
671@bundle_app.command("load")
672def bundle_load(

Callers 2

bundle_loadFunction · 0.85
registry_downloadFunction · 0.85

Calls 5

import_from_bundleMethod · 0.95
CGCBundleClass · 0.90
_load_credentialsFunction · 0.85
_initialize_servicesFunction · 0.85
close_driverMethod · 0.45

Tested by

no test coverage detected