진지한 개발자

CustomOperator에서 jinja 템블릿 값 사용하려면 본문

IT/Airflow

CustomOperator에서 jinja 템블릿 값 사용하려면

제이_엔 2023. 5. 2. 14:07
728x90
  • template_fields 에 정의하면 됨

 

  • baseoperator
# venv > Lib > site-packages > airflow > models > baseoperator.py > Jupyter > BaseOperator

class BaseOperator ...

    def render_template_fields(
        self,
        context: Context,
        jinja_env: Optional["jinja2.Environment"] = None,
    ) -> Optional["BaseOperator"]:
        """Template all attributes listed in template_fields.

        This mutates the attributes in-place and is irreversible.

        :param context: Dict with values to apply on content
        :param jinja_env: Jinja environment
        """
        if not jinja_env:
            jinja_env = self.get_template_env()
        self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
        return selftem

 

728x90

'IT > Airflow' 카테고리의 다른 글

Spark vs Sqoop  (0) 2025.02.18
Date 변환  (0) 2023.05.02