Skip to content

Support defining pre/post hook for operators in a DAG at the DAG level #17073

@sighingnow

Description

@sighingnow

Description

We propose to add such features to airflow, which will allow the users to define a hook at the DAG level, and been executed before the pre_execution and after the post_execution.

TODO: we will propose detailed API change if such change is acceptable.

Use case / motivation

Airflow supports the operator to define their custom pre_execution/post_execution method, which will be exeucted before/after the execution of the operator, respectively.

But is hard to inject such hooks to existing operators, without modifying the code. i.e., airfow doesn't support a global pre-hook/post-hook to run before/after execution of every operators.

Such kind of hooks could be used for preparing the required inputs and finalizing the produced outputs for every operators in the DAG, etc. For example, the underlying XCom backends may support local values more efficiently than remote value accessing, the pre/post hook that the DAG level could do a migration/replication before the execution of operators, and gain end-to-end performance improvement.

Are you willing to submit a PR?

Yes, we would like to submit a PR if this feature request is acceptable.

Related Issues

None.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions