From d54c53099b2a998657fd49761e2c6dc3d2dbabd9 Mon Sep 17 00:00:00 2001 From: Maxime Armstrong <46797220+maximearmstrong@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:47:09 -0400 Subject: [PATCH] [dagster-tableau] Rename Tableau asset builder fn (#25667) ## 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 --- docs/content/integrations/tableau.mdx | 28 +++++++++---------- .../api/apidocs/libraries/dagster-tableau.rst | 2 +- .../add-tableau-data-quality-warning.py | 14 +++++----- .../refresh-and-materialize-tableau-assets.py | 14 +++++----- .../dagster_tableau/__init__.py | 2 +- .../dagster-tableau/dagster_tableau/assets.py | 4 +-- .../dagster_tableau/resources.py | 4 +-- .../test_reconstruction.py | 12 ++++---- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/docs/content/integrations/tableau.mdx b/docs/content/integrations/tableau.mdx index c2f65f67d0994..2e9b69b79e086 100644 --- a/docs/content/integrations/tableau.mdx +++ b/docs/content/integrations/tableau.mdx @@ -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, ) @@ -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}, ) @@ -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, ) @@ -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}, diff --git a/docs/sphinx/sections/api/apidocs/libraries/dagster-tableau.rst b/docs/sphinx/sections/api/apidocs/libraries/dagster-tableau.rst index 3cfbda434d820..ba400c7e3ab07 100644 --- a/docs/sphinx/sections/api/apidocs/libraries/dagster-tableau.rst +++ b/docs/sphinx/sections/api/apidocs/libraries/dagster-tableau.rst @@ -25,6 +25,6 @@ Assets (Tableau API) .. autofunction:: load_tableau_asset_specs -.. autofunction:: build_tableau_executable_assets_definition +.. autofunction:: build_tableau_materializable_assets_definition diff --git a/examples/docs_snippets/docs_snippets/integrations/tableau/add-tableau-data-quality-warning.py b/examples/docs_snippets/docs_snippets/integrations/tableau/add-tableau-data-quality-warning.py index 767e284f6165d..786a6879fbfb3 100644 --- a/examples/docs_snippets/docs_snippets/integrations/tableau/add-tableau-data-quality-warning.py +++ b/examples/docs_snippets/docs_snippets/integrations/tableau/add-tableau-data-quality-warning.py @@ -1,6 +1,6 @@ from dagster_tableau import ( TableauCloudWorkspace, - build_tableau_executable_assets_definition, + build_tableau_materializable_assets_definition, load_tableau_asset_specs, ) @@ -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}, diff --git a/examples/docs_snippets/docs_snippets/integrations/tableau/refresh-and-materialize-tableau-assets.py b/examples/docs_snippets/docs_snippets/integrations/tableau/refresh-and-materialize-tableau-assets.py index 573df566a2d39..b545e0f53de4e 100644 --- a/examples/docs_snippets/docs_snippets/integrations/tableau/refresh-and-materialize-tableau-assets.py +++ b/examples/docs_snippets/docs_snippets/integrations/tableau/refresh-and-materialize-tableau-assets.py @@ -1,6 +1,6 @@ from dagster_tableau import ( TableauCloudWorkspace, - build_tableau_executable_assets_definition, + build_tableau_materializable_assets_definition, load_tableau_asset_specs, ) @@ -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}, ) diff --git a/python_modules/libraries/dagster-tableau/dagster_tableau/__init__.py b/python_modules/libraries/dagster-tableau/dagster_tableau/__init__.py index ab6d89ffffc6e..17a710fb29950 100644 --- a/python_modules/libraries/dagster-tableau/dagster_tableau/__init__.py +++ b/python_modules/libraries/dagster-tableau/dagster_tableau/__init__.py @@ -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, diff --git a/python_modules/libraries/dagster-tableau/dagster_tableau/assets.py b/python_modules/libraries/dagster-tableau/dagster_tableau/assets.py index 5b40efc757472..55507697ee0a1 100644 --- a/python_modules/libraries/dagster-tableau/dagster_tableau/assets.py +++ b/python_modules/libraries/dagster-tableau/dagster_tableau/assets.py @@ -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. diff --git a/python_modules/libraries/dagster-tableau/dagster_tableau/resources.py b/python_modules/libraries/dagster-tableau/dagster_tableau/resources.py index 7c8c88f3d12d7..4e471d0084692 100644 --- a/python_modules/libraries/dagster-tableau/dagster_tableau/resources.py +++ b/python_modules/libraries/dagster-tableau/dagster_tableau/resources.py @@ -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" @@ -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, diff --git a/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py b/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py index 79e49e196aa6c..245c74b186eb4 100644 --- a/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py +++ b/python_modules/libraries/dagster-tableau/dagster_tableau_tests/test_reconstruction.py @@ -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 @@ -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"] @@ -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},