-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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] Move contextual data from DagsterPowerBITranslator to PowerBITranslatorData #26654
[dagster-powerbi] Move contextual data from DagsterPowerBITranslator to PowerBITranslatorData #26654
Conversation
Is this every going to cause a recursive explosion of data? I guess we are relying on the fact that That's kind of why I was imagining a container class that holds a reference class PowerBITranslatorData:
content: PowerBIContentData
workspace: PowerBIWorkspaceData As it would make the possibility structurally impossible via the type system. Overall this looks good though. |
cb21360
to
9ab65c3
Compare
Deploy preview for dagster-docs ready! Preview available at https://dagster-docs-1mngnv18l-elementl.vercel.app Direct link to changed pages: |
@schrockn in theory, it's not a problem because Currently, That said, after thinking about this, we should not subclass
I updated this PR to make Here's why I think we can move forward with this approach:
|
@@ -78,6 +78,23 @@ class PowerBIContentData: | |||
properties: Dict[str, Any] | |||
|
|||
|
|||
class PowerBITranslatorData(NamedTuple): |
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.
can just make this @record
but not serializable to be consistent with the rest of this interface.
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.
Done in 7c63440
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.
Container class works for me!
adf4154
to
88115b1
Compare
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.
Hey @maximearmstrong I think one thing we could do here to make the transition a little easier would be to implement the properties of PowerBIContentData
on PowerBITranslatorData
. That way the code wouldn't break, just the the typehints.
Meaning
class PowerBITranslatorData:
@property
def content_type(self) -> PowerBIContentType:
return self.content_data.content_type
@schrockn Exactly - that's the current state of this PR. The changes requested here were already implemented in bb5b904 when we switched to using a container class.
I will update this part of this comment to emphasize that code does not break in the current state. |
@@ -21,7 +21,7 @@ class CustomDagsterPowerBITranslator(DagsterPowerBITranslator): | |||
def get_report_spec(self, data: PowerBIContentData) -> dg.AssetSpec: | |||
return ( | |||
super() | |||
.get_report_spec(data) | |||
.get_report_spec(data) # type: ignore |
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.
why new type: ignore?
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.
looks good, let's see if we can get rid of the type ignore in the docs snippet
88115b1
to
24fe471
Compare
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.
Please update PR summary to be accurate (still refers to subclassing)
…to TableauTranslatorData (#26739) ## Summary & Motivation Same as #26654 but for Tableau. ## How I Tested These Changes Updated tests with BK ## Changelog [dagster-tableau] Type hints in the signature of `DagsterTableauTranslator.get_asset_spec` have been updated - the parameter `data` is now of type `TableauTranslatorData` instead of `TableauContentData`. Custom Tableau translators should be updated.
… to LookerApiTranslatorStructureData (#26742) ## Summary & Motivation Same as #26654 but for Looker. ## How I Tested These Changes Updated tests with BK ## Changelog [dagster-looker] Type hints in the signature of `DagsterLookerApiTranslator.get_asset_spec` have been updated - the parameter `looker_structure` is now of type `LookerApiTranslatorStructureData` instead of `LookerStructureData`. Custom Looker API translators should be updated.
…ontainer classes (#26798) ## Summary & Motivation Same as #26654 but for Sigma. ## How I Tested These Changes Updated tests with BK ## Changelog [dagster-sigma] Type hints in the signature of `DagsterLookerApiTranslator.get_asset_spec` have been updated - the parameter `data` is now of type `Union[SigmaDatasetTranslatorData, SigmaWorkbookTranslatorData]` instead of `Union[SigmaDataset, SigmaWorkbook]`. Custom Looker API translators should be updated.
Summary & Motivation
This PR implements
PowerBITranslatorData
, a container class containing aPowerBIContentData
object (props) and aPowerBIWorkspaceData
object (context), to pass contextual data to the translator without breaking theget_asset_spec
signature or requiring context to be passed to the__init__
method of theDagsterPowerBITranslator
.This is PR is an alternative to the proposals mentioned in #26617.
How I Tested These Changes
Updated tests with BK
Changelog
[dagster-powerbi] Type hints in the signature of
DagsterPowerBITranslator.get_asset_spec
have been updated - the parameterdata
is now of typePowerBITranslatorData
instead ofPowerBIContentData
. Custom Power BI translators should be updated.