Skip to content

yggdrasil.databricks.loki.base

base

Shared base for the per-service Databricks Loki skills.

Each Databricks service module (sql, table, volume, job, …) ships its own loki.py defining the Loki skill(s) for that service — close to the code they drive, for isolation. They all build on :class:DatabricksServiceSkill here: it guards the workspace session, hands the authenticated client over (agent.databricks — Loki as token provider), carries a precise domain preprompt, and offers the two small helpers every service skill needs (_names to summarize SDK objects, _tabular to take a row set as a frame through the project's Tabular-convertible objects).

DatabricksServiceSkill

Bases: LokiSkill

Base for the Databricks service skills — guards the session for all of them.

The shared preprompt below is the package-level guideline; each service skill overrides :attr:preprompt with its own precise guidance so a model reasoning in that service's context reaches for the right dbc accessor.

available

available(agent: 'Loki') -> bool

True when this skill can run in agent's environment.

Default: available everywhere, unless :attr:requires names a backend that isn't detected. Override for finer checks.

run abstractmethod

run(agent: 'Loki', **kwargs: Any) -> Any

Perform the skill, using agent as the capability/token provider.

names

names(
    items: Any, *, attrs: tuple[str, ...] = ("name", "id", "full_name")
) -> list[Any]

Summarize an iterable of SDK/resource objects to their identifying field.

tabular

tabular(result: Any) -> Any

Take a row set as a polars frame via the object's own conversion.

A Databricks statement result, a Genie answer, an :class:IO leaf — they are all Tabular-convertible, so we don't reshape data by hand: ask the object for the representation we want (to_polars preferred, then pandas, then records). Returns the object unchanged when it isn't tabular.