-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dagster-tableau] Update Tableau docs with custom materialization exa…
…mple (#25672) ## Summary & Motivation As title.
- Loading branch information
1 parent
f84b5b8
commit b7dafbd
Showing
2 changed files
with
125 additions
and
0 deletions.
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
59 changes: 59 additions & 0 deletions
59
...s/docs_snippets/docs_snippets/integrations/tableau/materialize-tableau-assets-advanced.py
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,59 @@ | ||
from typing import Sequence | ||
|
||
from dagster_tableau import ( | ||
TableauCloudWorkspace, | ||
load_tableau_asset_specs, | ||
parse_tableau_external_and_materializable_asset_specs, | ||
) | ||
|
||
import dagster as dg | ||
|
||
tableau_workspace = TableauCloudWorkspace( | ||
connected_app_client_id=dg.EnvVar("TABLEAU_CONNECTED_APP_CLIENT_ID"), | ||
connected_app_secret_id=dg.EnvVar("TABLEAU_CONNECTED_APP_SECRET_ID"), | ||
connected_app_secret_value=dg.EnvVar("TABLEAU_CONNECTED_APP_SECRET_VALUE"), | ||
username=dg.EnvVar("TABLEAU_USERNAME"), | ||
site_name=dg.EnvVar("TABLEAU_SITE_NAME"), | ||
pod_name=dg.EnvVar("TABLEAU_POD_NAME"), | ||
) | ||
|
||
|
||
# Assets definition factory which triggers workbooks refresh and sends a notification once complete | ||
def build_tableau_materialize_and_notify_asset_def( | ||
specs: Sequence[dg.AssetSpec], refreshable_workbook_ids: Sequence[str] | ||
) -> dg.AssetsDefinition: | ||
@dg.multi_asset( | ||
name="tableau_sync", | ||
compute_kind="tableau", | ||
specs=specs, | ||
) | ||
def asset_fn(context: dg.AssetExecutionContext, tableau: TableauCloudWorkspace): | ||
with tableau.get_client() as client: | ||
yield from client.refresh_and_materialize_workbooks( | ||
specs=specs, refreshable_workbook_ids=refreshable_workbook_ids | ||
) | ||
# Do some custom work after refreshing here, such as sending an email notification | ||
|
||
return asset_fn | ||
|
||
|
||
# Load Tableau asset specs | ||
tableau_specs = load_tableau_asset_specs( | ||
workspace=tableau_workspace, | ||
) | ||
|
||
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( | ||
assets=[ | ||
build_tableau_materialize_and_notify_asset_def( | ||
specs=materializable_asset_specs, | ||
refreshable_workbook_ids=["b75fc023-a7ca-4115-857b-4342028640d0"], | ||
), | ||
*external_asset_specs, | ||
], | ||
resources={"tableau": tableau_workspace}, | ||
) |
b7dafbd
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.
Deploy preview for dagster-docs ready!
✅ Preview
https://dagster-docs-mgn07a0jb-elementl.vercel.app
https://master.dagster.dagster-docs.io
Built with commit b7dafbd.
This pull request is being automatically deployed with vercel-action