-
I have a custom Operator and a Sensor that define However, in the Airflow UI, both the tasks have the right rendered value for the key I have tried all different combinations of using XCOMs and have exhausted all my options. Is there any gotcha in using an XCOM from a task outside a task group for multiple taks in the group? It looks like only the first task (t1) gets the value. One caveat is that I appreciate any suggestion on getting this to work or any workaround for passing XCOM values to tasks in a group |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @sid-habu! Just curious, have you tried not wrapping the conn_id=f'{data_plane_conf["connection_name"]}', have you tried this: conn_id=data_plane_conf["connection_name"], |
Beta Was this translation helpful? Give feedback.
-
@josh-fell Thanks for your reply. No, it didn't work as the rendered value still shows up as
Some more data points that can isolate the issue
I have updated the code snippet to depict the above data points |
Beta Was this translation helpful? Give feedback.
-
Attributes rendered after the class constructor ( from __future__ import annotations
from functools import cached_property
from typing import TYPE_CHECKING, Sequence
from airflow.sensors.base import BaseSensorOperator
if TYPE_CHECKING:
from airflow.utils.context import Context
class CustomSensor(BaseSensorOperator):
template_fields: Sequence[str] = ("conn_id", "app_name")
def __init__(
self,
*,
conn_id: str,
app_name: str,
**kwargs,
) -> None:
super().__init__(**kwargs)
self.conn_id = conn_id
self.app_name = app_name
@cached_property
def hook(self):
return CustomHook(connection_name=self.conn_id)
def poke(self, context: Context) -> bool:
# Do something with your hook, conn_id already templated, avoid to call it in __init__
print(self.hook.connection_name)
# Do something with app_name
print(self.app_name) |
Beta Was this translation helpful? Give feedback.
Attributes rendered after the class constructor (
__init__
method) and beforeexecute
,poke
methods