geronimo.cli.config_cmd

Config CLI commands for managing global Geronimo settings.

Provides commands for:

  • geronimo config init - Interactive setup wizard
  • geronimo config set - Set individual values
  • geronimo config show - View current config
  • geronimo config reset - Reset to defaults
  1"""Config CLI commands for managing global Geronimo settings.
  2
  3Provides commands for:
  4- geronimo config init - Interactive setup wizard
  5- geronimo config set <key> <value> - Set individual values
  6- geronimo config show - View current config
  7- geronimo config reset - Reset to defaults
  8"""
  9
 10import typer
 11from rich.panel import Panel
 12from rich.table import Table
 13
 14from geronimo.config.user_config import (
 15    load_user_config,
 16    save_user_config,
 17    set_config_value,
 18    reset_user_config,
 19    USER_CONFIG_FILE,
 20    UserConfig,
 21    ArtifactConfig,
 22    DefaultsConfig,
 23)
 24from geronimo.cli.utils import console, success, dim
 25
 26
 27config_app = typer.Typer(
 28    name="config",
 29    help="Manage global Geronimo configuration.",
 30    no_args_is_help=True,
 31)
 32
 33
 34@config_app.command("init")
 35def config_init():
 36    """Interactive setup wizard for first-time configuration.
 37    
 38    Sets up ~/.geronimo/config.yaml with your preferred defaults.
 39    """
 40    console.print("\n[bold blue]🚀 Geronimo Configuration Setup[/bold blue]\n")
 41    console.print("This wizard will configure your global Geronimo settings.\n")
 42    
 43    # Backend selection
 44    console.print("[bold]Artifact Storage Backend[/bold]")
 45    console.print("  [dim]local[/dim]  - Store artifacts in ~/.geronimo/artifacts")
 46    console.print("  [dim]s3[/dim]     - Store artifacts in your S3 bucket")
 47    console.print("  [dim]gdc[/dim]  - Store artifacts in Geronimo Deploy Cloud (requires auth)\n")
 48    
 49    backend = typer.prompt(
 50        "Select backend",
 51        default="local",
 52        type=str,
 53    )
 54    
 55    if backend not in ("local", "s3", "gdc"):
 56        console.print(f"[red]Invalid backend: {backend}. Using 'local'.[/red]")
 57        backend = "local"
 58    
 59    s3_bucket = None
 60    if backend == "s3":
 61        s3_bucket = typer.prompt(
 62            "S3 bucket name",
 63            default="ml-artifacts",
 64        )
 65    elif backend == "gdc":
 66        console.print("\n[yellow]Note:[/yellow] Deploy Cloud backend requires authentication.")
 67        console.print("Run [bold]geronimo auth login[/bold] to authenticate.\n")
 68    
 69    # Create config
 70    config = UserConfig(
 71        artifacts=ArtifactConfig(
 72            backend=backend,
 73            s3_bucket=s3_bucket,
 74        ),
 75        defaults=DefaultsConfig(),
 76    )
 77    
 78    save_user_config(config)
 79    
 80    console.print(Panel(
 81        f"Configuration saved to [cyan]{USER_CONFIG_FILE}[/cyan]\n\n"
 82        f"  Backend: [green]{backend}[/green]"
 83        + (f"\n  S3 Bucket: [green]{s3_bucket}[/green]" if s3_bucket else ""),
 84        title="✓ Setup Complete",
 85        border_style="green",
 86    ))
 87    
 88    console.print("\nNext steps:")
 89    console.print("  • Run [bold]geronimo init --name my-project[/bold] to create a project")
 90    console.print("  • Run [bold]geronimo config show[/bold] to view your settings\n")
 91
 92
 93@config_app.command("show")
 94def config_show():
 95    """Display current configuration settings."""
 96    config = load_user_config()
 97    
 98    table = Table(title="Geronimo Configuration", show_header=True)
 99    table.add_column("Setting", style="cyan")
100    table.add_column("Value", style="green")
101    
102    # Artifacts section
103    table.add_row("artifacts.backend", config.artifacts.backend)
104    table.add_row("artifacts.s3_bucket", config.artifacts.s3_bucket or "[dim]not set[/dim]")
105    table.add_row("artifacts.base_path", config.artifacts.base_path)
106    
107    # Defaults section
108    table.add_row("defaults.framework", config.defaults.framework)
109    table.add_row("defaults.template", config.defaults.template)
110    
111    console.print()
112    console.print(table)
113    dim(f"\nConfig file: {USER_CONFIG_FILE}\n")
114    
115    # Show auth status for cloud backend
116    if config.artifacts.backend == "gdc":
117        try:
118            from geronimo.cli.auth_cmd import get_current_user
119            user = get_current_user()
120            if user:
121                success(f"Authenticated as {user}")
122            else:
123                console.print("[yellow]âš  GDC backend requires authentication.[/yellow]")
124                console.print("  Run [bold]geronimo auth login[/bold] to authenticate.\n")
125        except Exception:
126            console.print("[yellow]âš  Could not check authentication status.[/yellow]\n")
127
128
129@config_app.command("set")
130def config_set(
131    key: str = typer.Argument(..., help="Config key (e.g., artifacts.backend)"),
132    value: str = typer.Argument(..., help="Value to set"),
133):
134    """Set a configuration value.
135    
136    Examples:
137        geronimo config set artifacts.backend s3
138        geronimo config set artifacts.s3_bucket my-ml-bucket
139    """
140    result = set_config_value(key, value)
141    
142    if result:
143        success(f"Set [cyan]{key}[/cyan] = [green]{value}[/green]")
144    else:
145        console.print(f"[red]✗[/red] Invalid key or value: {key}={value}")
146        console.print("\nValid keys:")
147        console.print("  artifacts.backend   - local, s3, or gdc")
148        console.print("  artifacts.s3_bucket - S3 bucket name")
149        console.print("  artifacts.base_path - Local storage path")
150        console.print("  defaults.framework  - ML framework (sklearn, pytorch, etc.)")
151        console.print("  defaults.template   - Project template (realtime, batch, both)")
152        raise typer.Exit(1)
153
154
155@config_app.command("reset")
156def config_reset(
157    force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation"),
158):
159    """Reset configuration to defaults."""
160    if not force:
161        confirm = typer.confirm("Reset all settings to defaults?")
162        if not confirm:
163            dim("Cancelled.")
164            return
165    
166    reset_user_config()
167    success("Configuration reset to defaults.")
168    dim(f"Removed {USER_CONFIG_FILE}")
config_app = <typer.main.Typer object>
@config_app.command('init')
def config_init():
35@config_app.command("init")
36def config_init():
37    """Interactive setup wizard for first-time configuration.
38    
39    Sets up ~/.geronimo/config.yaml with your preferred defaults.
40    """
41    console.print("\n[bold blue]🚀 Geronimo Configuration Setup[/bold blue]\n")
42    console.print("This wizard will configure your global Geronimo settings.\n")
43    
44    # Backend selection
45    console.print("[bold]Artifact Storage Backend[/bold]")
46    console.print("  [dim]local[/dim]  - Store artifacts in ~/.geronimo/artifacts")
47    console.print("  [dim]s3[/dim]     - Store artifacts in your S3 bucket")
48    console.print("  [dim]gdc[/dim]  - Store artifacts in Geronimo Deploy Cloud (requires auth)\n")
49    
50    backend = typer.prompt(
51        "Select backend",
52        default="local",
53        type=str,
54    )
55    
56    if backend not in ("local", "s3", "gdc"):
57        console.print(f"[red]Invalid backend: {backend}. Using 'local'.[/red]")
58        backend = "local"
59    
60    s3_bucket = None
61    if backend == "s3":
62        s3_bucket = typer.prompt(
63            "S3 bucket name",
64            default="ml-artifacts",
65        )
66    elif backend == "gdc":
67        console.print("\n[yellow]Note:[/yellow] Deploy Cloud backend requires authentication.")
68        console.print("Run [bold]geronimo auth login[/bold] to authenticate.\n")
69    
70    # Create config
71    config = UserConfig(
72        artifacts=ArtifactConfig(
73            backend=backend,
74            s3_bucket=s3_bucket,
75        ),
76        defaults=DefaultsConfig(),
77    )
78    
79    save_user_config(config)
80    
81    console.print(Panel(
82        f"Configuration saved to [cyan]{USER_CONFIG_FILE}[/cyan]\n\n"
83        f"  Backend: [green]{backend}[/green]"
84        + (f"\n  S3 Bucket: [green]{s3_bucket}[/green]" if s3_bucket else ""),
85        title="✓ Setup Complete",
86        border_style="green",
87    ))
88    
89    console.print("\nNext steps:")
90    console.print("  • Run [bold]geronimo init --name my-project[/bold] to create a project")
91    console.print("  • Run [bold]geronimo config show[/bold] to view your settings\n")

Interactive setup wizard for first-time configuration.

Sets up ~/.geronimo/config.yaml with your preferred defaults.

@config_app.command('show')
def config_show():
 94@config_app.command("show")
 95def config_show():
 96    """Display current configuration settings."""
 97    config = load_user_config()
 98    
 99    table = Table(title="Geronimo Configuration", show_header=True)
100    table.add_column("Setting", style="cyan")
101    table.add_column("Value", style="green")
102    
103    # Artifacts section
104    table.add_row("artifacts.backend", config.artifacts.backend)
105    table.add_row("artifacts.s3_bucket", config.artifacts.s3_bucket or "[dim]not set[/dim]")
106    table.add_row("artifacts.base_path", config.artifacts.base_path)
107    
108    # Defaults section
109    table.add_row("defaults.framework", config.defaults.framework)
110    table.add_row("defaults.template", config.defaults.template)
111    
112    console.print()
113    console.print(table)
114    dim(f"\nConfig file: {USER_CONFIG_FILE}\n")
115    
116    # Show auth status for cloud backend
117    if config.artifacts.backend == "gdc":
118        try:
119            from geronimo.cli.auth_cmd import get_current_user
120            user = get_current_user()
121            if user:
122                success(f"Authenticated as {user}")
123            else:
124                console.print("[yellow]âš  GDC backend requires authentication.[/yellow]")
125                console.print("  Run [bold]geronimo auth login[/bold] to authenticate.\n")
126        except Exception:
127            console.print("[yellow]âš  Could not check authentication status.[/yellow]\n")

Display current configuration settings.

@config_app.command('set')
def config_set( key: str = <typer.models.ArgumentInfo object>, value: str = <typer.models.ArgumentInfo object>):
130@config_app.command("set")
131def config_set(
132    key: str = typer.Argument(..., help="Config key (e.g., artifacts.backend)"),
133    value: str = typer.Argument(..., help="Value to set"),
134):
135    """Set a configuration value.
136    
137    Examples:
138        geronimo config set artifacts.backend s3
139        geronimo config set artifacts.s3_bucket my-ml-bucket
140    """
141    result = set_config_value(key, value)
142    
143    if result:
144        success(f"Set [cyan]{key}[/cyan] = [green]{value}[/green]")
145    else:
146        console.print(f"[red]✗[/red] Invalid key or value: {key}={value}")
147        console.print("\nValid keys:")
148        console.print("  artifacts.backend   - local, s3, or gdc")
149        console.print("  artifacts.s3_bucket - S3 bucket name")
150        console.print("  artifacts.base_path - Local storage path")
151        console.print("  defaults.framework  - ML framework (sklearn, pytorch, etc.)")
152        console.print("  defaults.template   - Project template (realtime, batch, both)")
153        raise typer.Exit(1)

Set a configuration value.

Examples: geronimo config set artifacts.backend s3 geronimo config set artifacts.s3_bucket my-ml-bucket

@config_app.command('reset')
def config_reset(force: bool = <typer.models.OptionInfo object>):
156@config_app.command("reset")
157def config_reset(
158    force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation"),
159):
160    """Reset configuration to defaults."""
161    if not force:
162        confirm = typer.confirm("Reset all settings to defaults?")
163        if not confirm:
164            dim("Cancelled.")
165            return
166    
167    reset_user_config()
168    success("Configuration reset to defaults.")
169    dim(f"Removed {USER_CONFIG_FILE}")

Reset configuration to defaults.