mik-laj commented on a change in pull request #21785:
URL: https://github.com/apache/airflow/pull/21785#discussion_r817117343



##########
File path: airflow/providers/alibaba/cloud/hooks/oss.py
##########
@@ -269,6 +279,74 @@ def create_bucket(
             self.log.error(e)
             raise AirflowException(f"Errors when create bucket: {bucket_name}")
 
+    @provide_bucket_name
+    @unify_bucket_name_and_key
+    def append_string(self, bucket_name: Optional[str], content: str, key: 
str, pos: int):
+        """
+        Append string to a remote existing file
+
+        :param bucket_name: the name of the bucket
+        :param content: content to be appended
+        :param key: oss bucket key
+        :param pos: position of the existing file where the content will be 
appended
+        """
+        self.log.info("Write oss bucket key: " + key)
+        self.log.info("Write oss bucket pos: " + str(pos))

Review comment:
       ```suggestion
           self.log.info("Write oss bucket. key: %s, pos: %s", key, pos)
   ```
   Pass the text and arguments to the logger separately so that they can be 
formatted depending on the logger configuration. See: 
https://github.com/apache/airflow/blob/8505d2f0a4524313e3eff7a4f16b9a9439c7a79f/airflow/utils/log/colored_log.py#L39

##########
File path: airflow/providers/alibaba/cloud/hooks/oss.py
##########
@@ -269,6 +279,74 @@ def create_bucket(
             self.log.error(e)
             raise AirflowException(f"Errors when create bucket: {bucket_name}")
 
+    @provide_bucket_name
+    @unify_bucket_name_and_key
+    def append_string(self, bucket_name: Optional[str], content: str, key: 
str, pos: int):
+        """
+        Append string to a remote existing file
+
+        :param bucket_name: the name of the bucket
+        :param content: content to be appended
+        :param key: oss bucket key
+        :param pos: position of the existing file where the content will be 
appended
+        """
+        self.log.info("Write oss bucket key: " + key)
+        self.log.info("Write oss bucket pos: " + str(pos))
+        try:
+            self.get_bucket(bucket_name).append_object(key, pos, content)
+        except Exception as e:
+            self.log.error(e)
+            raise AirflowException(f"Errors when append string for object: 
{key}")
+
+    @provide_bucket_name
+    @unify_bucket_name_and_key
+    def read_key(self, bucket_name: Optional[str], key: str) -> str:
+        """
+        Read oss remote object content with the specified key
+
+        :param bucket_name: the name of the bucket
+        :param key: oss bucket key
+        """
+        self.log.info("Read oss key: " + key)

Review comment:
       ```suggestion
           self.log.info("Read oss key: %s", key)
   ```




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


Reply via email to