airflowairflow-schedulerairflow-2.x

Airflow try number issue


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 

Solution

  • 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