Skip to content

Dashboard

laktory.models.resources.databricks.Dashboard ¤

Bases: RenderableFileMixin, DashboardBase

Databricks Lakeview Dashboard

Examples:

import io

from laktory import models

dashboard_yaml = '''
display_name: databricks-costs
file_path: ./dashboards/databricks_costs.json
parent_path: /.laktory/dashboards
warehouse_id: a7d9f2kl8mp3q6rt
access_controls:
- group_name: account users
  permission_level: CAN_VIEW
- group_name: role-engineers
  permission_level: CAN_RUN
'''
dashboard = models.resources.databricks.Dashboard.model_validate_yaml(
    io.StringIO(dashboard_yaml)
)

Set render_vars: true to resolve ${vars.x} / ${{ expr }} placeholders found inside the file_path JSON content itself (e.g. a dataset query referencing ${vars.catalog}) before it's uploaded - the resolved content is staged under settings.build_root and never modifies the original file on disk.

import io

from laktory import models

dashboard_yaml = '''
display_name: databricks-costs
file_path: ./dashboards/databricks_costs.json
warehouse_id: a7d9f2kl8mp3q6rt
render_vars: true
variables:
  catalog: dev_catalog
'''
dashboard = models.resources.databricks.Dashboard.model_validate_yaml(
    io.StringIO(dashboard_yaml)
)
References
BASE DESCRIPTION
create_time

TYPE: str | None | VariableType DEFAULT: None

dashboard_change_detected

TYPE: bool | None | VariableType DEFAULT: None

dashboard_id

TYPE: str | None | VariableType DEFAULT: None

dataset_catalog

Sets the default catalog for all datasets in this dashboard. Does not impact table references that use fully qualified catalog names (ex: samples.nyctaxi.trips)

TYPE: str | None | VariableType DEFAULT: None

dataset_schema

Sets the default schema for all datasets in this dashboard. Does not impact table references that use fully qualified catalog names (ex: samples.nyctaxi.trips)

TYPE: str | None | VariableType DEFAULT: None

display_name

The display name of the dashboard

TYPE: str | VariableType

embed_credentials

Whether to embed credentials in the dashboard. Default is true

TYPE: bool | None | VariableType DEFAULT: None

etag

TYPE: str | None | VariableType DEFAULT: None

lifecycle_state

TYPE: str | None | VariableType DEFAULT: None

md5

TYPE: str | None | VariableType DEFAULT: None

path

TYPE: str | None | VariableType DEFAULT: None

serialized_dashboard

The contents of the dashboard in serialized string form. Conflicts with file_path

TYPE: str | None | VariableType DEFAULT: None

update_time

TYPE: str | None | VariableType DEFAULT: None

warehouse_id

The warehouse ID used to run the dashboard

TYPE: str | VariableType

LAKTORY DESCRIPTION
access_controls

Access controls list

TYPE: list[AccessControl | VariableType] | VariableType DEFAULT: []

file_path_

The path to the dashboard JSON file. Conflicts with serialized_dashboard

TYPE: str | None | VariableType DEFAULT: None

name_prefix

Prefix added to the dashboard display name

TYPE: str | VariableType DEFAULT: None

name_suffix

Suffix added to the dashboard display name

TYPE: str | VariableType DEFAULT: None

parent_path_

The path to a workspace folder (inside laktory root) containing the dashboard. If changed, the query will be recreated.

TYPE: str | None | VariableType DEFAULT: None

render_vars

If True, resolve ${vars.x} / ${{ expr }} placeholders in this file's content before upload. Resolved content is staged under settings.build_root; the staged copy is (re)written whenever Stack.build() runs (which preview, deploy, destroy and build all trigger).

TYPE: bool DEFAULT: False

METHOD DESCRIPTION
build

Render ${vars.x}/${{ expr }} placeholders in the dashboard JSON

check_staged

Raise a clear error if this resource is configured for variable

ATTRIBUTE DESCRIPTION
additional_core_resources
  • permissions

TYPE: list

additional_core_resources property ¤

  • permissions

build(vars=None) ¤

Render ${vars.x}/${{ expr }} placeholders in the dashboard JSON content and stage the result under settings.build_root, if render_vars is True. No-op otherwise.

Source code in laktory/models/resources/databricks/dashboard.py
119
120
121
122
123
124
125
126
def build(self, vars: dict = None):
    """
    Render `${vars.x}`/`${{ expr }}` placeholders in the dashboard JSON
    content and stage the result under `settings.build_root`, if
    `render_vars` is `True`. No-op otherwise.
    """
    if self.render_vars and self.file_path_:
        self._render_to_staged_path(self.file_path_, self.file_path, vars=vars)

check_staged() ¤

Raise a clear error if this resource is configured for variable rendering but its staged copy hasn't been written yet (i.e. .build() hasn't run). Guards against programmatic use that bypasses Stack.build() (the normal CLI flow always calls it before dumping resources).

Source code in laktory/models/resources/databricks/_renderablefile.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def check_staged(self):
    """
    Raise a clear error if this resource is configured for variable
    rendering but its staged copy hasn't been written yet (i.e.
    `.build()` hasn't run). Guards against programmatic use that
    bypasses `Stack.build()` (the normal CLI flow always calls it
    before dumping resources).
    """
    if not self.render_vars:
        return
    staged = self._rendered_field_value
    if staged and not Path(staged).exists():
        raise RuntimeError(
            f"'{staged}' has not been rendered yet. Run `laktory build` "
            "(or `preview`/`deploy`, which trigger it automatically) "
            "before this resource is used."
        )