Skip to content

Commit

Permalink
Update dashboard display name when updating dashboard in deploy (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond authored Jun 21, 2024
1 parent 3d6677d commit 553b007
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/databricks/labs/lsql/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,15 @@ def deploy_dashboard(
) -> SDKDashboard:
"""Deploy a lakeview dashboard."""
serialized_dashboard = json.dumps(lakeview_dashboard.as_dict())
display_name = lakeview_dashboard.pages[0].display_name or lakeview_dashboard.pages[0].name
if dashboard_id is not None:
dashboard = self._ws.lakeview.update(
dashboard_id,
display_name=display_name,
serialized_dashboard=serialized_dashboard,
warehouse_id=warehouse_id,
)
else:
display_name = lakeview_dashboard.pages[0].display_name or lakeview_dashboard.pages[0].name
dashboard = self._ws.lakeview.create(
display_name,
parent_path=parent_path,
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,11 +968,12 @@ def test_dashboards_deploy_calls_update_with_dashboard_id():
dashboards = Dashboards(ws)

dashboard = Dashboard([], [Page("test", [])])
dashboards.deploy_dashboard(dashboard, dashboard_id="test", warehouse_id="warehouse")
dashboards.deploy_dashboard(dashboard, dashboard_id="id", warehouse_id="warehouse")

ws.lakeview.create.assert_not_called()
ws.lakeview.update.assert_called_with(
"test",
"id",
display_name="test",
serialized_dashboard=json.dumps({"pages": [{"name": "test"}]}),
warehouse_id="warehouse",
)
Expand Down

0 comments on commit 553b007

Please sign in to comment.