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

Add test to evaluation of tasks in mapped task group #36149

Merged
merged 1 commit into from
Dec 30, 2023
Merged
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
59 changes: 59 additions & 0 deletions tests/models/test_mappedoperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,3 +1568,62 @@ def my_teardown(val):
"tg_2.my_work": "skipped",
}
assert states == expected

def test_skip_one_mapped_task_from_task_group_with_generator(self, dag_maker):
with dag_maker() as dag:

@task
def make_list():
return [1, 2, 3]

@task
def double(n):
if n == 2:
raise AirflowSkipException()
return n * 2

@task
def last(n):
...

@task_group
def group(n: int) -> None:
last(double(n))

group.expand(n=make_list())

dr = dag.test()
states = self.get_states(dr)
expected = {
"group.double": {0: "success", 1: "skipped", 2: "success"},
"group.last": {0: "success", 1: "skipped", 2: "success"},
"make_list": "success",
}
assert states == expected

def test_skip_one_mapped_task_from_task_group(self, dag_maker):
with dag_maker() as dag:

@task
def double(n):
if n == 2:
raise AirflowSkipException()
return n * 2

@task
def last(n):
...

@task_group
def group(n: int) -> None:
last(double(n))

group.expand(n=[1, 2, 3])

dr = dag.test()
states = self.get_states(dr)
expected = {
"group.double": {0: "success", 1: "skipped", 2: "success"},
"group.last": {0: "success", 1: "skipped", 2: "success"},
}
assert states == expected