Skip to content

Try number is incorrect #32290

Closed
Closed

Description

@aamster

Apache Airflow version

2.6.2

What happened

All tasks were run 1 time. The try number is 2 for all tasks

What you think should happen instead

Try number should be 1 if only tried 1 time

How to reproduce

Run a task and use the UI to look up try number

Operating System

centos

Versions of Apache Airflow Providers

No response

Deployment

Virtualenv installation

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. Adaverse commented on Jul 3, 2023

    @Adaverse
    Contributor

    I looked into it, the endpoint api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id} and it was giving the right result. In the code, it is seems to be attached to the field _try_number

    _try_number = auto_field(data_key="try_number")
    

    but the one we see in the UI is try_number attribute from TaskInstance model which is _try_number + 1 for finished tasks

        @hybrid_property
        def try_number(self):
            """
            Return the try number that this task number will be when it is actually
            run.
    
            If the TaskInstance is currently running, this will match the column in the
            database, in all other cases this will be incremented.
            """
            # This is designed so that task logs end up in the right file.
            if self.state == State.RUNNING:
                return self._try_number
            return self._try_number + 1
    

    So we can, instead of showing try_number we can show _try_number in the UI.

    Will open a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions