Skip to content

Commit

Permalink
Cast callbacks to functions when set with default_args on task groups
Browse files Browse the repository at this point in the history
>

Co-authored-by: Luiz Felipe de Mesquita Baraldo <luiz.felipe.m.baraldo@hotmail.com>
  • Loading branch information
pankajastro and Baraldo committed Oct 14, 2024
1 parent 11a5393 commit e1a2b1b
Showing 1 changed file with 39 additions and 38 deletions.
77 changes: 39 additions & 38 deletions tests/test_dagbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,44 +130,6 @@
},
},
}
DAG_CONFIG_TASK_GROUP_WITH_CALLBACKS = {
"default_args": {"owner": "custom_owner"},
"schedule_interval": "0 3 * * *",
"task_groups": {
"task_group_1": {
"tooltip": "this is a task group",
"default_args": {
"on_failure_callback": f"{__name__}.print_context_callback",
"on_success_callback": f"{__name__}.print_context_callback",
"on_execute_callback": f"{__name__}.print_context_callback",
"on_retry_callback": f"{__name__}.print_context_callback",
},
},
},
"tasks": {
"task_1": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 1",
"task_group_name": "task_group_1",
},
"task_2": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 2",
"task_group_name": "task_group_1",
},
"task_3": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 3",
"task_group_name": "task_group_1",
"dependencies": ["task_2"],
},
"task_4": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 4",
"dependencies": ["task_group_1"],
},
},
}
DAG_CONFIG_DYNAMIC_TASK_MAPPING = {
"default_args": {"owner": "custom_owner"},
"description": "This is an example dag with dynamic task mapping",
Expand Down Expand Up @@ -236,6 +198,45 @@
}
UTC = pendulum.timezone("UTC")

DAG_CONFIG_TASK_GROUP_WITH_CALLBACKS = {
"default_args": {"owner": "custom_owner"},
"schedule_interval": "0 3 * * *",
"task_groups": {
"task_group_1": {
"tooltip": "this is a task group",
"default_args": {
"on_failure_callback": f"{__name__}.print_context_callback",
"on_success_callback": f"{__name__}.print_context_callback",
"on_execute_callback": f"{__name__}.print_context_callback",
"on_retry_callback": f"{__name__}.print_context_callback",
},
},
},
"tasks": {
"task_1": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 1",
"task_group_name": "task_group_1",
},
"task_2": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 2",
"task_group_name": "task_group_1",
},
"task_3": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 3",
"task_group_name": "task_group_1",
"dependencies": ["task_2"],
},
"task_4": {
"operator": "airflow.operators.bash_operator.BashOperator",
"bash_command": "echo 4",
"dependencies": ["task_group_1"],
},
},
}


class MockTaskGroup:
def __init__(self, **kwargs):
Expand Down

0 comments on commit e1a2b1b

Please sign in to comment.