Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions airflow-core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ dependencies = [
"tenacity>=8.3.0",
"termcolor>=3.0.0",
"typing-extensions>=4.14.1",
# Universal Pathlib 0.2.4 adds extra validation for Paths and our integration with local file paths
# Does not work with it Tracked in https://github.com/fsspec/universal_pathlib/issues/276
"universal-pathlib>=0.2.2,!=0.2.4",
"universal-pathlib>=0.3.0",
"uuid6>=2024.7.10",
"apache-airflow-task-sdk<1.3.0,>=1.1.0",
# pre-installed providers
Expand Down
6 changes: 4 additions & 2 deletions task-sdk/src/airflow/sdk/io/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def _cp_file(self, dst: ObjectStoragePath, **kwargs):
# make use of system dependent buffer size
shutil.copyfileobj(f1, f2, **kwargs)

def copy(self, dst: str | ObjectStoragePath, recursive: bool = False, **kwargs) -> None:
def copy(self, dst: str | ObjectStoragePath, recursive: bool = False, **kwargs) -> None: # type: ignore[override]
"""
Copy file(s) from this path to another location.

Expand All @@ -307,6 +307,8 @@ def copy(self, dst: str | ObjectStoragePath, recursive: bool = False, **kwargs)

kwargs: Additional keyword arguments to be passed to the underlying implementation.
"""
# TODO: change dst arg to target when we bump major version for task-sdk and remove type: ignore in copy method

from airflow.lineage.hook import get_hook_lineage_collector

if isinstance(dst, str):
Expand Down Expand Up @@ -413,5 +415,5 @@ def deserialize(cls, data: dict, version: int) -> ObjectStoragePath:
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 f"{self._protocol}://{conn_id}@{self.parser.join(*self._raw_urlpaths)}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really the only options? Relying on a private method doesn't feel great.

Could we do this instead:

super(type(self), self).__str__(self.path)

It's much more verbose, and opaque, yes, but it doesn't depend on accessing a "private" method?
Or use self.parts somehow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per your comment below, we should likely restrict 0.3.0 and use this library properly

return super().__str__()
4 changes: 2 additions & 2 deletions task-sdk/tests/task_sdk/io/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _strip_protocol(cls, path):
class TestAttach:
FAKE = "ffs:///fake"
MNT = "ffs:///mnt/warehouse"
FOO = "ffs:///mnt/warehouse/foo"
FOO = "ffs://fake@/mnt/warehouse/foo"
BAR = FOO

@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_relative_to(self, tmp_path, target):
o1 = ObjectStoragePath(f"file://{target}")
o2 = ObjectStoragePath(f"file://{tmp_path.as_posix()}")
o3 = ObjectStoragePath(f"file:///{uuid.uuid4()}")
assert o1.relative_to(o2) == o1
assert o1.relative_to(o2)
with pytest.raises(ValueError, match="is not in the subpath of"):
o1.relative_to(o3)

Expand Down
Loading