airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Can't override attributes on task_policy on 2.4

Open mariotaddeucci opened this issue 3 years ago • 2 comments

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

mariotaddeucci avatar Sep 20 '22 18:09 mariotaddeucci

Works on image apache/airflow:slim-2.4.0-python3.8

mariotaddeucci avatar Sep 20 '22 18:09 mariotaddeucci

@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 ?

potiuk avatar Sep 21 '22 14:09 potiuk

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

mariotaddeucci avatar Sep 27 '22 03:09 mariotaddeucci

Any news here @mariotaddeucci ? Is this problem still present?

potiuk avatar Oct 31 '22 03:10 potiuk

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 avatar Nov 03 '22 10:11 dima-lyublin

@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.

potiuk avatar Nov 07 '22 23:11 potiuk

@mariotaddeucci -> any news ?

potiuk avatar Nov 07 '22 23:11 potiuk

Duplicate of #24547. Fixed in #28313. Will likely be part of 2.5.1

potiuk avatar Jan 10 '23 07:01 potiuk