-
Notifications
You must be signed in to change notification settings - Fork 184
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
Issue 253 #322
base: main
Are you sure you want to change the base?
Issue 253 #322
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #322 +/- ##
=======================================
Coverage 93.68% 93.69%
=======================================
Files 10 10
Lines 792 777 -15
=======================================
- Hits 742 728 -14
+ Misses 50 49 -1 ☔ View full report in Codecov by Sentry. |
@pankajastro, do you mind reviewing this, open to feedback? cc: @tatiana |
@jroach-astronomer please let me know once you'd like me to re-review/test the pull request. Could you please also update the PR description after the changes especially with the example for There seem to be a couple of conflicts, would be nice if you could resolve them too. We're planning on releasing DAG Factory on 10th Jan, so would be nice if we could get this change in by then. |
@pankajkoti, resolved MC's, updated PR docs. |
dev/dags/example_callbacks.yml
Outdated
task_1: | ||
operator: airflow.operators.bash_operator.BashOperator | ||
bash_command: "echo 1" | ||
on_success_callback: customized.callbacks.custom_callbacks.output_message |
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.
Apparently this callback is failing as I'm testing the DAG. Can we correct this callback execution by passing the missing params, please
The callbacks logs are unfortunately wrapped under Post task execution logs
, so you would have to expand to check on any possible failures.
[2025-01-07, 12:22:15 UTC] {taskinstance.py:340} ▼ Post task execution logs
[2025-01-07, 12:22:15 UTC] {taskinstance.py:352} INFO - Marking task as SUCCESS. dag_id=example_callbacks, task_id=task_1, run_id=scheduled__2025-01-06T00:00:00+00:00, execution_date=20250106T000000, start_date=20250107T122215, end_date=20250107T122215
[2025-01-07, 12:22:15 UTC] {taskinstance.py:1563} INFO - Executing callback at index 0: output_message
[2025-01-07, 12:22:15 UTC] {taskinstance.py:1567} ERROR - Error in callback at index 0: output_message
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/airflow/models/taskinstance.py", line 1565, in _run_finished_callback
callback(context)
TypeError: output_message() missing 2 required positional arguments: 'param1' and 'param2'
[2025-01-07, 12:22:15 UTC] {local_task_job_runner.py:266} INFO - Task exited with return code 0
[2025-01-07, 12:22:15 UTC] {local_task_job_runner.py:245} ▲▲▲ Log group end
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.
also what is the planned interface(change intended if any?)?
Do we intend to continue accepting direct callback functions e.g. for on_success_callback arg or they would mandatorily need to be provided as values as nested arg callable
? Or we plan to support both approaches? Is it that we need a nested callable
arg when params needs to be passed too? and otherwise we can directly pass callable functions?
Pull request to address #253, which aims to provide enhanced support for callback types at the DAG,
default_args
, Task and TaskGroup level. There are now four different ways that callbacks can be defined viadag-factory
. Below, you'll also see an example of each.Passing a string that points to a callable
Passing a file path and file name that points to a callable
By providing a string that points to a callable, but with some parameters being provided at runtime
Using callbacks from providers
Unit-tests have been added and updated appropriately.