Skip to content

Commit

Permalink
[dagster-powerbi] Update Power BI docs/examples to use translator ins…
Browse files Browse the repository at this point in the history
…tance and PowerBITranslatorData
  • Loading branch information
maximearmstrong committed Dec 27, 2024
1 parent cc5f8b4 commit 007375d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
Binary file modified docs/content/api/modules.json.gz
Binary file not shown.
Binary file modified docs/content/api/searchindex.json.gz
Binary file not shown.
Binary file modified docs/content/api/sections.json.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/content/integrations/powerbi.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ from dagster_powerbi import (
PowerBIWorkspace,
load_powerbi_asset_specs,
)
from dagster_powerbi.translator import PowerBIContentData, PowerBIContentType
from dagster_powerbi.translator import PowerBIContentType, PowerBITranslatorData

import dagster as dg

Expand All @@ -106,7 +106,7 @@ power_bi_workspace = PowerBIWorkspace(
# A translator class lets us customize properties of the built
# Power BI assets, such as the owners or asset key
class MyCustomPowerBITranslator(DagsterPowerBITranslator):
def get_asset_spec(self, data: PowerBIContentData) -> dg.AssetSpec:
def get_asset_spec(self, data: PowerBITranslatorData) -> dg.AssetSpec:
# We create the default asset spec using super()
default_spec = super().get_asset_spec(data)
# We customize the team owner tag for all assets,
Expand All @@ -122,7 +122,7 @@ class MyCustomPowerBITranslator(DagsterPowerBITranslator):


power_bi_specs = load_powerbi_asset_specs(
power_bi_workspace, dagster_powerbi_translator=MyCustomPowerBITranslator
power_bi_workspace, dagster_powerbi_translator=MyCustomPowerBITranslator()
)
defs = dg.Definitions(
assets=[*power_bi_specs], resources={"power_bi": power_bi_workspace}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PowerBIWorkspace,
load_powerbi_asset_specs,
)
from dagster_powerbi.translator import PowerBIContentData, PowerBIContentType
from dagster_powerbi.translator import PowerBIContentType, PowerBITranslatorData

import dagster as dg

Expand All @@ -21,9 +21,9 @@
# A translator class lets us customize properties of the built
# Power BI assets, such as the owners or asset key
class MyCustomPowerBITranslator(DagsterPowerBITranslator):
def get_asset_spec(self, data: PowerBIContentData) -> dg.AssetSpec:
def get_asset_spec(self, data: PowerBITranslatorData) -> dg.AssetSpec:
# We create the default asset spec using super()
default_spec = super().get_asset_spec(data) # type: ignore
default_spec = super().get_asset_spec(data)
# We customize the team owner tag for all assets,
# and we customize the asset key prefix only for dashboards.
return default_spec.replace_attributes(
Expand All @@ -37,8 +37,7 @@ def get_asset_spec(self, data: PowerBIContentData) -> dg.AssetSpec:


power_bi_specs = load_powerbi_asset_specs(
power_bi_workspace,
dagster_powerbi_translator=MyCustomPowerBITranslator, # type: ignore
power_bi_workspace, dagster_powerbi_translator=MyCustomPowerBITranslator()
)
defs = dg.Definitions(
assets=[*power_bi_specs], resources={"power_bi": power_bi_workspace}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
PowerBIWorkspace,
load_powerbi_asset_specs,
)
from dagster_powerbi.translator import PowerBIContentData
from dagster_powerbi.translator import PowerBITranslatorData

power_bi_workspace = PowerBIWorkspace(
credentials=PowerBIServicePrincipal(
Expand All @@ -18,22 +18,22 @@


class CustomDagsterPowerBITranslator(DagsterPowerBITranslator):
def get_report_spec(self, data: PowerBIContentData) -> dg.AssetSpec:
def get_report_spec(self, data: PowerBITranslatorData) -> dg.AssetSpec:
return (
super()
.get_report_spec(data) # type: ignore
.get_report_spec(data)
.replace_attributes(
group_name="reporting",
)
)

def get_semantic_model_spec(self, data: PowerBIContentData) -> dg.AssetSpec:
def get_semantic_model_spec(self, data: PowerBITranslatorData) -> dg.AssetSpec:
upsteam_table_deps = [
dg.AssetKey(table.get("name")) for table in data.properties.get("tables", [])
]
return (
super()
.get_semantic_model_spec(data) # type: ignore
.get_semantic_model_spec(data)
.replace_attributes(
group_name="reporting",
deps=upsteam_table_deps,
Expand All @@ -43,7 +43,7 @@ def get_semantic_model_spec(self, data: PowerBIContentData) -> dg.AssetSpec:

power_bi_specs = load_powerbi_asset_specs(
power_bi_workspace,
dagster_powerbi_translator=CustomDagsterPowerBITranslator,
dagster_powerbi_translator=CustomDagsterPowerBITranslator(),
)

defs = dg.Definitions(assets=[*power_bi_specs], resources={"power_bi": power_bi_workspace})

0 comments on commit 007375d

Please sign in to comment.