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:
- A shared
"Databricks client"argparse group — every workspace credential / discovery flag the :class:DatabricksClientconstructor accepts is surfaced here so each sub-service can stop re-declaring them. Useygg-<service> --helpto see the full list. - A single :meth:
build_clienthandshake that filters argparse fields down toDatabricksClient.__init__kwargs, builds the client, and exits cleanly on construction errors (returning exit code 2). - A :meth:
parse_and_rundriver that subclasses opt into by exposing amain(argv)module-level function — keeps every sub-service entry point a one-liner.
Subclasses implement:
- :meth:
add_service_argumentsto 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 ¶
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 the argparse tree: client group + service flags.
add_service_arguments
abstractmethod
classmethod
¶
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
¶
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
¶
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
¶
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(...).