This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new ca4f99d Serialize the template_ext attribute to show it in UI (#17985)
ca4f99d is described below
commit ca4f99d349e664bbcf58d3c84139b5f4919f6c8e
Author: Bas Harenslak <[email protected]>
AuthorDate: Fri Sep 3 00:54:32 2021 +0200
Serialize the template_ext attribute to show it in UI (#17985)
Co-authored-by: Bas Harenslak <[email protected]>
---
airflow/models/baseoperator.py | 1 +
airflow/serialization/serialized_objects.py | 1 +
tests/serialization/test_dag_serialization.py | 5 +++++
3 files changed, 7 insertions(+)
diff --git a/airflow/models/baseoperator.py b/airflow/models/baseoperator.py
index 3feeb5b..60d6621 100644
--- a/airflow/models/baseoperator.py
+++ b/airflow/models/baseoperator.py
@@ -1572,6 +1572,7 @@ class BaseOperator(Operator, LoggingMixin, TaskMixin,
metaclass=BaseOperatorMeta
'subdag',
'ui_color',
'ui_fgcolor',
+ 'template_ext',
'template_fields',
'template_fields_renderers',
}
diff --git a/airflow/serialization/serialized_objects.py
b/airflow/serialization/serialized_objects.py
index 4978736..35561ae 100644
--- a/airflow/serialization/serialized_objects.py
+++ b/airflow/serialization/serialized_objects.py
@@ -434,6 +434,7 @@ class SerializedBaseOperator(BaseOperator,
BaseSerialization):
# Move class attributes into object attributes.
self.ui_color = BaseOperator.ui_color
self.ui_fgcolor = BaseOperator.ui_fgcolor
+ self.template_ext = BaseOperator.template_ext
self.template_fields = BaseOperator.template_fields
self.operator_extra_links = BaseOperator.operator_extra_links
diff --git a/tests/serialization/test_dag_serialization.py
b/tests/serialization/test_dag_serialization.py
index 450bed9..cb68722 100644
--- a/tests/serialization/test_dag_serialization.py
+++ b/tests/serialization/test_dag_serialization.py
@@ -99,6 +99,7 @@ serialized_simple_dag_ground_truth = {
"_outlets": [],
"ui_color": "#f0ede4",
"ui_fgcolor": "#000",
+ "template_ext": ['.sh', '.bash'],
"template_fields": ['bash_command', 'env'],
"template_fields_renderers": {'bash_command': 'bash', 'env':
'json'},
"bash_command": "echo {{ task.task_id }}",
@@ -130,6 +131,7 @@ serialized_simple_dag_ground_truth = {
"_operator_extra_links":
[{"tests.test_utils.mock_operators.CustomOpLink": {}}],
"ui_color": "#fff",
"ui_fgcolor": "#000",
+ "template_ext": [],
"template_fields": ['bash_command'],
"template_fields_renderers": {},
"_task_type": "CustomOperator",
@@ -447,6 +449,7 @@ class TestStringifiedDAGs(unittest.TestCase):
# Type is excluded, so don't check it
'_log',
# List vs tuple. Check separately
+ 'template_ext',
'template_fields',
# We store the string, real dag has the actual code
'on_failure_callback',
@@ -457,6 +460,8 @@ class TestStringifiedDAGs(unittest.TestCase):
}
assert serialized_task.task_type == task.task_type
+
+ assert set(serialized_task.template_ext) == set(task.template_ext)
assert set(serialized_task.template_fields) ==
set(task.template_fields)
assert serialized_task.upstream_task_ids == task.upstream_task_ids