fpopic commented on issue #36629:
URL: https://github.com/apache/airflow/issues/36629#issuecomment-1882612654

   and seems that not all pendulum method are imported. Substract doesn't work. 
Add works.
   
   ```py
    newer_than='{{ dag_run.logical_date.substract(days=1, hours=-2) }}',
   ```
   
   ```py
   [2024-01-09T08:26:14.525+0000] {taskinstance.py:1826} ERROR - Task failed 
with exception
   Traceback (most recent call last):
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", 
line 1408, in _run_raw_task
       self._execute_task_with_callbacks(context, test_mode)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", 
line 1533, in _execute_task_with_callbacks
       task_orig = self.render_templates(context=context)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/models/taskinstance.py", 
line 2182, in render_templates
       original_task.render_template_fields(context)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/models/baseoperator.py", 
line 1266, in render_template_fields
       self._do_render_template_fields(self, self.template_fields, context, 
jinja_env, set())
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/utils/session.py", line 76, 
in wrapper
       return func(*args, session=session, **kwargs)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/models/abstractoperator.py",
 line 586, in _do_render_template_fields
       rendered_content = self.render_template(
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/template/templater.py", 
line 156, in render_template
       return self._render(template, context)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/models/abstractoperator.py",
 line 540, in _render
       return super()._render(template, context, dag=dag)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/template/templater.py", 
line 113, in _render
       return render_template_to_string(template, context)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/utils/helpers.py", line 
288, in render_template_to_string
       return render_template(template, cast(MutableMapping[str, Any], 
context), native=False)
     File 
"/opt/python3.8/lib/python3.8/site-packages/airflow/utils/helpers.py", line 
283, in render_template
       return "".join(nodes)
     File "<template>", line 12, in root
     File "/opt/python3.8/lib/python3.8/site-packages/jinja2/sandbox.py", line 
391, in call
       if not __self.is_safe_callable(__obj):
     File "/opt/python3.8/lib/python3.8/site-packages/jinja2/sandbox.py", line 
275, in is_safe_callable
       getattr(obj, "unsafe_callable", False) or getattr(obj, "alters_data", 
False)
     File "/opt/python3.8/lib/python3.8/site-packages/jinja2/runtime.py", line 
859, in __getattr__
       return self._fail_with_undefined_error()
     File "/opt/python3.8/lib/python3.8/site-packages/jinja2/runtime.py", line 
852, in _fail_with_undefined_error
       raise self._undefined_exception(self._undefined_message)
   
   jinja2.exceptions.UndefinedError: 'pendulum.datetime.DateTime object' has no 
attribute 'substract'
   ```
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to