빅데이터/airflow
[airflow] BashOperator에서 jinja2.exceptions.TemplateNotFound: 오류
hs_seo
2021. 11. 18. 09:49
에어플로우 BashOperator 에서 템플릿을 사용하지 않는데, TelplateNotFound 오류가 발생하는 경우가 있습니다. 이 경우 스크립트 뒤에 공백을 추가하면 됩니다.
[2021-11-17 18:14:21,099] {taskinstance.py:1150} ERROR - /home/user/sample.sh
Traceback (most recent call last):
File "/home/deploy/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py", line 965, in _run_raw_task
self.render_templates(context=context)
File "/home/deploy/.local/lib/python3.6/site-packages/airflow/models/taskinstance.py", line 1424, in render_templates
self.task.render_template_fields(context)
File "/home/deploy/.local/lib/python3.6/site-packages/airflow/models/baseoperator.py", line 719, in render_template_fields
self._do_render_template_fields(self, self.template_fields, context, jinja_env, set())
File "/home/deploy/.local/lib/python3.6/site-packages/airflow/models/baseoperator.py", line 726, in _do_render_template_fields
rendered_content = self.render_template(content, context, jinja_env, seen_oids)
File "/home/deploy/.local/lib/python3.6/site-packages/airflow/models/baseoperator.py", line 753, in render_template
return jinja_env.get_template(content).render(**context)
File "/home/deploy/.local/lib/python3.6/site-packages/jinja2/environment.py", line 883, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/deploy/.local/lib/python3.6/site-packages/jinja2/environment.py", line 857, in _load_template
template = self.loader.load(self, name, globals)
File "/home/deploy/.local/lib/python3.6/site-packages/jinja2/loaders.py", line 115, in load
source, filename, uptodate = self.get_source(environment, name)
File "/home/deploy/.local/lib/python3.6/site-packages/jinja2/loaders.py", line 197, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: /home/user/sample.sh
해결 방법
코드를 다음과 같이 수정합니다. bash_command에 입력하는 문자열에 공백을 추가하면 됩니다.
반응형