Skip to content

yggdrasil.cli.databricks.base

base

Abstract base for Databricks-CLI entry points.

:class:DatabricksCLI owns three things every concrete sub-service CLI needs to do the same way:

  1. A shared "Databricks client" argparse group — every workspace credential / discovery flag the :class:DatabricksClient constructor accepts is surfaced here so each sub-service can stop re-declaring them. Use ygg-<service> --help to see the full list.
  2. A single :meth:build_client handshake that filters argparse fields down to DatabricksClient.__init__ kwargs, builds the client, and exits cleanly on construction errors (returning exit code 2).
  3. A :meth:parse_and_run driver that subclasses opt into by exposing a main(argv) module-level function — keeps every sub-service entry point a one-liner.

Subclasses implement:

  • :meth:add_service_arguments to attach service-specific flag groups (the Genie CLI adds Genie defaults, agent options, REPL settings, …).
  • :meth:run — the actual service workload. Receives the parsed argparse namespace and a live :class:DatabricksClient.

Both hooks are deliberately tiny so a new sub-service CLI rarely needs more than a 30-line subclass plus a main wrapper.

DatabricksCLI

DatabricksCLI(client: 'DatabricksClient', args: Namespace)

Bases: ABC

Abstract base for ygg-<service> console scripts.

Concrete subclasses live in yggdrasil.cli.databricks.<service> and expose a module-level main(argv=None) function that simply calls cls.parse_and_run(argv).

Attributes

prog Program name shown in --help. Set on the subclass. description One-line description shown in --help. epilog Optional example block appended to --help output.

build_parser classmethod

build_parser() -> argparse.ArgumentParser

Build the argparse tree: client group + service flags.

add_service_arguments abstractmethod classmethod

add_service_arguments(parser: ArgumentParser) -> None

Attach service-specific flag groups to parser.

Subclasses override to declare their own argument groups. The method runs once per parser build — keep it side-effect-free.

client_kwargs staticmethod

client_kwargs(args: Namespace) -> dict[str, Any]

Return the :class:DatabricksClient kwargs supplied on the CLI.

Skips fields the caller left at None so the client falls back to its env defaults (DATABRICKS_*).

build_client classmethod

build_client(args: Namespace) -> 'DatabricksClient'

Construct the :class:DatabricksClient from CLI args.

Lazy-imports the client so ygg-<service> --help doesn't pay the SDK import cost.

parse_and_run classmethod

parse_and_run(argv: Optional[Sequence[str]] = None) -> int

End-to-end: build parser, parse, build client, dispatch :meth:run.

Returns the process exit code so concrete entry points can return DatabricksCLI.parse_and_run(...).

run abstractmethod

run() -> int

Run the sub-service. Returns a process exit code.