josh-fell commented on code in PR #30197:
URL: https://github.com/apache/airflow/pull/30197#discussion_r1149654050
##########
airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -502,3 +514,152 @@ def test_connection(self):
return success
except Exception as e:
return False, str(e)
+
+
+class WasbAsyncHook(WasbHook):
+ """
+ An async hook that connects to Azure WASB to perform operations.
+
+ :param wasb_conn_id: reference to the :ref:`wasb connection
<howto/connection:wasb>`
+ :param public_read: whether an anonymous public read access should be
used. default is False
+ """
+
+ def __init__(
+ self,
+ wasb_conn_id: str = "wasb_default",
+ public_read: bool = False,
+ ) -> None:
+ """Initialize the hook instance."""
+ self.conn_id = wasb_conn_id
+ self.public_read = public_read
+ self.blob_service_client: AsyncBlobServiceClient = self.get_conn()
+
+ def get_conn(self) -> AsyncBlobServiceClient:
+ """Return the Async BlobServiceClient object."""
+ conn = self.get_connection(self.conn_id)
Review Comment:
Does this need to be wrapped in a `sync_to_async()`?
##########
airflow/providers/microsoft/azure/sensors/wasb.py:
##########
@@ -62,6 +65,64 @@ def poke(self, context: Context):
return hook.check_for_blob(self.container_name, self.blob_name,
**self.check_options)
+class WasbBlobAsyncSensor(WasbBlobSensor):
+ """
+ Polls asynchronously for the existence of a blob in a WASB container.
+
+ :param container_name: name of the container in which the blob should be
searched for
+ :param blob_name: name of the blob to check existence for
+ :param wasb_conn_id: the connection identifier for connecting to Azure WASB
+ :param poll_interval: polling period in seconds to check for the status
Review Comment:
WDYT about also adding `timeout` to the docstring too? Just thinking users
wouldn't have to traverse parent classes to figure out this param can be set.
##########
airflow/providers/microsoft/azure/sensors/wasb.py:
##########
@@ -62,6 +65,64 @@ def poke(self, context: Context):
return hook.check_for_blob(self.container_name, self.blob_name,
**self.check_options)
+class WasbBlobAsyncSensor(WasbBlobSensor):
+ """
+ Polls asynchronously for the existence of a blob in a WASB container.
+
+ :param container_name: name of the container in which the blob should be
searched for
+ :param blob_name: name of the blob to check existence for
+ :param wasb_conn_id: the connection identifier for connecting to Azure WASB
+ :param poll_interval: polling period in seconds to check for the status
Review Comment:
```suggestion
:param poke_interval: polling period in seconds to check for the status
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]