Skip to content

dirfs info not working with ftp implementation when path is root, appeared in 2025.3.0 release #1809

@gmaze

Description

@gmaze

Hi,
My CI upstream tests at argopy started to fail after the 2025.3.0 fsspec release and it seems to arise from changes added by #1798 in the last 2025.3.0 release.

Here is a reproducible example.

The following works ok:

fs = fsspec.filesystem("dir", fs=fsspec.filesystem('ftp', host='ftp.ifremer.fr'), path='ifremer/argo')
fs.info('dac/aoml/13857/13857_meta.nc')

but in this scenario:

fs = fsspec.filesystem("dir", fs=fsspec.filesystem('ftp', host='ftp.ifremer.fr'), path='/')
fs.info('ifremer/argo/dac/aoml/13857/13857_meta.nc')

we get the error:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[2], line 2
      1 fs = fsspec.filesystem("dir", fs=fsspec.filesystem('ftp', host='ftp.ifremer.fr'), path='/')
----> 2 fs.info('ifremer/argo/dac/aoml/13857/13857_meta.nc')

File ~/miniconda3/envs/argopy-py310-all-free/lib/python3.10/site-packages/fsspec/implementations/dirfs.py:242, in DirFileSystem.info(self, path, **kwargs)
    240 info = self.fs.info(self._join(path), **kwargs)
    241 info = info.copy()
--> 242 info["name"] = self._relpath(info["name"])
    243 return info

File ~/miniconda3/envs/argopy-py310-all-free/lib/python3.10/site-packages/fsspec/implementations/dirfs.py:74, in DirFileSystem._relpath(self, path)
     72     if self.path.startswith(self.fs.sep) and not path.startswith(self.fs.sep):
     73         prefix = prefix[1:]
---> 74     assert path.startswith(prefix)
     75     return path[len(prefix) :]
     76 return [self._relpath(_path) for _path in path]

AssertionError:

If we run the same test on a s3 implementation, it works ok:

fs = fsspec.filesystem("dir", fs=fsspec.filesystem('s3'), path='argo-gdac-sandbox/pub')
fs.info('dac/aoml/13857/13857_meta.nc')

provides similar results to:

fs = fsspec.filesystem("dir", fs=fsspec.filesystem('s3'), path='/')
fs.info('argo-gdac-sandbox/pub/dac/aoml/13857/13857_meta.nc')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions