Skip to content

Add api call for changing task instance status #23246

Closed

Description

@josephine093

Description

In the UI you can change the status of a task instance, but there is no API call available for the same feature.

It would be nice to have an api call for this as well.

Use case/motivation

I found a solution on stack-overflow on [How to add manual tasks in an Apache Airflow Dag]. There is a suggestion to set a task on failed and change it manually to succeed when the task is done.

Our project has many manual tasks. This suggestions seems like a good option, but there is no api call yet to call instead of change all status manually. I would like to use an api call for this instead.

You can change the status of on a dag run so it also seems natural to have something similar for task instances.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Apr 26, 2022

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. tirkarthi commented on Apr 26, 2022

    @tirkarthi
    Contributor

    There is /api/v1/dags/{dag_id}/updateTaskInstancesState.

    Sample payload :

    json={
    "dry_run": True,
    "task_id": "print_the_context",
    "execution_date": DEFAULT_DATETIME_1,
    "include_upstream": True,
    "include_downstream": True,
    "include_future": True,
    "include_past": True,
    "new_state": "failed",
    },

  3. ashb commented on Apr 26, 2022

    @ashb
    Member

    There should probably also be a POST to update a single TI just for consistency sake too.

  4. tirkarthi commented on Apr 26, 2022

    @tirkarthi
    Contributor

    Agreed, there is also #23227 to clear a given task under a DAG run which seems little similar to this request if my understanding is correct.

  5. erdos2n commented on Apr 26, 2022

    @erdos2n
    Contributor

    @ashb @tirkarthi is it possible to get assigned this issue? I would love to take it if possible.

  6. tirkarthi commented on Apr 26, 2022

    @tirkarthi
    Contributor

    @erdos2n I am not working on it. Feel free to take it up.

  7. ephraimbuddy commented on Apr 28, 2022

    @ephraimbuddy
    Contributor

    There should probably also be a POST to update a single TI just for consistency sake too.

    I think updating a single TI is possible in the current endpoint. Setting these:

        "include_upstream": False, 
         "include_downstream": False, 
         "include_future": False, 
         "include_past": False, 

    False in the payload will have it update only the particular task instance

  8. ephraimbuddy commented on Apr 28, 2022

    @ephraimbuddy
    Contributor

    There should probably also be a POST to update a single TI just for consistency sake too.

    I think updating a single TI is possible in the current endpoint. Setting these:

        "include_upstream": False, 
         "include_downstream": False, 
         "include_future": False, 
         "include_past": False, 

    False in the payload will have it update only the particular task instance

    Problem with this is the date range that it updates. Yeah, will be good to be more specific

  9. ashb commented on Apr 28, 2022

    @ashb
    Member

    From a RESTy point of view I like and end point where the task id is in the URL :)

  10. added
    area:API
    on Apr 28, 2022
  11. added this to the Airflow 2.4.0 milestone on May 2, 2022
  12. erdos2n commented on May 13, 2022

    @erdos2n
    Contributor

    @ephraimbuddy @ashb about to write some test cases. Should this be a PATCH request since this updates a task instance state as opposed to POST which is typically used to create the task instance?

  13. uranusjr commented on May 14, 2022

    @uranusjr
    Member

    PATCH sounds like a reasonable choice to me.

  14. erdos2n commented on Jun 19, 2022

    @erdos2n
    Contributor

    I have written the methods needed, but for some reason my tests are failing when I run them locally. Curious if it's something in the v1.yaml file. Can someone possibly help me out with this sometime?

  15. potiuk commented on Jun 19, 2022

    @potiuk
    Member

    Runing stuff in breeze (after updating the image) is the best way to test stuff in a reproducible environment that is the same on CI as locally and one that you can make sure hsa all the same dependencies - this is an often reason of the "works for me" syndrome when running tests. I recommend running tests for breeze (not sure though if that's exactly the case of yours).

  16. erdos2n commented on Jul 21, 2022

    @erdos2n
    Contributor

    unnassigning myself, as I am unable to get the tests to pass

  17. removed their assignment
    on Jul 21, 2022
  18. cedkoffeto commented on Aug 18, 2022

    @cedkoffeto
    Contributor

    Hi everyone, I am new in the airflow community and want to help and learn.
    Am interested in this issue so @erdos2n can we assign it to me, please?

  19. cedkoffeto commented on Aug 18, 2022

    @cedkoffeto
    Contributor

    Do you think we should add an API call like this? /taskInstances/{task_instance_id}/update just to be focused on the DagRun itself.

  20. potiuk commented on Aug 26, 2022

    @potiuk
    Member

    I think it's best to add draft PR with proposal and discuss it there.

  21. cedkoffeto commented on Aug 28, 2022

    @cedkoffeto
    Contributor

    Sure, Thank you for your feedback

  22. removed this from the Airflow 2.5.0 milestone on Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:APIkind:feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions