This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-9-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 0c2d53e14bc61e7c7caae3341da60f10830ba187
Author: Wei Lee <[email protected]>
AuthorDate: Tue Apr 30 08:41:10 2024 +0800

    fix(io.path): add missing conn_id to string representation of 
ObjectStoragePath (#39313)
    
    (cherry picked from commit ddd3b5b738fbfc13f6deeb7f0bc1a1e99c3013ba)
---
 airflow/io/path.py    | 6 ++++++
 tests/io/test_path.py | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/airflow/io/path.py b/airflow/io/path.py
index 709f50a316..87ab420b9c 100644
--- a/airflow/io/path.py
+++ b/airflow/io/path.py
@@ -361,3 +361,9 @@ class ObjectStoragePath(CloudPath):
         conn_id = data.pop("conn_id", None)
 
         return ObjectStoragePath(path, conn_id=conn_id, **_kwargs)
+
+    def __str__(self):
+        conn_id = self.storage_options.get("conn_id")
+        if self._protocol and conn_id:
+            return f"{self._protocol}://{conn_id}@{self.path}"
+        return super().__str__()
diff --git a/tests/io/test_path.py b/tests/io/test_path.py
index c08284163b..1ccdfbfb79 100644
--- a/tests/io/test_path.py
+++ b/tests/io/test_path.py
@@ -403,3 +403,8 @@ class TestFs:
 
         assert o.fs is not None
         assert o._fs_cached
+
+    @pytest.mark.parametrize("input_str", ("file:///tmp/foo", 
"s3://conn_id@bucket/test.txt"))
+    def test_str(self, input_str):
+        o = ObjectStoragePath(input_str)
+        assert str(o) == input_str

Reply via email to