Content-Length: 327539 | pFad | https://github.com/astronomer/airflow/commit/280f1f0c4cc49aba1b2f8b456326795733769d18

81 Correctly restore upstream_task_ids when deserializing Operators (#8775) · astronomer/airflow@280f1f0 · GitHub
Skip to content

Commit 280f1f0

Browse files
authored
Correctly restore upstream_task_ids when deserializing Operators (apache#8775)
This test exposed a bug in one of the example dags, that wasn't caught by apache#6549. That will be a fixed in a separate issue, but it caused the round-trip tests to fail here Fixes apache#8720
1 parent a715aa6 commit 280f1f0

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

airflow/providers/google/cloud/example_dags/example_gcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@
126126
)
127127

128128
# [START howto_operator_gcs_delete_bucket]
129-
delete_bucket_1 = GCSDeleteBucketOperator(task_id="delete_bucket", bucket_name=BUCKET_1)
130-
delete_bucket_2 = GCSDeleteBucketOperator(task_id="delete_bucket", bucket_name=BUCKET_2)
129+
delete_bucket_1 = GCSDeleteBucketOperator(task_id="delete_bucket_1", bucket_name=BUCKET_1)
130+
delete_bucket_2 = GCSDeleteBucketOperator(task_id="delete_bucket_2", bucket_name=BUCKET_2)
131131
# [END howto_operator_gcs_delete_bucket]
132132

133133
[create_bucket1, create_bucket2] >> list_buckets >> list_buckets_result

airflow/serialization/serialized_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def deserialize_dag(cls, encoded_dag: Dict[str, Any]) -> 'SerializedDAG':
598598
for task_id in serializable_task.downstream_task_ids:
599599
# Bypass set_upstream etc here - it does more than we want
600600
# noinspection PyProtectedMember
601-
dag.task_dict[task_id]._upstream_task_ids.add(task_id) # pylint: disable=protected-access
601+
dag.task_dict[task_id]._upstream_task_ids.add(serializable_task.task_id) # noqa: E501 # pylint: disable=protected-access
602602

603603
return dag
604604

tests/serialization/test_dag_serialization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ def validate_deserialized_task(self, serialized_task, task,):
355355
assert serialized_task.task_type == task.task_type
356356
assert set(serialized_task.template_fields) == set(task.template_fields)
357357

358+
assert serialized_task.upstream_task_ids == task.upstream_task_ids
359+
assert serialized_task.downstream_task_ids == task.downstream_task_ids
360+
358361
for field in fields_to_check:
359362
assert getattr(serialized_task, field) == getattr(task, field), \
360363
f'{task.dag.dag_id}.{task.task_id}.{field} does not match'

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/astronomer/airflow/commit/280f1f0c4cc49aba1b2f8b456326795733769d18

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy