Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dagster-powerbi] Update Power BI docs/examples to use translator instance and PowerBITranslatorData #26735

Open
wants to merge 2 commits into
base: maxime/use-translator-instance-in-load-powerbi-asset-specs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
7 changes: 3 additions & 4 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,8 +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, # type: ignore
dagster_powerbi_translator=CustomDagsterPowerBITranslator(),
)

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