You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "phanikumv (via GitHub)" <gi...@apache.org> on 2023/05/02 07:05:59 UTC
[GitHub] [airflow] phanikumv opened a new pull request, #31009: Optimize deferred mode execution for wasb sensors
phanikumv opened a new pull request, #31009:
URL: https://github.com/apache/airflow/pull/31009
In deferrable mode for wasb sensors, we should first check if blob is available or not in the execute method and only defer if that is not successful. This way we don’t run an unnecessary deferral cycle if the condition is already true.
cc @dstandish
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] eladkal merged pull request #31009: Optimize deferred mode execution for wasb sensors
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #31009:
URL: https://github.com/apache/airflow/pull/31009
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] phanikumv commented on a diff in pull request #31009: Optimize deferred mode execution for wasb sensors
Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #31009:
URL: https://github.com/apache/airflow/pull/31009#discussion_r1190908231
##########
tests/providers/microsoft/azure/sensors/test_wasb.py:
##########
@@ -128,9 +128,17 @@ def create_context(self, task, dag=None):
deferrable=True,
)
- def test_wasb_blob_sensor_async(self):
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbHook")
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbBlobSensor.defer")
+ def test_wasb_blob_sensor_finish_before_deferred(self, mock_defer, mock_hook):
+ mock_hook.return_value.check_for_blob.return_value = True
+ self.SENSOR.execute(mock.MagicMock())
+ assert not mock_defer.called
Review Comment:
Done in [4d9fefc](https://github.com/apache/airflow/pull/31009/commits/4d9fefc43fb92a99735b0fb65c23728b2498fc5e)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] pankajastro commented on a diff in pull request #31009: Optimize deferred mode execution for wasb sensors
Posted by "pankajastro (via GitHub)" <gi...@apache.org>.
pankajastro commented on code in PR #31009:
URL: https://github.com/apache/airflow/pull/31009#discussion_r1183339652
##########
tests/providers/microsoft/azure/sensors/test_wasb.py:
##########
@@ -128,9 +128,17 @@ def create_context(self, task, dag=None):
deferrable=True,
)
- def test_wasb_blob_sensor_async(self):
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbHook")
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbBlobSensor.defer")
+ def test_wasb_blob_sensor_finish_before_deferred(self, mock_defer, mock_hook):
+ mock_hook.return_value.check_for_blob.return_value = True
+ self.SENSOR.execute(mock.MagicMock())
+ assert not mock_defer.called
Review Comment:
should we use `mock_defer.assert_not_called()` instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on a diff in pull request #31009: Optimize deferred mode execution for wasb sensors
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #31009:
URL: https://github.com/apache/airflow/pull/31009#discussion_r1187828193
##########
tests/providers/microsoft/azure/sensors/test_wasb.py:
##########
@@ -128,9 +128,17 @@ def create_context(self, task, dag=None):
deferrable=True,
)
- def test_wasb_blob_sensor_async(self):
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbHook")
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbBlobSensor.defer")
+ def test_wasb_blob_sensor_finish_before_deferred(self, mock_defer, mock_hook):
+ mock_hook.return_value.check_for_blob.return_value = True
+ self.SENSOR.execute(mock.MagicMock())
+ assert not mock_defer.called
Review Comment:
yes. I think we should
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] phanikumv commented on a diff in pull request #31009: Optimize deferred mode execution for wasb sensors
Posted by "phanikumv (via GitHub)" <gi...@apache.org>.
phanikumv commented on code in PR #31009:
URL: https://github.com/apache/airflow/pull/31009#discussion_r1190988626
##########
tests/providers/microsoft/azure/sensors/test_wasb.py:
##########
@@ -128,9 +128,17 @@ def create_context(self, task, dag=None):
deferrable=True,
)
- def test_wasb_blob_sensor_async(self):
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbHook")
+ @mock.patch("airflow.providers.microsoft.azure.sensors.wasb.WasbBlobSensor.defer")
+ def test_wasb_blob_sensor_finish_before_deferred(self, mock_defer, mock_hook):
+ mock_hook.return_value.check_for_blob.return_value = True
+ self.SENSOR.execute(mock.MagicMock())
+ assert not mock_defer.called
Review Comment:
it doesnt work as `mock_defer.assert_not_called()` results in None
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org