Skip to content

Improve object oriented dashboard-as-code implementation#208

Merged
nfx merged 31 commits intomainfrom
fix/improve-oop-dashboard-implementation
Jul 9, 2024
Merged

Improve object oriented dashboard-as-code implementation#208
nfx merged 31 commits intomainfrom
fix/improve-oop-dashboard-implementation

Conversation

@JCZuurmond
Copy link
Copy Markdown
Contributor

Covers the outstanding comments in #201

@JCZuurmond JCZuurmond requested a review from nfx July 9, 2024 11:59
@JCZuurmond JCZuurmond self-assigned this Jul 9, 2024
@JCZuurmond JCZuurmond mentioned this pull request Jul 9, 2024
23 tasks
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jul 9, 2024

✅ 35/35 passed, 3 flaky, 2 skipped, 11m54s total

Flaky tests:

  • 🤪 test_dashboards_deploys_dashboard_with_order_overwrite_in_query_header (31.987s)
  • 🤪 test_dashboard_deploys_dashboard_with_table (35.896s)
  • 🤪 test_dashboards_deploys_dashboard_with_invalid_query (40.744s)

Running from acceptance #281

Copy link
Copy Markdown
Collaborator

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some severe bugs, otherwise looks way cleaner

width = self._metadata.width or default_width
height = self._metadata.height or default_height
self.position = Position(0, 0, width, height)
_position: Position = Position(0, 0, 0, 0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_position: Position = Position(0, 0, 0, 0)
position: Position = Position(0, 0, 0, 0)

otherwise looks a bit ugly... rename def position to def position_or_default

if id_count > 1:
raise ValueError(f"Duplicate id: {tile_id}")

def update(self, other: "DashboardMetadata") -> None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def update(self, other: "DashboardMetadata") -> None:
def merge(self, other: "DashboardMetadata") -> None:

did you mean merge?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named this after the dict.update, see resources in docstring

Copy link
Copy Markdown
Collaborator

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@nfx nfx merged commit 5b288fc into main Jul 9, 2024
@nfx nfx deleted the fix/improve-oop-dashboard-implementation branch July 9, 2024 12:35
@JCZuurmond JCZuurmond mentioned this pull request Jul 9, 2024
nfx pushed a commit that referenced this pull request Jul 10, 2024
nfx added a commit that referenced this pull request Jul 11, 2024
* Added method to dashboards to get dashboard url ([#211](#211)). In this release, we have added a new method `get_url` to the `lakeview_dashboards` object in the `laksedashboard` library. This method utilizes the Databricks SDK to retrieve the dashboard URL, simplifying the code and making it more maintainable. Previously, the dashboard URL was constructed by concatenating the host and dashboard ID, but this new method ensures that the URL is obtained correctly, even if the format changes in the future. Additionally, a new unit test has been added for a method that gets the dashboard URL using the workspace client. This new functionality allows users to easily retrieve the URL for a dashboard using its ID and the workspace client.
* Extend replace database in query ([#210](#210)). This commit extends the database replacement functionality in the `DashboardMetadata` class, allowing users to specify which database and catalog to replace. The enhancement includes support for catalog replacement and a new `replace_database` method in the `DashboardMetadata` class, which replaces the catalog and/or database in the query based on provided parameters. These changes enhance the flexibility and customization of the database replacement feature in queries, making it easier for users to control how their data is displayed in the dashboard. The `create_dashboard` function has also been updated to use the new method for replacing the database and catalog. Additionally, the `TileMetadata` update method has been replaced with a new merge method, and the `QueryTile` and `Tile` classes have new properties and methods for handling content, width, height, and position. The commit also includes several unit tests to ensure the new functionality works as expected.
* Improve object oriented dashboard-as-code implementation ([#208](#208)). In this release, the object-oriented implementation of the dashboard-as-code feature has been significantly improved, addressing previous pull request comments ([#201](#201)). The `TileMetadata` dataclass now includes methods for updating and comparing tile metadata, and the `DashboardMetadata` class has been removed and its functionality incorporated into the `Dashboards` class. The `Dashboards` class now generates tiles, datasets, and layouts for dashboards using the provided `query_transformer`. The code's readability and maintainability have been further enhanced by replacing the use of the `copy` module with `dataclasses.replace` for creating object copies. Additionally, updates have been made to the unit tests for dashboard functionality in the project, with new methods and attributes added to check for valid dashboard metadata and handle duplicate query or widget IDs, as well as to specify the order in which tiles and widgets should be displayed in the dashboard.
@nfx nfx mentioned this pull request Jul 11, 2024
nfx added a commit that referenced this pull request Jul 11, 2024
* Added method to dashboards to get dashboard url
([#211](#211)). In this
release, we have added a new method `get_url` to the
`lakeview_dashboards` object in the `laksedashboard` library. This
method utilizes the Databricks SDK to retrieve the dashboard URL,
simplifying the code and making it more maintainable. Previously, the
dashboard URL was constructed by concatenating the host and dashboard
ID, but this new method ensures that the URL is obtained correctly, even
if the format changes in the future. Additionally, a new unit test has
been added for a method that gets the dashboard URL using the workspace
client. This new functionality allows users to easily retrieve the URL
for a dashboard using its ID and the workspace client.
* Extend replace database in query
([#210](#210)). This commit
extends the database replacement functionality in the
`DashboardMetadata` class, allowing users to specify which database and
catalog to replace. The enhancement includes support for catalog
replacement and a new `replace_database` method in the
`DashboardMetadata` class, which replaces the catalog and/or database in
the query based on provided parameters. These changes enhance the
flexibility and customization of the database replacement feature in
queries, making it easier for users to control how their data is
displayed in the dashboard. The `create_dashboard` function has also
been updated to use the new method for replacing the database and
catalog. Additionally, the `TileMetadata` update method has been
replaced with a new merge method, and the `QueryTile` and `Tile` classes
have new properties and methods for handling content, width, height, and
position. The commit also includes several unit tests to ensure the new
functionality works as expected.
* Improve object oriented dashboard-as-code implementation
([#208](#208)). In this
release, the object-oriented implementation of the dashboard-as-code
feature has been significantly improved, addressing previous pull
request comments
([#201](#201)). The
`TileMetadata` dataclass now includes methods for updating and comparing
tile metadata, and the `DashboardMetadata` class has been removed and
its functionality incorporated into the `Dashboards` class. The
`Dashboards` class now generates tiles, datasets, and layouts for
dashboards using the provided `query_transformer`. The code's
readability and maintainability have been further enhanced by replacing
the use of the `copy` module with `dataclasses.replace` for creating
object copies. Additionally, updates have been made to the unit tests
for dashboard functionality in the project, with new methods and
attributes added to check for valid dashboard metadata and handle
duplicate query or widget IDs, as well as to specify the order in which
tiles and widgets should be displayed in the dashboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants