-
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
WIP: Serialized object property #25248
Conversation
2985072
to
dafd7db
Compare
BTW, seems like all XCom based External Links won't work with dynamic tasks. |
List of External Links which define
|
Nice. I saw those issues too. I know it's draft but a look at that might be useful @uranusjr :) |
I found that Extra Links do not work with dynamic tasks at all. Sample DAGfrom pendulum import datetime
from airflow.decorators import dag
from airflow.sensors.external_task import ExternalTaskSensor
from airflow.operators.empty import EmptyOperator
EXTERNAL_DAG_IDS = [f"example_external_dag_{ix:02d}" for ix in range(3)]
DAG_KWARGS = {
"start_date": datetime(2022, 7, 1),
"schedule_interval": "@daily",
"catchup": False,
"tags": ["mapped_extra_links", "AIP-42", "serialization"],
}
def external_dags():
EmptyOperator(task_id="dummy")
@dag(**DAG_KWARGS)
def external_regular_task_sensor():
for external_dag_id in EXTERNAL_DAG_IDS:
ExternalTaskSensor(
task_id=f'wait_for_{external_dag_id}',
external_dag_id=external_dag_id,
poke_interval=5,
)
@dag(**DAG_KWARGS)
def external_mapped_task_sensor():
ExternalTaskSensor.partial(
task_id='wait',
poke_interval=5,
).expand(external_dag_id=EXTERNAL_DAG_IDS)
dag_external_regular_task_sensor = external_regular_task_sensor()
dag_external_mapped_task_sensor = external_mapped_task_sensor()
for dag_id in EXTERNAL_DAG_IDS:
globals()[dag_id] = dag(dag_id=dag_id, **DAG_KWARGS)(external_dags)() Video Demomapped_extra_links.mp4Might be better do not serialize Extra Links for dynamic tasks at all? |
def resolve_property_value(obj, prop): | ||
"""Return class property value. | ||
|
||
:param obj: Reference to class. | ||
:param prop: Reference to class property. | ||
:returns: If ``prop`` property than return property value, | ||
otherwise it returns class attribute value. | ||
""" | ||
if isinstance(prop, property): | ||
return prop.fget(obj) | ||
return prop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can live directly in serialized_objects
instead (and be a private function)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify - is it related to Operator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? Not sure I understand the question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for confuse you. Initially I think you mean add some implementation __serialized_fields
in BatchOperator.
Now I understand what you mean place in serialized_objects
module.
@potiuk @uranusjr Do we need this PR or I could close it? The only reason why I created this PR, try to get property values for extra_link property but this still can't be for Also I could make changes in |
At that moment Airflow can't serialize DAG with dynamic tasks if
operator_extra_links
set as propertyrelated: #25243, #25215, #24676
I've tried to add get actual values of property.
It works in simple cases: #25215, #24676
However there is no reason use property
operator_extra_links
in this casesIt still not completely help in case when property uses for dynamic links selections such as: #25243
With this PoC error changed,
airflow.models.mappedoperator.MappedOperator
doesn't have access to attributes of Taskcc: @josh-fell