-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dashboard-as-code functionality #201
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
4677acb
Create table from query with multiple columns and introduce tiles (#150)
JCZuurmond cb8eb56
Add cli command (#153)
JCZuurmond 2c2e5bf
Fix widget order is zero (#162)
JCZuurmond 83b0a27
Support header for markdown files (#161)
JCZuurmond 4864bb4
Make default markdown height `3` (#178)
JCZuurmond e2df766
Adjust test with default markdown height `3` (#179)
JCZuurmond 217fac4
Overwrite database in query (#164)
JCZuurmond 6f29448
Solve when query starts with cte (#176)
JCZuurmond 5772be5
Fix query format after transforming (#182)
JCZuurmond adc8f08
Fix handeling partially (in)correct metadata (#183)
JCZuurmond aa2f325
Add multi select filter(s) (#181)
JCZuurmond e6f5b8a
Pass parent path to lakeview create in dashboard deploy (#184)
JCZuurmond 3d6677d
Support passing warehouse id to lakeview endpoint when deploying dash…
JCZuurmond 553b007
Update dashboard display name when updating dashboard in deploy (#186)
JCZuurmond 33bd0eb
Add `--spec` flag (#188)
JCZuurmond c9eb6d9
Fix incorrect spec (#192)
JCZuurmond 5f380fa
Fix incorrect spec conversion (#193)
JCZuurmond aa07cfd
Rename spec flag to type (#194)
JCZuurmond d774e94
Update supported arguments in docs (#189)
JCZuurmond 3b84ce7
Revert table to use TableV1Spec (#190)
JCZuurmond cde70a5
Fix description and titles not being given (#197)
JCZuurmond 51ba666
Fix tablev1 spec (#196)
JCZuurmond f9d3c32
Support tile order in dashboard yml (#198)
JCZuurmond 7945520
Allow overriding lower level Lakeview settings (#195)
JCZuurmond 9e35389
Raise NotImplementedError when encountering star in query (#203)
JCZuurmond b384fdd
Format
JCZuurmond ec8614e
Update integration test with counter column that has spaces (#204)
JCZuurmond 5412ec6
Fix integration test dashboard file collision (#205)
JCZuurmond a8c4d37
Update docs
JCZuurmond 7ad99bc
Refactor _id to id
JCZuurmond b9d4041
Refactor __or__ to update
JCZuurmond 3ab32dc
Separate continues in Tilemetadata.as_dict
JCZuurmond 17794df
Refactor _tile_metadata to _metadata in Tile
JCZuurmond 03eeedb
Fix continue
JCZuurmond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: lsql | ||
description: Lightweight SQL execution wrapper only on top of Databricks SDK | ||
entrypoint: src/databricks/labs/lsql/cli.py | ||
min_python: 3.10 | ||
commands: | ||
- name: create-dashboard | ||
description: Create an unpublished dashboard from code, see [docs](./docs/dashboards.md). | ||
flags: | ||
- name: folder | ||
description: The folder with dashboard files. By default, the current working directory. | ||
- name: database | ||
description: | | ||
Overwrite the database in query with given value. Useful when developing with seperated databases, for | ||
example, for production and development. | ||
- name: no-open | ||
description: Do not open the dashboard in the browser after creating |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .core import Row | ||
from databricks.labs.lsql.core import Row | ||
|
||
__all__ = ["Row"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import functools | ||
import webbrowser | ||
from pathlib import Path | ||
|
||
from databricks.labs.blueprint.cli import App | ||
from databricks.labs.blueprint.entrypoint import get_logger | ||
from databricks.sdk import WorkspaceClient | ||
|
||
from databricks.labs.lsql import dashboards | ||
from databricks.labs.lsql.dashboards import Dashboards | ||
|
||
logger = get_logger(__file__) | ||
lsql = App(__file__) | ||
|
||
|
||
@lsql.command | ||
def create_dashboard( | ||
w: WorkspaceClient, | ||
folder: Path = Path.cwd(), | ||
*, | ||
database: str = "", | ||
no_open: bool = False, | ||
): | ||
"""Create a dashboard from queries""" | ||
logger.debug("Creating dashboard ...") | ||
lakeview_dashboards = Dashboards(w) | ||
folder = Path(folder) | ||
replace_database_in_query = None | ||
if database: | ||
replace_database_in_query = functools.partial(dashboards.replace_database_in_query, database=database) | ||
lakeview_dashboard = lakeview_dashboards.create_dashboard(folder, query_transformer=replace_database_in_query) | ||
sdk_dashboard = lakeview_dashboards.deploy_dashboard(lakeview_dashboard) | ||
dashboard_url = f"{w.config.host}/sql/dashboardsv3/{sdk_dashboard.dashboard_id}" | ||
if not no_open: | ||
webbrowser.open(dashboard_url) | ||
print(sdk_dashboard.dashboard_id) | ||
|
||
|
||
if __name__ == "__main__": | ||
lsql() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pending more changes in the other PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #208