Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion airflow/models/taskinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@
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


PAST_DEPENDS_MET = "past_depends_met"

Expand Down Expand Up @@ -561,7 +568,7 @@ def init_on_load(self) -> None:
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
Expand Down
13 changes: 13 additions & 0 deletions tests/www/views/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ def test_task_start_date_filter(admin_client, url, content):
check_content_in_response(content, resp)


@pytest.mark.parametrize(
"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",
[
Expand Down