Skip to content

Jinja template not rendering in a custom sensor that internally uses a custom hook #39626

Answered by Taragolis
sid-habu asked this question in Q&A
Discussion options

You must be logged in to vote

Attributes rendered after the class constructor (__init__ method) and before execute, poke methods

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(s…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@sid-habu
Comment options

Answer selected by sid-habu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants