Skip to content

Commit

Permalink
[dagster-tableau] Rename Tableau asset builder fn (#25667)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Updates fn name to `build_tableau_materializable_asset_definitions` to
be consistent with Dagster external vs materializable assets.

Subsequent PR will add an asset spec parser function that users could
use to split their asset specs in external and materializable asset
specs - the goal is to make the Tableau boilerplate more elegant and
easy to implement.

## How I Tested These Changes

Updated tests
  • Loading branch information
maximearmstrong authored Oct 31, 2024
1 parent e41646a commit d54c530
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
28 changes: 14 additions & 14 deletions docs/content/integrations/tableau.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ You can use Dagster to refresh Tableau workbooks and materialize Tableau sheets
```python file=/integrations/tableau/refresh-and-materialize-tableau-assets.py
from dagster_tableau import (
TableauCloudWorkspace,
build_tableau_executable_assets_definition,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
)

Expand All @@ -209,27 +209,27 @@ tableau_specs = load_tableau_asset_specs(
workspace=tableau_workspace,
)

non_executable_asset_specs = [
external_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") == "data_source"
]

executable_asset_specs = [
materializable_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") in ["dashboard", "sheet"]
]

# Use the asset definition builder to construct the definition for tableau executable assets
# Use the asset definition builder to construct the definition for tableau materializable assets
defs = dg.Definitions(
assets=[
build_tableau_executable_assets_definition(
build_tableau_materializable_assets_definition(
resource_key="tableau",
specs=executable_asset_specs,
specs=materializable_asset_specs,
refreshable_workbook_ids=["b75fc023-a7ca-4115-857b-4342028640d0"],
),
*non_executable_asset_specs,
*external_asset_specs,
],
resources={"tableau": tableau_workspace},
)
Expand All @@ -244,7 +244,7 @@ When an upstream dependency of a Tableau asset fails to materialize or to pass t
```python file=/integrations/tableau/add-tableau-data-quality-warning.py
from dagster_tableau import (
TableauCloudWorkspace,
build_tableau_executable_assets_definition,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
)

Expand Down Expand Up @@ -288,28 +288,28 @@ tableau_specs = load_tableau_asset_specs(
workspace=tableau_workspace,
)

non_executable_asset_specs = [
external_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") == "data_source"
]

executable_asset_specs = [
materializable_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") in ["dashboard", "sheet"]
]

# Pass the sensor, Tableau resource, upstream asset, Tableau assets specs and executable assets definition at once
# Pass the sensor, Tableau resource, upstream asset, Tableau assets specs and materializable assets definition at once
defs = dg.Definitions(
assets=[
upstream_asset,
build_tableau_executable_assets_definition(
build_tableau_materializable_assets_definition(
resource_key="tableau",
specs=executable_asset_specs,
specs=materializable_asset_specs,
refreshable_workbook_ids=["b75fc023-a7ca-4115-857b-4342028640d0"],
),
*non_executable_asset_specs,
*external_asset_specs,
],
sensors=[tableau_run_failure_sensor],
resources={"tableau": tableau_workspace},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Assets (Tableau API)

.. autofunction:: load_tableau_asset_specs

.. autofunction:: build_tableau_executable_assets_definition
.. autofunction:: build_tableau_materializable_assets_definition


Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dagster_tableau import (
TableauCloudWorkspace,
build_tableau_executable_assets_definition,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
)

Expand Down Expand Up @@ -44,28 +44,28 @@ def tableau_run_failure_sensor(
workspace=tableau_workspace,
)

non_executable_asset_specs = [
external_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") == "data_source"
]

executable_asset_specs = [
materializable_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") in ["dashboard", "sheet"]
]

# Pass the sensor, Tableau resource, upstream asset, Tableau assets specs and executable assets definition at once
# Pass the sensor, Tableau resource, upstream asset, Tableau assets specs and materializable assets definition at once
defs = dg.Definitions(
assets=[
upstream_asset,
build_tableau_executable_assets_definition(
build_tableau_materializable_assets_definition(
resource_key="tableau",
specs=executable_asset_specs,
specs=materializable_asset_specs,
refreshable_workbook_ids=["b75fc023-a7ca-4115-857b-4342028640d0"],
),
*non_executable_asset_specs,
*external_asset_specs,
],
sensors=[tableau_run_failure_sensor],
resources={"tableau": tableau_workspace},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dagster_tableau import (
TableauCloudWorkspace,
build_tableau_executable_assets_definition,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
)

Expand All @@ -20,27 +20,27 @@
workspace=tableau_workspace,
)

non_executable_asset_specs = [
external_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") == "data_source"
]

executable_asset_specs = [
materializable_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") in ["dashboard", "sheet"]
]

# Use the asset definition builder to construct the definition for tableau executable assets
# Use the asset definition builder to construct the definition for tableau materializable assets
defs = dg.Definitions(
assets=[
build_tableau_executable_assets_definition(
build_tableau_materializable_assets_definition(
resource_key="tableau",
specs=executable_asset_specs,
specs=materializable_asset_specs,
refreshable_workbook_ids=["b75fc023-a7ca-4115-857b-4342028640d0"],
),
*non_executable_asset_specs,
*external_asset_specs,
],
resources={"tableau": tableau_workspace},
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from dagster._core.libraries import DagsterLibraryRegistry

from dagster_tableau.assets import (
build_tableau_executable_assets_definition as build_tableau_executable_assets_definition,
build_tableau_materializable_assets_definition as build_tableau_materializable_assets_definition,
)
from dagster_tableau.resources import (
TableauCloudWorkspace as TableauCloudWorkspace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@


@experimental
def build_tableau_executable_assets_definition(
def build_tableau_materializable_assets_definition(
resource_key: str,
specs: Sequence[AssetSpec],
refreshable_workbook_ids: Optional[Sequence[str]] = None,
) -> AssetsDefinition:
"""Returns the AssetsDefinition of the executable assets in the Tableau workspace.
"""Returns the AssetsDefinition of the materializable assets in the Tableau workspace.
Args:
resource_key (str): The resource key to use for the Tableau resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def build_defs(
Returns:
Definitions: A Definitions object which will build and return the Power BI content.
"""
from dagster_tableau.assets import build_tableau_executable_assets_definition
from dagster_tableau.assets import build_tableau_materializable_assets_definition

resource_key = "tableau"

Expand All @@ -508,7 +508,7 @@ def build_defs(

return Definitions(
assets=[
build_tableau_executable_assets_definition(
build_tableau_materializable_assets_definition(
resource_key=resource_key,
specs=executable_asset_specs,
refreshable_workbook_ids=refreshable_workbook_ids,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dagster._core.execution.api import create_execution_plan, execute_plan
from dagster._core.instance_for_test import instance_for_test
from dagster._utils.test.definitions import lazy_definitions
from dagster_tableau.assets import build_tableau_executable_assets_definition
from dagster_tableau.assets import build_tableau_materializable_assets_definition
from dagster_tableau.resources import TableauCloudWorkspace, load_tableau_asset_specs
from dagster_tableau.translator import DagsterTableauTranslator

Expand Down Expand Up @@ -43,13 +43,13 @@ def cacheable_asset_defs_refreshable_workbooks():
workspace=resource,
)

non_executable_asset_specs = [
external_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") == "data_source"
]

executable_asset_specs = [
materializable_asset_specs = [
spec
for spec in tableau_specs
if spec.tags.get("dagster-tableau/asset_type") in ["dashboard", "sheet"]
Expand All @@ -59,12 +59,12 @@ def cacheable_asset_defs_refreshable_workbooks():

return Definitions(
assets=[
build_tableau_executable_assets_definition(
build_tableau_materializable_assets_definition(
resource_key=resource_key,
specs=executable_asset_specs,
specs=materializable_asset_specs,
refreshable_workbook_ids=["b75fc023-a7ca-4115-857b-4342028640d0"],
),
*non_executable_asset_specs,
*external_asset_specs,
],
jobs=[define_asset_job("all_asset_job")],
resources={resource_key: resource},
Expand Down

2 comments on commit d54c530

@github-actions
Copy link

Choose a reason for hiding this comment

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

Deploy preview for dagster-docs ready!

✅ Preview
https://dagster-docs-2wk6n2f26-elementl.vercel.app
https://master.dagster.dagster-docs.io

Built with commit d54c530.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

@github-actions github-actions bot commented on d54c530 Oct 31, 2024

Choose a reason for hiding this comment

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

Deploy preview for dagster-docs-beta ready!

✅ Preview
https://dagster-docs-beta-bzw83ai8d-elementl.vercel.app

Built with commit d54c530.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.