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

spec: support exists() on directories pre-cache #237

Merged
merged 8 commits into from
Jun 8, 2021

Conversation

isidentical
Copy link
Member

import secrets
from adlfs import AzureBlobFileSystem

BUCKET = 'bucket/'
FOLDER = f'{BUCKET}{secrets.token_hex(12)}/'

fs = AzureBlobFileSystem(**opts)
fs.touch(FOLDER + 'foo')
fs.touch(FOLDER + 'bar')
fs.invalidate_cache()

print(fs.exists(FOLDER))
fs.ls(fs._parent(FOLDER))
print(fs.exists(FOLDER))

While the first one is returning False, after the cache the second one is returning true. The reason is that, the exists() implementation first tries to check whether a such a directory exists by traversing the cache and when it fails it tries to check if a blob named path exists though if the directory is not cached, it doesn't check for that. This patch makes it fallback to the default implementation which is basically checking the result of info().

@isidentical
Copy link
Member Author

The test earliest passes but the other failures are caused by /issues/240. CC: @hayesgb @TomAugspurger (it would be really cool to have this, since a lot of codepaths that we have depend on this exist() calls to result with True for directories on all filesystems, thanks!)

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Looks good. One small question.

@isidentical
Copy link
Member Author

One small question.

I can't see the question.

@TomAugspurger
Copy link
Contributor

Strange, my review was lost. The gist was: should the .rstrip call be .rstrip("/", 1) to avoid cases where the path is /path/to/file// (if that's even allowed)?

@isidentical
Copy link
Member Author

Strange, my review was lost. The gist was: should the .rstrip call be .rstrip("/", 1) to avoid cases where the path is /path/to/file// (if that's even allowed)?

There are multiple places where a regular rstrip() is used so I don't think that would help. E.g https://github.com/dask/adlfs/blob/96958331854c5a67917d4c9a802a62720d091374/adlfs/spec.py#L936

@TomAugspurger TomAugspurger mentioned this pull request Jun 8, 2021
Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

CI is passing now. Planning to merge in a few hours.

@TomAugspurger TomAugspurger merged commit deb5abd into fsspec:master Jun 8, 2021
@TomAugspurger
Copy link
Contributor

Thanks @isidentical!

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

Successfully merging this pull request may close these issues.

2 participants