turbaszek commented on a change in pull request #11815:
URL: https://github.com/apache/airflow/pull/11815#discussion_r517983985
##########
File path: airflow/models/renderedtifields.py
##########
@@ -81,6 +85,31 @@ def get_templated_fields(cls, ti: TaskInstance, session:
Session = None) -> Opti
else:
return None
+ @classmethod
+ @provide_session
+ def get_k8s_pod_yaml(cls, ti: TaskInstance, session: Session = None) ->
Optional[str]:
+ """
+ Get templated field for a TaskInstance from the
RenderedTaskInstanceFields
+ table.
+
+ :param ti: Task Instance
+ :param session: SqlAlchemy Session
+ :return: Rendered Templated TI field
+ """
+ result = (
+ session.query(cls.k8s_pod_yaml)
+ .filter(
+ cls.dag_id == ti.dag_id, cls.task_id == ti.task_id,
cls.execution_date == ti.execution_date
+ )
+ .one_or_none()
+ )
+
+ if result:
+ k8s_pod_yaml = result.k8s_pod_yaml
+ return k8s_pod_yaml
+ else:
+ return None
Review comment:
```suggestion
return result.k8s_pod_yaml if result else None
```
How about this oneliner?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]