This is an automated email from the ASF dual-hosted git repository. pierrejeambrun pushed a commit to branch v2-5-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit df8fbb01dfb3ae24569515945e4fb143f6959db1 Author: Sam Wheating <[email protected]> AuthorDate: Fri Mar 10 04:01:15 2023 -0800 Fixing broken filter in in /taskinstance/list view (#29850) (cherry picked from commit a3c9902bc606f0c067a45f09e9d3d152058918e9) --- airflow/models/taskinstance.py | 9 ++++++++- tests/www/views/test_views.py | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py index f4fc7bcd42..f8e0fe95eb 100644 --- a/airflow/models/taskinstance.py +++ b/airflow/models/taskinstance.py @@ -135,6 +135,13 @@ if TYPE_CHECKING: from airflow.models.operator import Operator from airflow.utils.task_group import MappedTaskGroup, TaskGroup + # This is a workaround because mypy doesn't work with hybrid_property + # TODO: remove this hack and move hybrid_property back to main import block + # See https://github.com/python/mypy/issues/4430 + hybrid_property = property +else: + from sqlalchemy.ext.hybrid import hybrid_property + @contextlib.contextmanager def set_current_context(context: Context) -> Generator[Context, None, None]: @@ -537,7 +544,7 @@ class TaskInstance(Base, LoggingMixin): self._log = logging.getLogger("airflow.task") self.test_mode = False # can be changed when calling 'run' - @property + @hybrid_property def try_number(self): """ Return the try number that this task number will be when it is actually diff --git a/tests/www/views/test_views.py b/tests/www/views/test_views.py index 1a0894bac4..ee1eb7a53a 100644 --- a/tests/www/views/test_views.py +++ b/tests/www/views/test_views.py @@ -146,6 +146,19 @@ def test_task_start_date_filter(admin_client, url, content): check_content_in_response(content, resp) [email protected]( + "url", + [ + "/taskinstance/list/?_flt_1_try_number=0", # greater than + "/taskinstance/list/?_flt_2_try_number=5", # less than + ], +) +def test_try_number_filter(admin_client, url): + resp = admin_client.get(url) + # Ensure that the taskInstance view can filter on gt / lt try_number + check_content_in_response("List Task Instance", resp) + + @pytest.mark.parametrize( "url, content", [
