airflow
airflow copied to clipboard
Add owner to taskinstance
Description add task owner information to taskinstance
Use case/motivation I am sending an alarm to Slack using the airflow callback(on_success_callback, on_failure_callback) function.
I create an alarm message using the information of the task instance, and it would be better if the task owner information is included here.
Closes: https://github.com/apache/airflow/issues/40366
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
- In case of a new feature add useful documentation (in docstrings or in
docs/directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it. - Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the Airflow Coding style.
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits. Apache Airflow is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] Slack: https://s.apache.org/airflow-slack
Could you add a test that tries to access this parameter on runtime?
@hussein-awala This is a very minor change, so it would be better to use the existing tests rather than creating a new one. I have added the task owner check logic to the test_refresh_from_db test.
I am worried a bit, the task instance table is a very huge table that potentially have millions of rows. Do we need to persist the field into the table or could we also load it from the Python object as task instance?
Note, the extension solely will not work, if really it is accepted to extend the data model, a DB migration is needed to be added.
I am worried a bit, the task instance table is a very huge table that potentially have millions of rows. Do we need to persist the field into the table or could we also load it from the Python object as task instance?
Note, the extension solely will not work, if really it is accepted to extend the data model, a DB migration is needed to be added.
@jscheffl you means migrations/versions/xxx.py? I didn't know that, but thank you for letting me know. i add migration py how are revision and down, revision determined? They seem to be commit IDs, but the actual commits do not exist on the main branch.
I am worried a bit, the task instance table is a very huge table that potentially have millions of rows. Do we need to persist the field into the table or could we also load it from the Python object as task instance? Note, the extension solely will not work, if really it is accepted to extend the data model, a DB migration is needed to be added.
@jscheffl you means migrations/versions/xxx.py? I didn't know that, but thank you for letting me know. i add migration py how are revision and down, revision determined? They seem to be commit IDs, but the actual commits do not exist on the main branch.
You should use alembic to generate those -those are not commits. See https://github.com/apache/airflow/blob/main/contributing-docs/13_metadata_database_updates.rst as starting point.
And I absolutely share @jscheffl worries. TaskInstance is a huge table, it can have miliions and millions of rows and it is the crucial part of the process. Modifying the DB structure and making our database less normalized is not a decision that should be taken lightly.
Have you run any performance tests on millons of rows @wornjs ? Do you know what impact it will have on the database size and memory used to store the extra data? Have you tested it on mysql and Postgres and sqlite with those millions of rows?
If the answer to any of the questions above is "no" - that change is absolutely not ready to be merged. And in generall, if the motivation is to avoid traversing from Task Instance to get the owner information in order to send slack alert, I seriously doubt this change has a serious merit.
I don't think this is a good idea, trying to access the information on the task would be better.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.