Can't override attributes on task_policy on 2.4
Apache Airflow version
2.4.0
What happened
Task policies on airflow 2.4 are raising ERROR [airflow.models.dagbag.DagBag] can't set attribute error on trying to override the values.
What you think should happen instead
No response
How to reproduce
Override an attribute using task_policy on config/airflow_local_settings.py using the docker image apache/airflow:slim-2.4.0-python3.10
def task_policy(task):
task.owner = "newowner"
task.on_failure_callback = lambda context: print(context)
Operating System
docker image apache/airflow:slim-2.4.0-python3.10
Versions of Apache Airflow Providers
No response
Deployment
Other Docker-based deployment
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Works on image apache/airflow:slim-2.4.0-python3.8
@mariotaddeucci - can you please provide more information ? Is it happeniing on 3.9 too? Could you provide a more detailed stack trace? Is it when you set owner or on_failure_callback ?
Yes, it's happing on 3.9. On 3.8 only with dynamic task. It happens with both parameters, owners and on failure callback. I will describe how to get this error better
Any news here @mariotaddeucci ? Is this problem still present?
I have a similar issue in Airflow 2.4.2:
def create_hooks(self):
self.s3_hook = S3Hook(aws_conn_id=self.s3_conn_id)
self.s3_hook.extra_args = {"ContentType": content_type}
ERROR - Task failed with exception
Traceback (most recent call last):
File "", line 57, in execute
self.s3_hook.extra_args = {"ContentType": content_type}
AttributeError: can't set attribute
@dima-lyublin Please do not hijack this discussion- your problem is that you are trying to override property. DON'T do it. _extra_args is the field that is exposed by the property.
@mariotaddeucci -> any news ?
Duplicate of #24547. Fixed in #28313. Will likely be part of 2.5.1