Skip to content
Draft
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
7 changes: 7 additions & 0 deletions upath/_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ def unchain(self, path: str, kwargs: dict[str, Any]) -> list[ChainSegment]:
out.append(ChainSegment(None, protocol, kw))
if previous_bit is not None:
bit = previous_bit
elif (
protocol in {"blockcache", "filecache", "simplecache"}
and "target_protocol" in kw
):
out.append(ChainSegment(None, protocol, kw))
if previous_bit is not None:
bit = previous_bit
else:
out.append(ChainSegment(bit, protocol, kw))
previous_bit = bit
Expand Down
9 changes: 5 additions & 4 deletions upath/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def __init__(
segments = chain_parser.unchain(
str_args0, {"protocol": protocol, **storage_options}
)
chain = Chain.from_list(segments)
chain = Chain.from_list(Chain.from_list(segments).to_list())
if len(args) > 1:
chain = chain.replace(
path=WrappedFileSystemFlavour.from_protocol(protocol).join(
Expand Down Expand Up @@ -1120,14 +1120,14 @@ def group(self) -> str:

def absolute(self) -> Self:
if self._relative_base is not None:
return self.cwd().joinpath(str(self))
return self.cwd().joinpath(self.__vfspath__())
return self

def is_absolute(self) -> bool:
if self._relative_base is not None:
return False
else:
return self.parser.isabs(str(self))
return self.parser.isabs(self.__vfspath__())

def __eq__(self, other: object) -> bool:
"""UPaths are considered equal if their protocol, path and
Expand Down Expand Up @@ -1293,7 +1293,8 @@ def root(self) -> str:
return self.parser.splitroot(str(self))[1]

def __reduce__(self):
args = tuple(self._raw_urlpaths)
# args = tuple(self._raw_urlpaths)
args = (self.__vfspath__(),)
kwargs = {
"protocol": self._protocol,
**self._storage_options,
Expand Down
9 changes: 2 additions & 7 deletions upath/tests/cases.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import pickle
import re
import stat
import sys
import warnings
Expand Down Expand Up @@ -380,12 +379,8 @@ def test_fsspec_compat(self):
fs = self.path.fs
content = b"a,b,c\n1,2,3\n4,5,6"

def strip_scheme(path):
root = "" if sys.platform.startswith("win") else "/"
return root + re.sub("^[a-z0-9]+:/*", "", str(path))

upath1 = self.path / "output1.csv"
p1 = strip_scheme(upath1)
p1 = upath1.path
upath1.write_bytes(content)
assert fs is upath1.fs
with fs.open(p1) as f:
Expand All @@ -394,7 +389,7 @@ def strip_scheme(path):

# write with fsspec, read with upath
upath2 = self.path / "output2.csv"
p2 = strip_scheme(upath2)
p2 = upath2.path
assert fs is upath2.fs
with fs.open(p2, "wb") as f:
f.write(content)
Expand Down
Loading