Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sensor to check status of Dataform action #43055

Merged

Conversation

steve148
Copy link
Contributor

@steve148 steve148 commented Oct 15, 2024

Summary

Adds a new sensor to the Google Cloud provider that waits on the status of a target in a workflow invocation.

Why might this be useful?

Right now I use Airflow to trigger a Dataform workflow on a schedule. I use the async=True argument on the DataformCreateWorkflowInvocationOperator and the DataformWorkflowInvocationStateSensor to wait until the workflow is complete before running subsequent steps. This approach is simple but comes with some tradeoffs due to its lack of granularity.

  1. If any target in the workflow fails, the sensor will also fail. If I want to have subsequent tasks run for any target that does succeed, this approach will not work.
  2. If I have multiple targets that my subsequent tasks depend on, there may be large gap between when Dataform completes the tasks. This approach has subsequent tasks run when the whole Dataform workflow is complete.

The sensor added in this PR addresses the trade offs listed above by providing a more granular sensor. Instead of waiting for the workflow to complete, it waits for a target within the workflow to complete.

@boring-cyborg boring-cyborg bot added area:providers kind:documentation provider:google Google (including GCP) related issues labels Oct 15, 2024
Copy link

boring-cyborg bot commented Oct 15, 2024

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@steve148 steve148 force-pushed the feat/dataform-workflow-invocation-action-sensor branch from daafa10 to 3257f33 Compare October 15, 2024 20:54
Copy link
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Apache Airflow and thanks for your contribution!
Looks good overall - could you please add unit tests?

@steve148 steve148 force-pushed the feat/dataform-workflow-invocation-action-sensor branch from 3257f33 to d66355e Compare October 18, 2024 17:14
Adds a new sensor to check the status of a WorkflowInvocationAction in
Google Cloud Dataform. Heavily based on theDataformWorkflowInvocationStateSensor
which already exists.

Useful for checking the status of a specific target within a Dataform
workflow invocation and taking action based on the status.
@steve148 steve148 force-pushed the feat/dataform-workflow-invocation-action-sensor branch from d66355e to 5abd6b2 Compare October 18, 2024 17:15
@steve148
Copy link
Contributor Author

Hey @shahar1! Thanks for having me here. I rebased the branch to add unit tests and update it to the latest.

Copy link
Contributor

@shahar1 shahar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :) Well done!

@shahar1 shahar1 merged commit ca2c809 into apache:main Oct 23, 2024
6 checks passed
Copy link

boring-cyborg bot commented Oct 23, 2024

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

kaxil added a commit to astronomer/airflow that referenced this pull request Oct 23, 2024
Test was failing here: https://github.com/apache/airflow/actions/runs/11482958870/job/31957874656?pr=43291

```
=========================== short test summary info ============================
FAILED tests/always/test_project_structure.py::TestProjectStructure::test_providers_modules_should_have_tests - AssertionError: Detect added tests in providers module - please remove the tests from OVERLOOKED_TESTS list above
assert equals failed
  set()                            set([
                                     'providers/tests/google/cloud
                                   /sensors/test_dataform.py',
                                   ])
= 1 failed, 12165 passed, 9445 skipped, 2 xfailed, 5 warnings in 571.47s (0:09:31) =

```

This was because the test was added in apache#43055
@kaxil kaxil mentioned this pull request Oct 23, 2024
kaxil added a commit to astronomer/airflow that referenced this pull request Oct 23, 2024
Test was failing here: https://github.com/apache/airflow/actions/runs/11482958870/job/31957874656?pr=43291

```
=========================== short test summary info ============================
FAILED tests/always/test_project_structure.py::TestProjectStructure::test_providers_modules_should_have_tests - AssertionError: Detect added tests in providers module - please remove the tests from OVERLOOKED_TESTS list above
assert equals failed
  set()                            set([
                                     'providers/tests/google/cloud
                                   /sensors/test_dataform.py',
                                   ])
= 1 failed, 12165 passed, 9445 skipped, 2 xfailed, 5 warnings in 571.47s (0:09:31) =

```

This was because the test was added in apache#43055
kaxil added a commit that referenced this pull request Oct 23, 2024
Test was failing here: https://github.com/apache/airflow/actions/runs/11482958870/job/31957874656?pr=43291

```
=========================== short test summary info ============================
FAILED tests/always/test_project_structure.py::TestProjectStructure::test_providers_modules_should_have_tests - AssertionError: Detect added tests in providers module - please remove the tests from OVERLOOKED_TESTS list above
assert equals failed
  set()                            set([
                                     'providers/tests/google/cloud
                                   /sensors/test_dataform.py',
                                   ])
= 1 failed, 12165 passed, 9445 skipped, 2 xfailed, 5 warnings in 571.47s (0:09:31) =

```

This was because the test was added in #43055
harjeevanmaan pushed a commit to harjeevanmaan/airflow that referenced this pull request Oct 23, 2024
Adds a new sensor to check the status of a WorkflowInvocationAction in
Google Cloud Dataform. Heavily based on theDataformWorkflowInvocationStateSensor
which already exists.

Useful for checking the status of a specific target within a Dataform
workflow invocation and taking action based on the status.
harjeevanmaan pushed a commit to harjeevanmaan/airflow that referenced this pull request Oct 23, 2024
Test was failing here: https://github.com/apache/airflow/actions/runs/11482958870/job/31957874656?pr=43291

```
=========================== short test summary info ============================
FAILED tests/always/test_project_structure.py::TestProjectStructure::test_providers_modules_should_have_tests - AssertionError: Detect added tests in providers module - please remove the tests from OVERLOOKED_TESTS list above
assert equals failed
  set()                            set([
                                     'providers/tests/google/cloud
                                   /sensors/test_dataform.py',
                                   ])
= 1 failed, 12165 passed, 9445 skipped, 2 xfailed, 5 warnings in 571.47s (0:09:31) =

```

This was because the test was added in apache#43055
PaulKobow7536 pushed a commit to PaulKobow7536/airflow that referenced this pull request Oct 24, 2024
Adds a new sensor to check the status of a WorkflowInvocationAction in
Google Cloud Dataform. Heavily based on theDataformWorkflowInvocationStateSensor
which already exists.

Useful for checking the status of a specific target within a Dataform
workflow invocation and taking action based on the status.
PaulKobow7536 pushed a commit to PaulKobow7536/airflow that referenced this pull request Oct 24, 2024
Test was failing here: https://github.com/apache/airflow/actions/runs/11482958870/job/31957874656?pr=43291

```
=========================== short test summary info ============================
FAILED tests/always/test_project_structure.py::TestProjectStructure::test_providers_modules_should_have_tests - AssertionError: Detect added tests in providers module - please remove the tests from OVERLOOKED_TESTS list above
assert equals failed
  set()                            set([
                                     'providers/tests/google/cloud
                                   /sensors/test_dataform.py',
                                   ])
= 1 failed, 12165 passed, 9445 skipped, 2 xfailed, 5 warnings in 571.47s (0:09:31) =

```

This was because the test was added in apache#43055
@steve148 steve148 deleted the feat/dataform-workflow-invocation-action-sensor branch November 6, 2024 15:20
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
Adds a new sensor to check the status of a WorkflowInvocationAction in
Google Cloud Dataform. Heavily based on theDataformWorkflowInvocationStateSensor
which already exists.

Useful for checking the status of a specific target within a Dataform
workflow invocation and taking action based on the status.
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
Test was failing here: https://github.com/apache/airflow/actions/runs/11482958870/job/31957874656?pr=43291

```
=========================== short test summary info ============================
FAILED tests/always/test_project_structure.py::TestProjectStructure::test_providers_modules_should_have_tests - AssertionError: Detect added tests in providers module - please remove the tests from OVERLOOKED_TESTS list above
assert equals failed
  set()                            set([
                                     'providers/tests/google/cloud
                                   /sensors/test_dataform.py',
                                   ])
= 1 failed, 12165 passed, 9445 skipped, 2 xfailed, 5 warnings in 571.47s (0:09:31) =

```

This was because the test was added in apache#43055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:documentation provider:google Google (including GCP) related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants