Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ls returns full path, not just items #906

Open
msharp9 opened this issue Oct 23, 2024 · 2 comments
Open

ls returns full path, not just items #906

msharp9 opened this issue Oct 23, 2024 · 2 comments

Comments

@msharp9
Copy link

msharp9 commented Oct 23, 2024

s3fs.S3FileSystem().ls(bucket_path) currently returns: [f'{bucket_path}/file1.txt', f'{bucket_path}/file2.txt', ...].

But running ls, in linux or python's similar function, os.listdir(path), returns just the file names, e.g. ['file1.txt', 'file2.txt', ...].

This is closer to what I'd expect from the docstring as well: https://github.com/fsspec/s3fs/blob/main/s3fs/core.py#L261-L265

>>> s3fs.__version__
'2024.9.0'

I just find this behavior confusing. I'm assuming this would be a relatively large breaking change for most users, but maybe we could add a flag to just return the file names?

@martindurant
Copy link
Member

All of the ls methods in all of the backends return full paths within the context of the filesystem (i.e., usually without a protocol prefix). If the docsstring is wrong, it should be fixed.

There have been discussions on making the return value for file information more concretely defined. It would be reasonable to have the "base name", "full path" and "canonical name" (with prefix and other URL parameters) as fields. That would still leave the problem to which to show when not requesting to see the details. I think the current pattern, returning strings that you can then directly use with the filesystem, and also the same as you get from find/glob - I think this is a good place to be. It is, however, a matter of judgement.

@msharp9
Copy link
Author

msharp9 commented Oct 29, 2024

I'm happy with whatever, I just searched the issues and didn't see any conversations around this, closed or open.

I do think your suggestion around returning fields makes a lot of sense when requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants