0

I have encountered an error during testing , does anyone have any lead on this.

Code:

relative_path = self._render_filename(ti, ti.try_number)

Error:

AttributeError: 'str' object has no attribute 'try_number 
Amila Senadheera
  • 12,229
  • 15
  • 27
  • 43
  • can you share pleas the full test? – ozs Jun 27 '22 at 15:12
  • I am using base hook to connect to http connection and below is the error File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/file_task_handler.py", line 285, in _init_file relative_path = self._render_filename(ti, ti.try_number) AttributeError: 'str' object has no attribute 'try_number' – jonuchauhan Jun 27 '22 at 17:01

2 Answers2

0

I was facing the same issue, but in my case I was initialising the BaseHook with string

super().__init__("mystring")

removing this "mystring" and initialising the base hook with None works for me.

0

This error in Airflow usually happens because the BaseHook class can no longer receive an str parameter[1], only a ti (TaskInstance) [2]. You can simply create the BaseHook without providing any parameters like:

my_hook = BaseHook()

[1] https://airflow.apache.org/docs/apache-airflow/stable/_modules/airflow/hooks/base.html#BaseHook

[2] https://airflow.apache.org/docs/apache-airflow/1.10.6/_modules/airflow/utils/log/logging_mixin.html