-
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
[11/n][dagster-fivetran] Implement materialization method in FivetranWorkspace #25961
Conversation
FivetranWorkspaceData
to FivetranConnectorTableProps
method
#25797
python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py
Outdated
Show resolved
Hide resolved
python_modules/libraries/dagster-fivetran/dagster_fivetran/resources.py
Outdated
Show resolved
Hide resolved
0521c7f
to
6e115f1
Compare
0e0b1e2
to
78fe129
Compare
6e115f1
to
e07232e
Compare
78fe129
to
d3f1bf6
Compare
e07232e
to
3be662b
Compare
d3f1bf6
to
b9e54d6
Compare
3be662b
to
5a87eb7
Compare
b417e4e
to
3150e3e
Compare
ebe8457
to
748298f
Compare
c16e280
to
2df7622
Compare
d2fa78b
to
67d0fcd
Compare
2df7622
to
3317a7d
Compare
67d0fcd
to
6cf70a0
Compare
3317a7d
to
b0e8961
Compare
materialized_asset_keys.add(materialization.asset_key) | ||
else: | ||
context.log.warning( | ||
f"An unexpected asset was materialized: {materialization.asset_key}" |
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.
maybe note that we're still going to yield a materialization event.
@@ -501,3 +515,25 @@ def all_api_mocks_fixture( | |||
status=200, | |||
) | |||
yield fetch_workspace_data_api_mocks | |||
|
|||
|
|||
@pytest.fixture(name="sync_and_poll") |
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.
poll_and_sync vs sync_and_poll
connector_id: str, | ||
fetch_workspace_data_api_mocks: responses.RequestsMock, | ||
sync_and_poll: MagicMock, | ||
) -> None: |
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.
nit: mention that this is actually testing sync_and_poll. Calling it the materialization method feels a bit overly specified to me.
assert len(materialized_asset_keys) == 4 | ||
assert my_fivetran_assets.keys == materialized_asset_keys | ||
|
||
# Mocked FivetranClient.sync_and_poll returns API response |
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.
would be nice to have some way of determining that the expected log messages actually happened - this just kinda makes sure it doesn't error. Could potentially directly invoke the fivetran asset and assert against the materializeresult objects + AssetMaterializations when appropriate
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.
6cf70a0
to
47cb47a
Compare
b0e8961
to
c94dc6b
Compare
47cb47a
to
79f0f78
Compare
c94dc6b
to
36e9da9
Compare
36e9da9
to
99e73bd
Compare
…Workspace (dagster-io#25961) ## Summary & Motivation This PR implements `FivetranWorkspace.sync_and_poll`, the materialization method for Fivetran assets. This method: - calls `FivetranClient.sync_and_poll` - takes the FivetranOutput returned by `FivetranClient.sync_and_poll` and generates the asset materializations - yields `MaterializeResult` for each expected asset and `AssetMaterialization` for each unexpected asset - a connector table that was not in the connector at definitions loading time can be in the FivetranOutput. Eg. the table was added after definitions loading time and before sync. - logs a warning for each unmaterialized table - a connector table can be created at definitions loading time, but can be missing in the FivetranOutput. Eg. the table was deleted after definitions loading time and before sync. Can be leveraged like: ```python from dagster_fivetran import FivetranWorkspace, fivetran_assets import dagster as dg fivetran_workspace = FivetranWorkspace( account_id=dg.EnvVar("FIVETRAN_API_KEY"), api_key=dg.EnvVar("FIVETRAN_API_KEY"), api_secret=dg.EnvVar("FIVETRAN_API_SECRET"), ) @fivetran_assets( connector_id="connector_id", name="connector_id", group_name="connector_id", workspace=fivetran_workspace, ) def fivetran_connector_assets(context: dg.AssetExecutionContext, fivetran: FivetranWorkspace): yield from fivetran.sync_and_poll(context=context) defs = dg.Definitions( assets=[fivetran_connector_assets], resources={"fivetran": fivetran_workspace}, ) ``` ## How I Tested These Changes Additional tests with BK Tested with a live Fivetran instance: <img width="1251" alt="Screenshot 2024-11-26 at 5 46 31 PM" src="https://github.com/user-attachments/assets/e4253119-045f-4ac7-8b98-eb805e24a843"> ## Changelog [dagster-fivetran]
Summary & Motivation
This PR implements
FivetranWorkspace.sync_and_poll
, the materialization method for Fivetran assets. This method:FivetranClient.sync_and_poll
FivetranClient.sync_and_poll
and generates the asset materializationsMaterializeResult
for each expected asset andAssetMaterialization
for each unexpected assetCan be leveraged like:
How I Tested These Changes
Additional tests with BK
Tested with a live Fivetran instance:
Changelog
[dagster-fivetran]