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

Function bundle_load

src/codegraphcontext/cli/main.py:830–891  ·  view source on GitHub ↗

Load a pre-indexed bundle (download if needed, then import). This is a convenience command that will: 1. Check if the bundle exists locally 2. Download from registry if not found 3. Import the bundle into the database Examples: cgc load numpy cgc lo

(
    bundle_name: str = typer.Argument(..., help="Bundle name or path to load (e.g., 'numpy' or 'numpy.cgc')"),
    clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before loading"),
    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

828
829@bundle_app.command("load")
830def bundle_load(
831 bundle_name: str = typer.Argument(..., help="Bundle name or path to load (e.g., 'numpy' or 'numpy.cgc')"),
832 clear: bool = typer.Option(False, "--clear", help="Clear existing graph data before loading"),
833 yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation when using --clear"),
834 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
835):
836 """
837 Load a pre-indexed bundle (download if needed, then import).
838
839 This is a convenience command that will:
840 1. Check if the bundle exists locally
841 2. Download from registry if not found
842 3. Import the bundle into the database
843
844 Examples:
845 cgc load numpy
846 cgc load numpy.cgc --clear
847 cgc load /path/to/bundle.cgc
848 """
849 _load_credentials()
850
851 bundle_path = Path(bundle_name)
852
853 # If it's an absolute path or has .cgc extension and exists, use it directly
854 if bundle_path.is_absolute() or (bundle_path.suffix == '.cgc' and bundle_path.exists()):
855 bundle_import(str(bundle_path), clear=clear, yes=yes, context=context)
856 return
857
858 # Add .cgc extension if not present
859 if not bundle_path.suffix:
860 bundle_path = Path(f"{bundle_name}.cgc")
861
862 # Check if exists locally
863 if bundle_path.exists():
864 console.print(f"[dim]Found local bundle: {bundle_path}[/dim]")
865 bundle_import(str(bundle_path), clear=clear, yes=yes, context=context)
866 return
867
868 # Try to download from registry
869 console.print(f"[yellow]Bundle '{bundle_name}' not found locally.[/yellow]")
870 console.print("[cyan]Attempting to download from registry...[/cyan]")
871
872 try:
873 from .registry_commands import download_bundle
874
875 # Extract just the name (without .cgc extension)
876 name = bundle_path.stem
877
878 # Download the bundle
879 downloaded_path = download_bundle(name, output_dir=None, auto_load=True)
880
881 if downloaded_path:
882 # Import the downloaded bundle
883 bundle_import(downloaded_path, clear=clear, yes=yes, context=context)
884 else:
885 console.print(f"[bold red]Failed to download bundle '{name}'[/bold red]")
886 raise typer.Exit(code=1)
887

Callers 1

load_shortcutFunction · 0.85

Calls 4

_load_credentialsFunction · 0.85
bundle_importFunction · 0.85
download_bundleFunction · 0.85
printMethod · 0.80

Tested by

no test coverage detected