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

exists should work on a bucket #291

Closed
mjkanji opened this issue Nov 22, 2022 · 1 comment · Fixed by #302
Closed

exists should work on a bucket #291

mjkanji opened this issue Nov 22, 2022 · 1 comment · Fixed by #302
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mjkanji
Copy link

mjkanji commented Nov 22, 2022

CloudPath currently doesn't let you easily check if a bucket itself exists. The exists method only works if you provide some path inside the bucket. This is a nice feature in Pathy and the analogous equivalent of pathlib.Path also works. It would be great to have this included in this library as well.

from pathy import Pathy
from cloudpathlib import CloudPath
from pathlib import Path

# Doesn't work
CloudPath("s3://some-bucket/").exists()
# ParamValidationError: Parameter validation failed:
# Invalid length for parameter Key, value: 0, valid min length: 1

Pathy("s3://some-bucket/").exists() # True

# Since a bucket is the equivalent of a drive, a comparison to pathlib.Path 
# for checking if a drive exists (I'm using Windows)
 Path("C:").exists() # True
@pjbull pjbull added bug Something isn't working good first issue Good for newcomers labels Nov 23, 2022
@pjbull
Copy link
Member

pjbull commented Nov 23, 2022

Yeah, agreed that this should work. At least on S3, I think the API is different to check for bucket existence, so it probably needs to be special cased. Not sure, but other backends may work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants