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-tableau] Update custom translator example in Tableau docs #26029

Merged

Conversation

maximearmstrong
Copy link
Contributor

@maximearmstrong maximearmstrong commented Nov 20, 2024

Summary & Motivation

Update the custom translator example in the Tableau docs to reflect get_asset_spec().key.

This PR stack will be merged after #25941 lands, so that replace_attributes() can be called as AssetSpec().replace_attributes()

@maximearmstrong maximearmstrong force-pushed the maxime/deprecate-get-asset-key-tableau-translator branch from 1afa7bc to 142f9ce Compare November 20, 2024 02:44
@maximearmstrong maximearmstrong force-pushed the maxime/update-tableau-docs-asset-key-translator branch from fed411e to 5dfc4b2 Compare November 20, 2024 02:44
@maximearmstrong maximearmstrong self-assigned this Nov 20, 2024
@maximearmstrong maximearmstrong marked this pull request as ready for review November 20, 2024 02:48
# We create the default asset spec using super()
default_spec = super().get_asset_spec(data)
# We customize the metadata and asset key prefix for all assets, including sheets
return replace_attributes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use default_spec.replace_attributes, once that merges?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can reduce the verbosity of this a bit once that merges - no need to set default_spec & can just do return super().get_asset_spec(data).replace_attributes(....)

Copy link
Contributor Author

@maximearmstrong maximearmstrong Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to use default_spec.replace_attributes, once that merges?

Definitely - it's mentioned in the PR description, but I could have added a comment here to make it clearer. I will wait for #25941 to land before merging the PR stack.

I think we can reduce the verbosity of this a bit once that merges - no need to set default_spec & can just do return super().get_asset_spec(data).replace_attributes(....)

I think it works if we keep the comment and note after the code snippet.

Copy link
Contributor Author

@maximearmstrong maximearmstrong Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can reduce the verbosity of this a bit once that merges - no need to set default_spec & can just do return super().get_asset_spec(data).replace_attributes(....)

Actually, we reuse default_spec in the parameters of replace_attributes, so we should keep super().get_asset_spec(data) and replace_attributes(....) to avoid calling super() again to access the asset key. Otherwise we get this:

return super().get_asset_spec(data).replace_attributes(
    key=super().get_asset_spec(data).key.with_prefix("my_prefix")
)

Also, having default_spec = super().get_asset_spec(data) puts the emphasis on creating the default spec first.

# We customize the team owner tag only for sheets
return replace_attributes(default_spec, owners=["team:my_team"])

def get_asset_spec(self, data: TableauContentData) -> dg.AssetSpec:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense for a user to want to override both get_asset_spec and get_sheet_spec? I find this a little confusing since I would imagine the typical case would be to either override one or more of the "object-level" spec methods, or just get_asset_spec?

Maybe we ought to just consolidate on overriding get_asset_spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair - will update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5eeb24c

@maximearmstrong maximearmstrong force-pushed the maxime/deprecate-get-asset-key-tableau-translator branch from 142f9ce to 43ea996 Compare November 20, 2024 14:08
@maximearmstrong maximearmstrong force-pushed the maxime/update-tableau-docs-asset-key-translator branch from 5dfc4b2 to 5eeb24c Compare November 20, 2024 14:08
@neverett neverett added the docs-to-migrate Docs to migrate to new docs site label Nov 20, 2024
Copy link
Contributor

@neverett neverett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One tiny copyedit, otherwise looks good to me!

@@ -104,17 +104,18 @@ defs = dg.Definitions(assets=[*tableau_specs], resources={"tableau": tableau_wor

### Customize asset definition metadata for Tableau assets

By default, Dagster will generate asset keys for each Tableau asset based on its type and name and populate default metadata. You can further customize asset properties by passing a custom <PyObject module="dagster_tableau" object="DagsterTableauTranslator" /> subclass to the <PyObject module="dagster_tableau" method="load_tableau_asset_specs" /> function. This subclass can implement methods to customize the asset keys or specs for each Tableau asset type.
By default, Dagster will generate asset specs for each Tableau asset based on its type and populate default metadata. You can further customize asset properties by passing a custom <PyObject module="dagster_tableau" object="DagsterTableauTranslator" /> subclass to the <PyObject module="dagster_tableau" method="load_tableau_asset_specs" /> function. This subclass can implement methods to customize the asset specs for each Tableau asset type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, Dagster will generate asset specs for each Tableau asset based on its type and populate default metadata. You can further customize asset properties by passing a custom <PyObject module="dagster_tableau" object="DagsterTableauTranslator" /> subclass to the <PyObject module="dagster_tableau" method="load_tableau_asset_specs" /> function. This subclass can implement methods to customize the asset specs for each Tableau asset type.
By default, Dagster will generate asset specs for each Tableau asset based on its type, and populate default metadata. You can further customize asset properties by passing a custom <PyObject module="dagster_tableau" object="DagsterTableauTranslator" /> subclass to the <PyObject module="dagster_tableau" method="load_tableau_asset_specs" /> function. This subclass can implement methods to customize the asset specs for each Tableau asset type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b80eee2

@maximearmstrong maximearmstrong force-pushed the maxime/deprecate-get-asset-key-tableau-translator branch from 43ea996 to 2ac721a Compare November 20, 2024 17:58
@maximearmstrong maximearmstrong force-pushed the maxime/update-tableau-docs-asset-key-translator branch from 7268d91 to b80eee2 Compare November 20, 2024 17:58
@maximearmstrong maximearmstrong force-pushed the maxime/deprecate-get-asset-key-tableau-translator branch from 2ac721a to de029db Compare November 25, 2024 19:08
@maximearmstrong maximearmstrong force-pushed the maxime/update-tableau-docs-asset-key-translator branch from b80eee2 to c34154e Compare November 25, 2024 19:08
@maximearmstrong maximearmstrong force-pushed the maxime/deprecate-get-asset-key-tableau-translator branch from de029db to 3c9210b Compare November 25, 2024 19:33
@maximearmstrong maximearmstrong force-pushed the maxime/update-tableau-docs-asset-key-translator branch from c34154e to 3abd4e3 Compare November 25, 2024 19:34
Base automatically changed from maxime/deprecate-get-asset-key-tableau-translator to master November 25, 2024 19:57
@maximearmstrong maximearmstrong force-pushed the maxime/update-tableau-docs-asset-key-translator branch from 3abd4e3 to 4d3e03e Compare November 25, 2024 19:57
@maximearmstrong maximearmstrong merged commit 94bcd2a into master Nov 25, 2024
2 checks passed
@maximearmstrong maximearmstrong deleted the maxime/update-tableau-docs-asset-key-translator branch November 25, 2024 20:20
maximearmstrong added a commit that referenced this pull request Nov 25, 2024
maximearmstrong added a commit that referenced this pull request Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-to-migrate Docs to migrate to new docs site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants