Skip to content

Commit

Permalink
fix(io.path): add missing conn_id to string representation of ObjectS…
Browse files Browse the repository at this point in the history
…toragePath
  • Loading branch information
Lee-W committed Apr 29, 2024
1 parent 6112745 commit cb98b09
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions airflow/io/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,9 @@ def deserialize(cls, data: dict, version: int) -> ObjectStoragePath:
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__()
5 changes: 5 additions & 0 deletions tests/io/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,8 @@ def test_lazy_load(self):

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

0 comments on commit cb98b09

Please sign in to comment.