-
Notifications
You must be signed in to change notification settings - Fork 294
Watcher depends on past #2615
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
Merged
tatiana
merged 13 commits into
astronomer:main
from
johnhoran:2596_fix-watcher-depends-on-past
May 19, 2026
+113
−14
Merged
Watcher depends on past #2615
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
70b4415
update graph
johnhoran b54a38c
add test
johnhoran 4d52358
add test
johnhoran e6b22ed
use task_map
johnhoran 271f4f1
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] 9731143
refactor around mcabe limit
johnhoran a5436e0
mypy
johnhoran 061d706
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] 4c0931c
update comment
johnhoran ec12577
resolve test failure
johnhoran 0ed111d
Merge branch 'main' into 2596_fix-watcher-depends-on-past
johnhoran 441cf87
Merge branch 'main' into 2596_fix-watcher-depends-on-past
johnhoran cdf688f
Merge branch 'main' into 2596_fix-watcher-depends-on-past
johnhoran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2228,3 +2228,78 @@ def test_add_watcher_producer_task_passes_freshness_callback_via_setup_operator_ | |
|
|
||
| task_metadata = mock_create_task.call_args[0][0] | ||
| assert task_metadata.arguments["freshness_callback"] is my_callback | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("depends_on_past", [False, True]) | ||
| @pytest.mark.parametrize("test_behavior", [TestBehavior.NONE, TestBehavior.AFTER_EACH, TestBehavior.AFTER_ALL]) | ||
| def test_watcher_dependency_wiring(test_behavior, depends_on_past): | ||
| with DAG("test-id", start_date=datetime(2022, 1, 1), default_args={"depends_on_past": depends_on_past}) as dag: | ||
| task_args = { | ||
| "project_dir": SAMPLE_PROJ_PATH, | ||
| "conn_id": "fake_conn", | ||
| "profile_config": ProfileConfig( | ||
| profile_name="default", | ||
| target_name="default", | ||
| profile_mapping=PostgresUserPasswordProfileMapping( | ||
| conn_id="fake_conn", | ||
| profile_args={"schema": "public"}, | ||
| ), | ||
| ), | ||
| } | ||
|
|
||
| child_2b = DbtNode( | ||
| unique_id=f"{DbtResourceType.MODEL.value}.{SAMPLE_PROJ_PATH.stem}.child2.v2_b", | ||
| resource_type=DbtResourceType.MODEL, | ||
| depends_on=[parent_node.unique_id], | ||
| path_base=SAMPLE_PROJ_PATH, | ||
| original_file_path=Path("gen3/models/child2_v2.sql"), | ||
| tags=["nightly"], | ||
| config={"materialized": "table", "meta": {"cosmos": {"operator_kwargs": {"pool": "custom_pool"}}}}, | ||
| has_test=True, | ||
| has_non_detached_test=True, | ||
| ) | ||
| child_2b_test = DbtNode( | ||
| unique_id=f"{DbtResourceType.TEST.value}.{SAMPLE_PROJ_PATH.stem}.child2.test_v2_b", | ||
| resource_type=DbtResourceType.TEST, | ||
| depends_on=[child_2b.unique_id], | ||
| path_base=Path("."), | ||
| original_file_path=Path("."), | ||
| ) | ||
|
|
||
| build_airflow_graph( | ||
| nodes={child_2b.unique_id: child_2b, child_2b_test.unique_id: child_2b_test, **sample_nodes}, | ||
| dag=dag, | ||
| execution_mode=ExecutionMode.WATCHER, | ||
| test_indirect_selection=TestIndirectSelection.EAGER, | ||
| task_args=task_args, | ||
| render_config=RenderConfig( | ||
| test_behavior=test_behavior, | ||
| ), | ||
| dbt_project_name="astro_shop", | ||
| task_group=TaskGroup("tg", dag=dag), | ||
| ) | ||
|
johnhoran marked this conversation as resolved.
|
||
| if not depends_on_past: | ||
| assert dag.task_dict["tg.dbt_producer_watcher_done"].upstream_task_ids == {"tg.dbt_producer_watcher"} | ||
| assert all(task.wait_for_downstream is False for task in dag.tasks) | ||
| return | ||
|
|
||
| assert all(task.wait_for_downstream is True for task in dag.tasks if task.task_id != "tg.dbt_producer_watcher_done") | ||
| if test_behavior == TestBehavior.NONE: | ||
| assert dag.task_dict["tg.dbt_producer_watcher_done"].upstream_task_ids == { | ||
| "tg.child_run", | ||
| "tg.dbt_producer_watcher", | ||
| "tg.child2_v2_run", | ||
| "tg.child2_v2_b_run", | ||
| } | ||
| if test_behavior == TestBehavior.AFTER_EACH: | ||
| assert dag.task_dict["tg.dbt_producer_watcher_done"].upstream_task_ids == { | ||
| "tg.child_run", | ||
| "tg.dbt_producer_watcher", | ||
| "tg.child2_v2_run", | ||
| "tg.child2_v2_b.test", | ||
| } | ||
| if test_behavior == TestBehavior.AFTER_ALL: | ||
| assert dag.task_dict["tg.dbt_producer_watcher_done"].upstream_task_ids == { | ||
| "tg.dbt_producer_watcher", | ||
| "tg.astro_shop_test", | ||
| } | ||
|
Comment on lines
+2250
to
+2305
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new test covers the dependency topology well. A small extra assertion that |
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.