Skip to content

Commit

Permalink
Add replace catalog functionality to create-dashboard command
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Jul 10, 2024
1 parent 15a23a8 commit 0b51df7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions labs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ commands:
flags:
- name: folder
description: The folder with dashboard files. By default, the current working directory.
- name: Catalog
description: |
Overwrite the catalog in query with given value. Useful when developing with seperated catalogs, for
example, for production and development.
- name: database
description: |
Overwrite the database in query with given value. Useful when developing with seperated databases, for
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fmt = ["isort .",
"mypy .",
"pylint --output-format=colorized -j 0 src"]
verify = ["isort . --check-only",
"ruff .",
"ruff check .",
"mypy .",
"pylint --output-format=colorized -j 0 src"]

Expand Down
5 changes: 4 additions & 1 deletion src/databricks/labs/lsql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def create_dashboard(
w: WorkspaceClient,
folder: Path = Path.cwd(),
*,
catalog: str = "",
database: str = "",
no_open: bool = False,
):
Expand All @@ -24,8 +25,10 @@ def create_dashboard(
lakeview_dashboards = Dashboards(w)
folder = Path(folder)
dashboard_metadata = DashboardMetadata.from_path(folder)
if catalog:
dashboard_metadata = dashboard_metadata.replace_database(catalog=catalog)
if database:
dashboard_metadata = dashboard_metadata.replace_database(database)
dashboard_metadata = dashboard_metadata.replace_database(database=database)
lakeview_dashboard = lakeview_dashboards.create_dashboard(dashboard_metadata)
sdk_dashboard = lakeview_dashboards.deploy_dashboard(lakeview_dashboard)
dashboard_url = f"{w.config.host}/sql/dashboardsv3/{sdk_dashboard.dashboard_id}"
Expand Down

0 comments on commit 0b51df7

Please sign in to comment.