-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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 run_if
/skip_if
functionality to non-TaskFlow operators
#44205
Comments
I have never submitted a PR, but my team wrote some working code to add this to our custom operator so I want to try to contribute this functionality. My initial thought was this could be added as arguments to
Then a lot of the code in I am also seeing that in the discussion that led to the Any thoughts? |
Yes. The only way we can do this approved is if you figure how how to run that code ONLY in task - and NOT in scheduler. Running any DAG Author provided code in scheduler is violating basic Airlfow security model https://airflow.apache.org/docs/apache-airflow/stable/security/security_model.html - and Airflow Scheduler should never run DAG Author modifiable code. This is for example why custom scheduler code is done via Plugins - you are not able to create custom scheduler code via DAG - you have to have plugin installed. I think it's possible to do it in a safe way - plugging it in in the "pre_execute" framework and you are welcome to try it. But it will be quite a bit more complex (likely) than what your team came up with. And currently we are only working on Airlfow 3 where the task execution is anyhow heavily changed. But after we release Airflow 3, I think that might be a good addition. |
Yes - We did exactly this, but in a custom operator instead of
Another compelling reason is if you have a |
Yes. it is. Because it is an underpinning for a LOT of things. Say mapped operators.
This could be also done by extracting common code and havin So yes - that's quite possible to add it - maybe even you can attempt to do it now - but again, be aware it's only going to be available in Airflow3 as we do not add any more features to Airlfow 2 (but that's fine as well - one more good reason to migrate to Airflow 3). |
Description
Currently, the useful
run_if
andskip_if
decorators can only be added to tasks that are decorated by the@task
decorator, aka TaskFlow compatible operators. However, many common operators are not compatible with TaskFlow API, e.g. theSqlExecuteQueryOperator
. If you try, you will be met with:This request is for
run_if
andskip_if
to be added to all operators, not just TaskFlow compatible ones.Use case/motivation
I want to use
run_if
andskip_if
for an operator that isn't TaskFlow compatible.Related issues
There is a similar issue that I didn't bookmark to make
@task
decorator apply to classes (aka Operators), not just functions. Depending on how that's implemented, it could solve this issue.Are you willing to submit a PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: