ashb commented on a change in pull request #10808:
URL: https://github.com/apache/airflow/pull/10808#discussion_r507658295



##########
File path: airflow/contrib/hooks/wasb_hook.py
##########
@@ -189,3 +197,50 @@ def delete_file(self, container_name, blob_name, 
is_prefix=False,
                                         blob_uri,
                                         delete_snapshots='include',
                                         **kwargs)
+
+
+    def write_string(self, container_name, blob_name, text, encoding = 
'utf-8', **kwargs):
+        """
+        Create a file for Azure Blob Storage from string.
+
+        :param container_name: Name of the container.
+        :type container_name: str
+        :param blob_name: Name of the blob.
+        :type blob_name: str
+        :param text: text content to be written to blob storage
+        :type text: str
+        :param encoding: Python encoding to use to convert the text to bytes
+        :type encoding: str
+        :param kwargs: Optional keyword arguments that
+            `BlockBlobService.create_blob_from_text()` takes.
+        :type kwargs: object
+        """
+        if text is None:
+            raise AirflowException("is_path variable set to FALSE but no text 
was provided.")

Review comment:
       What is_path?

##########
File path: airflow/contrib/hooks/wasb_hook.py
##########
@@ -36,9 +36,17 @@ class WasbHook(BaseHook):
     :type wasb_conn_id: str
     """
 
-    def __init__(self, wasb_conn_id='wasb_default'):
+    def __init__(self, wasb_conn_id='wasb_default', **kwargs):
         self.conn_id = wasb_conn_id
-        self.connection = self.get_conn()
+        if 'sas_token' in kwargs and kwargs['sas_token'] is not None:
+            self.connection = self.get_custom_conn(**kwargs)
+        else:
+            self.connection = self.get_conn()

Review comment:
       Why do you need this when there's already a mechanism for passing kwargs 
to the BlockBlobService.
   
   What is special about `sas_token` -- and if there are other values passed 
here they are just sliently ignored if that is false which doesn't seem very 
good behaviour.
   
   I think a better approach would be to remove this if/else, to pass all 
kwargs to the existing `get_conn()` and have that mergbe the kwargs with the 
extra_dejson from the connection.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to