Skip to content

Commit

Permalink
[dagster-tableau] Update Tableau docs to use helper parser fn
Browse files Browse the repository at this point in the history
  • Loading branch information
maximearmstrong committed Oct 31, 2024
1 parent f753cdf commit a06d4e4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 45 deletions.
30 changes: 8 additions & 22 deletions docs/content/integrations/tableau.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ from dagster_tableau import (
TableauCloudWorkspace,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
parse_tableau_external_and_materializable_asset_specs,
)

import dagster as dg
Expand All @@ -209,17 +210,9 @@ tableau_specs = load_tableau_asset_specs(
workspace=tableau_workspace,
)

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

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

# Use the asset definition builder to construct the definition for tableau materializable assets
defs = dg.Definitions(
Expand All @@ -246,6 +239,7 @@ from dagster_tableau import (
TableauCloudWorkspace,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
parse_tableau_external_and_materializable_asset_specs,
)

import dagster as dg
Expand Down Expand Up @@ -288,17 +282,9 @@ tableau_specs = load_tableau_asset_specs(
workspace=tableau_workspace,
)

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

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

# Pass the sensor, Tableau resource, upstream asset, Tableau assets specs and materializable assets definition at once
defs = dg.Definitions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Assets (Tableau API)

.. autofunction:: build_tableau_materializable_assets_definition


.. autofunction:: parse_tableau_external_and_materializable_asset_specs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
TableauCloudWorkspace,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
parse_tableau_external_and_materializable_asset_specs,
)

import dagster as dg
Expand Down Expand Up @@ -44,17 +45,9 @@ def tableau_run_failure_sensor(
workspace=tableau_workspace,
)

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

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

# Pass the sensor, Tableau resource, upstream asset, Tableau assets specs and materializable assets definition at once
defs = dg.Definitions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
TableauCloudWorkspace,
build_tableau_materializable_assets_definition,
load_tableau_asset_specs,
parse_tableau_external_and_materializable_asset_specs,
)

import dagster as dg
Expand All @@ -20,17 +21,9 @@
workspace=tableau_workspace,
)

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

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

# Use the asset definition builder to construct the definition for tableau materializable assets
defs = dg.Definitions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
def parse_tableau_external_and_materializable_asset_specs(
specs: Sequence[AssetSpec],
) -> Tuple[Sequence[AssetSpec], Sequence[AssetSpec]]:
"""Parses a list of Tableau AssetSpecs provided as input and return two lists of AssetSpecs,
one for the Tableau external assets and another one for the Tableau materializable assets.
In Tableau, data sources are considered external assets,
while sheets and dashboards are considered materializable assets.
"""
external_asset_specs = [
spec for spec in specs if TableauTagSet.extract(spec.tags).asset_type == "data_source"
]
Expand Down

0 comments on commit a06d4e4

Please sign in to comment.