Open jokokojote opened 10 months ago
"I considered making a pull request to address this issue, but I'm not entirely sure about the best solution for this. One straightforward way could be of course to add specific handling for fspath in the make_method
function of WrapperBase
, like so:
def make_method(name):
def method(self, *args, **kwargs):
# Existing code...
# Special handling for __fspath__ when the object is a string or bytes
if name == '__fspath__' and isinstance(obj, (str, bytes)):
return obj
# Rest of the existing code...
However, you know your architecture the best. I am happy make a pull request if desired.
Hi @jokokojote ! We will need something a little bit more robust to solve this issue. The root of the problem is that isinstance
doesn't evaluate the proxy object properly, so we will actually need to find a solution for this.
Describe the bug
When passing a parameter from one pipeline component to another, this parameter is wrapped (
<LazyEvalWrapper>
). When callingos.fspath
on this parameter and the parameter is of typestr
orbytes
, an error occurs:This is due to the fact that
str
andbytes
do not implement__fspath__
, butos._fspath
checks for these types to handle them as valid path-like objects.That is, when
fspath
is called on the wrapped parameter (of typestr
/bytes
) it is not recognised as one of these types (because it is still wrapped) and__fs__path
is called on it.WrapperBase
proxies this call, but then tries to call__fspath__
on the object like it would be some normal path-like object.To reproduce
See this minimal example code:
Expected behaviour
Pipeline component parameters of type
str
andbytes
should be usable with the path protocol.Environment