Skip to content

Commit

Permalink
Remove deploy_dashboard method (#240)
Browse files Browse the repository at this point in the history
Resolves #232
  • Loading branch information
JCZuurmond authored Aug 13, 2024
1 parent df83fe2 commit e2f2586
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 47 deletions.
11 changes: 0 additions & 11 deletions src/databricks/labs/lsql/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import math
import re
import shlex
import tempfile
import warnings
from argparse import ArgumentParser
from collections import defaultdict
from collections.abc import Callable, Iterable, Sized
Expand Down Expand Up @@ -962,15 +960,6 @@ def create_dashboard(
self._ws.lakeview.publish(sdk_dashboard.dashboard_id, warehouse_id=warehouse_id)
return sdk_dashboard

def deploy_dashboard(self, dashboard: Dashboard, **kwargs) -> SDKDashboard:
"""Legacy method use :meth:create_dashboard instead."""
warnings.warn("Deprecated method use `create_dashboard` instead.", category=DeprecationWarning)
with tempfile.TemporaryDirectory() as directory:
path = Path(directory)
self.save_to_folder(dashboard, path)
dashboard_metadata = DashboardMetadata.from_path(path)
return self.create_dashboard(dashboard_metadata, **kwargs)

def _with_better_names(self, dashboard: Dashboard) -> Dashboard:
"""Replace names with human-readable names."""
better_names = {}
Expand Down
18 changes: 1 addition & 17 deletions tests/integration/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,6 @@ def test_dashboard_deploys_dashboard_with_empty_title(ws, make_dashboard, tmp_pa
assert ws.lakeview.get(sdk_dashboard.dashboard_id)


def test_dashboards_creates_dashboard_via_legacy_method(ws, make_dashboard, tmp_path):
dashboards = Dashboards(ws)
sdk_dashboard = make_dashboard()

(tmp_path / "a.md").write_text("Below you see counters.")
for count, query_name in enumerate("bcdefg"):
(tmp_path / f"{query_name}.sql").write_text(f"SELECT {count} AS count")
dashboard_metadata = DashboardMetadata.from_path(tmp_path)
dashboard = dashboard_metadata.as_lakeview()

sdk_dashboard = dashboards.deploy_dashboard(dashboard, dashboard_id=sdk_dashboard.dashboard_id)

assert ws.lakeview.get(sdk_dashboard.dashboard_id)


def test_dashboards_creates_dashboard_with_replace_database(ws, make_dashboard, tmp_path, sql_backend, make_schema):
dashboards = Dashboards(ws)
sdk_dashboard = make_dashboard()
Expand All @@ -347,8 +332,7 @@ def test_dashboards_creates_dashboard_with_replace_database(ws, make_dashboard,
"""
(tmp_path / "counter.sql").write_text(query)
dashboard_metadata = DashboardMetadata.from_path(tmp_path).replace_database(database=schema.full_name)
dashboard = dashboard_metadata.as_lakeview()

sdk_dashboard = dashboards.deploy_dashboard(dashboard, dashboard_id=sdk_dashboard.dashboard_id)
sdk_dashboard = dashboards.create_dashboard(dashboard_metadata, dashboard_id=sdk_dashboard.dashboard_id)

assert ws.lakeview.get(sdk_dashboard.dashboard_id)
19 changes: 0 additions & 19 deletions tests/unit/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,25 +1496,6 @@ def test_dashboard_raises_value_error_when_creating_dashboard_with_invalid_queri
ws.assert_not_called()


def test_dashboard_warns_deploy_dashboard_is_deprecated():
ws = create_autospec(WorkspaceClient)
dashboards = Dashboards(ws)
dashboard = Dashboard([], [Page("test", [])])

with pytest.deprecated_call():
dashboards.deploy_dashboard(dashboard)
ws.lakeview.create.assert_called_once()


def test_dashboard_deploys_dashboard():
ws = create_autospec(WorkspaceClient)
dashboards = Dashboards(ws)
dashboard = Dashboard([], [Page("test", [])])

dashboards.deploy_dashboard(dashboard)
ws.assert_not_called()


def test_dashboards_save_to_folder_replaces_dataset_names_with_display_names(tmp_path):
ws = create_autospec(WorkspaceClient)
dashboards = Dashboards(ws)
Expand Down

0 comments on commit e2f2586

Please sign in to comment.